diff --git a/.github/.gitleaksignore b/.github/.gitleaksignore new file mode 100644 index 00000000..01568450 --- /dev/null +++ b/.github/.gitleaksignore @@ -0,0 +1,4 @@ +# gitleaks false positives, by fingerprint. Each was read; none is a secret. +# docs kubernetes.mdx: the name of an environment variable read from a +# Kubernetes secretKeyRef (ED25519_PRIVATE_KEY_HEX), not a value. +75b97eb03db9940eb43ccbaeacdda4cfc99ed778:docs/docs/admin/environments/kubernetes.mdx:generic-api-key:65 diff --git a/.github/gitleaks.toml b/.github/gitleaks.toml new file mode 100644 index 00000000..f2b9fc58 --- /dev/null +++ b/.github/gitleaks.toml @@ -0,0 +1,13 @@ +# gitleaks (keel-linux/.github, security-scan.yml): the default rules, less +# upstream's test fixtures below: throwaway TLS keys of the config tests and +# the SSH key of the gitweb integration test (docker-compose). A new fixture +# is added here by path once it has been read. +[extend] +useDefault = true + +[[allowlists]] +description = "upstream test fixtures, throwaway keys on purpose" +paths = [ + '''^lib/config/testdata/tls/''', + '''^test/gitweb/secrets/id_rsa$''', +] diff --git a/.github/security-baseline b/.github/security-baseline new file mode 100644 index 00000000..479fe7c8 --- /dev/null +++ b/.github/security-baseline @@ -0,0 +1,65 @@ +# Security scan baseline (keel-linux/.github, security-scan.yml): findings +# that were read and are not a risk, one per line, the fingerprint and why. +semgrep:generic.secrets.security.detected-private-key.detected-private-key:lib/config/testdata/tls/1.1.1.1/key.pem:e5380d8e1131 upstream test fixture: a throwaway TLS key for the config tests, never used by a deployment +semgrep:generic.secrets.security.detected-private-key.detected-private-key:lib/config/testdata/tls/minica-key.pem:e5380d8e1131 upstream test fixture: a throwaway TLS key for the config tests, never used by a deployment +semgrep:generic.secrets.security.detected-private-key.detected-private-key:lib/config/testdata/tls/selfsigned.key:e5380d8e1131 upstream test fixture: a throwaway TLS key for the config tests, never used by a deployment +semgrep:go.lang.security.audit.crypto.math_random.math-random-used:internal/honeypot/naive/naive.go:16cc1e9b49ab math/rand used for non-secret randomness (honeypot filler, sampling chance, a CEL random function); no key, token or nonce comes from it +semgrep:go.lang.security.audit.crypto.math_random.math-random-used:lib/http.go:6015cc9b848e math/rand used for non-secret randomness (honeypot filler, sampling chance, a CEL random function); no key, token or nonce comes from it +semgrep:go.lang.security.audit.crypto.math_random.math-random-used:lib/policy/expressions/environment.go:16cc1e9b49ab math/rand used for non-secret randomness (honeypot filler, sampling chance, a CEL random function); no key, token or nonce comes from it +semgrep:go.lang.security.audit.crypto.missing-ssl-minversion.missing-ssl-minversion:cmd/anubis/main.go:2feb7a57e087 Go's default minimum is TLS 1.2, which is acceptable; certificate checks stay on unless the operator sets the insecure-skip-verify option +semgrep:go.lang.security.audit.crypto.missing-ssl-minversion.missing-ssl-minversion:internal/ogtags/ogtags.go:2feb7a57e087 Go's default minimum is TLS 1.2, which is acceptable; certificate checks stay on unless the operator sets the insecure-skip-verify option +semgrep:go.lang.security.audit.crypto.missing-ssl-minversion.missing-ssl-minversion:internal/ogtags/sni.go:b0d121b1cbee Go's default minimum is TLS 1.2, which is acceptable; certificate checks stay on unless the operator sets the insecure-skip-verify option +semgrep:go.lang.security.audit.crypto.missing-ssl-minversion.missing-ssl-minversion:lib/metrics/metrics.go:c994cf3b2dcd Go's default minimum is TLS 1.2, which is acceptable; certificate checks stay on unless the operator sets the insecure-skip-verify option +semgrep:go.lang.security.audit.crypto.missing-ssl-minversion.missing-ssl-minversion:lib/thoth/thoth.go:3d0d7434fc25 Go's default minimum is TLS 1.2, which is acceptable; certificate checks stay on unless the operator sets the insecure-skip-verify option +semgrep:go.lang.security.audit.crypto.use_of_weak_crypto.use-of-sha1:internal/servicesid/servicesid.go:02079b6aeed0 SHA-1 computes a Windows service SID, a fixed public derivation, not a signature or password hash +semgrep:go.lang.security.audit.net.cookie-missing-httponly.cookie-missing-httponly:lib/http.go:27fc162499bb HttpOnly is set from the operator's CookieHttpOnly option, not omitted +semgrep:go.lang.security.audit.net.cookie-missing-secure.cookie-missing-secure:lib/http.go:27fc162499bb Secure is set from the operator's CookieSecure option, and SameSite=None falls back to Lax when it is off +semgrep:go.lang.security.injection.open-redirect.open-redirect:lib/http.go:548bf858ce4b runs only when Anubis has no TARGET (s.next nil); Keel Web and debian/default.env always set one, so it is unreachable as shipped. Without a TARGET and REDIRECT_DOMAINS, upstream allows any http(s) redir after a pass, and warns at startup +shellcheck:SC2027:vendor/golang.org/x/sys/unix/mkall.sh:903958b3ffea vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:run/anubis.freebsd:04e6173dc4cc FreeBSD rc.d variables (rcvar, command, command_args, start_precmd) are read by rc.subr, which sources the script +shellcheck:SC2034:run/anubis.freebsd:420e4ea14c9b FreeBSD rc.d variables (rcvar, command, command_args, start_precmd) are read by rc.subr, which sources the script +shellcheck:SC2034:run/anubis.freebsd:46abc4239738 FreeBSD rc.d variables (rcvar, command, command_args, start_precmd) are read by rc.subr, which sources the script +shellcheck:SC2034:run/anubis.freebsd:b5e74ee5c7e1 FreeBSD rc.d variables (rcvar, command, command_args, start_precmd) are read by rc.subr, which sources the script +shellcheck:SC2034:run/anubis.freebsd:cead3587455d FreeBSD rc.d variables (rcvar, command, command_args, start_precmd) are read by rc.subr, which sources the script +shellcheck:SC2034:vendor/golang.org/x/sys/plan9/mkerrors.sh:5eebe606c96d vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:4f366bbcd601 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:5387c764097c vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:5c14e1064006 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:5e46f16f3202 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:5eebe606c96d vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:821650bd33e8 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:863ec1500478 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:a47b15e438dc vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/golang.org/x/sys/unix/mkerrors.sh:f07149a786c3 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/mvdan.cc/sh/v3/syntax/canonical.sh:42bd877c71ff vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2034:vendor/mvdan.cc/sh/v3/syntax/canonical.sh:7f8a785d944d vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/aws/smithy-go/local-mod-replace.sh:4d78b18deae1 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/go-git/go-git/v5/oss-fuzz.sh:36a2554ba728 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/go-git/go-git/v5/oss-fuzz.sh:42f925fdc696 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/go-git/go-git/v5/oss-fuzz.sh:494b4282fffd vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/go-git/go-git/v5/oss-fuzz.sh:886e18039fd7 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/go-git/go-git/v5/oss-fuzz.sh:afdc679c9814 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/go-git/go-git/v5/oss-fuzz.sh:db23b9e4197f vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/github.com/go-git/go-git/v5/oss-fuzz.sh:fee07f93108a vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/golang.org/x/sys/unix/mkall.sh:f6b69a40906e vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/golang.org/x/telemetry/npm:64cd75343f25 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2046:vendor/golang.org/x/telemetry/npx:64cd75343f25 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2068:vendor/cel.dev/expr/regen_go_proto.sh:a37a5f0d6dda vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2068:vendor/golang.org/x/telemetry/npm:c3b845abdaed vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2068:vendor/golang.org/x/telemetry/npx:c3b845abdaed vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2084:vendor/mvdan.cc/sh/v3/syntax/canonical.sh:858be52c0407 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2091:vendor/cel.dev/expr/regen_go_proto.sh:fff3d638297c vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2091:vendor/mvdan.cc/sh/v3/syntax/canonical.sh:d8a6bcd2d2e1 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2124:vendor/golang.org/x/sys/plan9/mkerrors.sh:4108235065a9 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2124:vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh:bb09c5eb53bc vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2124:vendor/golang.org/x/sys/unix/mkerrors.sh:4108235065a9 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2148:vendor/github.com/aws/smithy-go/local-mod-replace.sh:f0b0d447d862 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2207:vendor/cel.dev/expr/regen_go_proto.sh:922e7bf2906c vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2207:vendor/cel.dev/expr/regen_go_proto_canonical_protos.sh:d16affef01ff vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2221:vendor/golang.org/x/sys/plan9/mkall.sh:92c0be71a608 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2221:vendor/golang.org/x/sys/unix/mkall.sh:92c0be71a608 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2222:vendor/golang.org/x/sys/plan9/mkall.sh:92c0be71a608 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC2222:vendor/golang.org/x/sys/unix/mkall.sh:92c0be71a608 vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC3030:vendor/cel.dev/expr/regen_go_proto.sh:922e7bf2906c vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +shellcheck:SC3054:vendor/cel.dev/expr/regen_go_proto.sh:a37a5f0d6dda vendored Go module's code-generation script (golang.org/x, go-git, cel, aws, mvdan sh), never run by the package build nor installed; shell lint, not a risk +semgrep:go.lang.security.injection.open-redirect.open-redirect:lib/anubis.go:548bf858ce4b upstream's PassChallenge compares redir's host with itself (an open redirect without REDIRECT_DOMAINS); the package closes it with debian/patches/redir-same-host.patch and redir-validate.patch, covered by autopkgtest behind-nginx diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 00000000..b40ce418 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,19 @@ +# Security scanning (keel-linux/.github, profile/WORKFLOWS.md "Security +# scanning"): gitleaks, bandit, semgrep and shellcheck on GitHub-hosted +# runners, no secrets. Findings that are not a risk are listed, each with its +# justification, in .github/security-baseline; gitleaks fixtures, if any, in +# .github/gitleaks.toml. +name: security +on: + pull_request: + push: + branches: [keel/trixie] + workflow_dispatch: +permissions: + contents: read +jobs: + security: + uses: keel-linux/.github/.github/workflows/security-scan.yml@main + permissions: + contents: read + security-events: write