Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
check-latest: false

- name: initialize
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
languages: go
queries: security-and-quality
Expand All @@ -52,6 +52,6 @@ jobs:
run: go build ./...

- name: analyze
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
category: '/language:go'
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
# .github/action-allowlist.txt for the scoping rationale. Never
# blocking — this is observation, not enforcement.
- name: Harden Runner
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2
with:
egress-policy: audit

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
persist-credentials: false

- name: run scorecard
uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -54,6 +54,6 @@ jobs:
publish_results: true

- name: upload SARIF
uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
sarif_file: results.sarif
35 changes: 33 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,38 @@ hardening pass done ahead of open-sourcing — is preserved in

## [Unreleased]

## [0.1.2] — 2026-10-27

### Security
- **Go toolchain bumped to 1.26.9** for GO-2026-6617 (HTTP/2 server crash
from an HPACK encoder race in `net/http`, fixed in 1.26.9).
- **Go toolchain bumped to 1.26.10** for GO-2026-6809 (`crypto/x509`,
reachable from ctxcop's code, fixed in 1.26.10) and GO-2026-6617 (HTTP/2
server crash from an HPACK encoder race in `net/http`, fixed in 1.26.9).
- **Vulnerable indirect dependencies bumped.** govulncheck found none of
these reachable from ctxcop's code; they're patched anyway:
`github.com/google/cel-go` v0.30.0 (GO-2026-6094), `golang.org/x/text`
v0.41.0 (GO-2026-5970, GO-2026-6629), `github.com/klauspost/compress`
v1.18.7 (GO-2026-5841), and `golang.org/x/crypto` v0.56.0 (GO-2026-6303,
GO-2026-6354, GO-2026-6355). GO-2026-5932 (the unmaintained
`x/crypto/openpgp` package) has no fixed version; ctxcop doesn't import it.

### Added
- **Redis AUTH detection: four embedded rules covering the leak shapes
upstream has no answer for.** A bare Redis password has no token prefix
and no key=value shape — the two forms gitleaks-class rules detect — so
the plain AUTH command line as error logs show it, the node-redis
structured error form (args array and JSON), redis-cli `-a`/`--pass`
invocations, and RESP protocol dumps (raw CRLF, escaped, space-flattened)
all passed through unredacted. Rules are ported rule-for-rule from
[webflow/secrets-scrubber](https://github.com/webflow/secrets-scrubber)
(Santiago Moreno), whose project was built around a real Redis key leak
into an AI session; RE2 forbids its JS lookaheads, so its
reference-value heuristic became a per-rule CEL filter. Every rule
carries a minimum-length floor (16 for plain AUTH, 8 elsewhere) — a
sub-8-char finding trips Splice's over-redact backstop against
unrelated lines carrying the same short form. Port deviation: the RESP
rule requires the `*N` array header (all of secrets-scrubber's RESP
fixtures carry it) so prose dollar-amounts near the word auth do not
redact.

### Fixed
- **Hooks drain stdin before exiting.** A paused hook (or one with an off
Expand Down Expand Up @@ -99,4 +128,6 @@ ctxcop's first public release.
- Full line-by-line detail, including issue references, is in the
[pre-1.0 dev log](docs/dev-log/CHANGELOG-pre-1.0.md).

[0.1.2]: https://github.com/webflow/ctxcop/releases/tag/v0.1.2
[0.1.1]: https://github.com/webflow/ctxcop/releases/tag/v0.1.1
[0.1.0]: https://github.com/webflow/ctxcop/releases/tag/v0.1.0
10 changes: 10 additions & 0 deletions THREATMODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ the approach, not bugs:
shaped to evade the ruleset are not in scope — ctxcop assumes the
agent and tools are not actively cooperating in exfiltration.

- **Bare Redis AUTH residuals.** The embedded redis-auth rules cover
the common leak shapes (plain AUTH lines, node-redis structured
errors, RESP dumps, redis-cli flags; ported from
webflow/secrets-scrubber) but keep their floors and framing
requirements: shorter passwords, RESP dumps with an empty
(`$0`-bulk) ACL username, and any RESP command other than AUTH pass
through. Floors exist because a sub-8-char finding trips Splice's
over-redact backstop against unrelated lines carrying the same
short form.

## Out of scope

These are documented non-goals, listed so it's clear what *not* to
Expand Down
15 changes: 14 additions & 1 deletion docs/detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ what every hook scans.
built-in recursive codec decoding (base64/hex/percent/unicode) so
secrets that were encoded before they reached the tool output are
still caught.
2. **ctxcop embedded pack** — eight high-confidence single-purpose
2. **ctxcop embedded pack** — twelve high-confidence single-purpose
patterns shipped in the binary. Same shape as gitleaks rules but
tuned for the CLI-output threat model: where gitleaks requires a
`\b` boundary (so credentials glued to surrounding text by tools
Expand All @@ -27,6 +27,19 @@ what every hook scans.
| `ctxcop-gitlab-pat` | `glpat-` |
| `ctxcop-slack-token` | `xox[bpoars]-` |
| `ctxcop-stripe-secret-key` | `(sk\|rk)_(live\|test)_` |
| `ctxcop-redis-auth-command` | bare `AUTH [user] <password>` command lines (16+, upper/digit gate) |
| `ctxcop-redis-auth-array` | `AUTH` in quoted args arrays / JSON (node-redis error form) |
| `ctxcop-redis-auth-resp` | `AUTH` in RESP protocol dumps (raw / escaped / flattened CRLF) |
| `ctxcop-redis-auth-cli` | `redis-cli` `-a` / `--pass` flag arguments |

The redis-auth rules close a structural gap in the upstream ruleset:
a bare Redis password has no token prefix and no key=value shape, the
two forms gitleaks-class rules detect. Ported from
[webflow/secrets-scrubber](https://github.com/webflow/secrets-scrubber)
(rule-for-rule from its four redis-auth rules; RE2 forbids its JS
lookaheads, so its reference-value heuristic became the per-rule CEL
filter). Redaction span is the whole match: the AUTH verb, RESP
framing, and ACL username vanish with the password.

3. **`~/.ctxcop/*.toml`** — every `.toml` file in the user rules dir,
loaded in alphabetical order. Drop org-specific credential patterns
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/webflow/ctxcop

go 1.26.9
go 1.26.10

require (
github.com/BurntSushi/toml v1.6.0
github.com/betterleaks/betterleaks v1.2.0
github.com/spf13/viper v1.21.0
go.yaml.in/yaml/v3 v3.0.5
golang.org/x/sys v0.47.0
golang.org/x/sys v0.49.0
)

require (
Expand All @@ -28,14 +28,14 @@ require (
github.com/gitleaks/go-gitdiff v0.9.1 // indirect
github.com/go-sprout/sprout v1.0.3 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/google/cel-go v0.29.0 // indirect
github.com/google/cel-go v0.30.0 // indirect
github.com/google/go-github/v72 v72.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/h2non/filetype v1.1.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/klauspost/compress v1.18.7 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -60,10 +60,10 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
go4.org v0.0.0-20260112195520-a5071408f32f // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/crypto v0.56.0 // indirect
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/text v0.37.0 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/text v0.41.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
google.golang.org/protobuf v1.36.11 // indirect
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ github.com/go-sprout/sprout v1.0.3/go.mod h1:cFFzpnyGGry3cmN0UNCAM1f7AGok6vPVabe
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/cel-go v0.29.0 h1:fEG+Ja3YRwNOqnQxTyJwoByAUAvTuxUGiro/jhrm4F4=
github.com/google/cel-go v0.29.0/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8=
github.com/google/cel-go v0.30.0 h1:ll54AkzKunWkBn9wSoiUXbFZXYZTkdJGNXTBXUoolGo=
github.com/google/cel-go v0.30.0/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
Expand All @@ -64,8 +64,8 @@ github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c=
github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
github.com/klauspost/compress v1.18.7 h1:aUyZsS4kH3QTKurYhAOwAHxllVPnOthb3vPfnF1Ehjw=
github.com/klauspost/compress v1.18.7/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
Expand Down Expand Up @@ -146,21 +146,21 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
go4.org v0.0.0-20260112195520-a5071408f32f h1:ziUVAjmTPwQMBmYR1tbdRFJPtTcQUI12fH9QQjfb0Sw=
go4.org v0.0.0-20260112195520-a5071408f32f/go.mod h1:ZRJnO5ZI4zAwMFp+dS1+V6J6MSyAowhRqAE+DPa1Xp0=
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
golang.org/x/crypto v0.56.0 h1:GUh5Ii4J5jtcseSMiRqr1jXCNHoxjeV9Fmekc2oLy6Y=
golang.org/x/crypto v0.56.0/go.mod h1:OMW5y6CY9l38uPLmxU6l6pwcXp1obtLo3e6gT7gQR2I=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=
Expand Down
85 changes: 85 additions & 0 deletions internal/rules/embedded/ctxcop.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,88 @@ id = "sourcegraph-access-token"
description = "Sourcegraph access token (prefixed forms only; bare 40-hex dropped — collides with Git SHAs)"
regex = '''(?i)\b(\b(sgp_(?:[a-fA-F0-9]{16}|local)_[a-fA-F0-9]{40}|sgp_[a-fA-F0-9]{40})\b)(?:\\?['"\x60]|[\s;]|\\[nr]|$)'''
keywords = ["sgp_"]

# Redis authentication credentials. Ported from webflow/secrets-scrubber
# (built around a real Redis key leak into an AI session), where betterleaks
# upstream has a structural gap: a bare Redis password carries no
# self-identifying token prefix and no key=value assignment structure, the
# two shapes gitleaks-class rules detect. Four leak shapes passed through
# unredacted upstream + embedded as of v0.1.1: the plain AUTH command line
# as error logs and pasted history show it, the node-redis structured error
# form (args array and JSON rendering), redis-cli invocations, and RESP
# protocol dumps in all three encodings they appear in logs (raw CRLF,
# escaped CRLF, space-flattened).
#
# Adaptations from the secrets-scrubber JS originals to RE2 + CEL-filter
# semantics:
# 1. Reference-value exclusion ($VAR refs, process.env chains, template
# placeholders must pass) moves from a replace-callback heuristic into
# a per-rule CEL filter on the captured secret.
# 2. The plain-AUTH "value must contain an uppercase letter or digit"
# gate becomes the `[a-z]*[A-Z0-9]` prefix, preserving the secret-span
# start.
# 3. RESP bulk values exclude whitespace and backslash instead of the JS
# tempered-dot lookahead (RE2 has none). Real passwords contain neither.
# 4. The RESP rule additionally requires the `*N` array header every real
# RESP command dump carries — the JS original does not anchor on it,
# but without it a dollar-amount next to the literal word "auth" in
# prose would redact an innocent trailing word. All of
# secrets-scrubber's RESP fixtures carry the header, so recall on the
# leak shapes is unchanged.
#
# Span semantics: these rules redact the whole match (AUTH verb, framing,
# and ACL username vanish with the password), matching the bearer-token
# rule's house style. The db-connection-uri rule keeps the host only
# because its regex deliberately ends at `@`.
#
# Every rule carries a minimum-length floor: a sub-8-char finding trips
# Splice's over-redact backstop against lines sharing its tiny secret form
# (a stray `/` swept every slash-bearing line during development). The
# plain-AUTH rule keeps secrets-scrubber's 16+ floor; array, RESP, and cli
# rules use 8.
[[rules]]
id = "ctxcop-redis-auth-command"
description = "Redis AUTH command line: optional ACL user then a 16+ char password (upper or digit required)"
regex = '''(?m)(?:^|[^A-Za-z0-9_])AUTH[ \t]+(?:[A-Za-z0-9_.-]{1,64}[ \t]+)?([a-z]*[A-Z0-9][^\s'"`]{15,})'''
keywords = ["auth"]
filter = '''
matchesAny(finding["secret"], [
"^[$<{%\\[]",
"^(?i)(?:process|env|os|self|config|secrets?|var|vars)\\."
])
'''

[[rules]]
id = "ctxcop-redis-auth-array"
description = "Redis AUTH in structured args / JSON: quoted AUTH, optional user, 8+ char quoted password"
regex = '''['"]AUTH['"]\s*,\s*(?:['"][^'"]{1,64}['"]\s*,\s*)?['"]([^'"]{8,})['"]'''
keywords = ["auth"]
filter = '''
matchesAny(finding["secret"], [
"^[$<{%\\[]",
"^(?i)(?:process|env|os|self|config|secrets?|var|vars)\\."
])
'''

[[rules]]
id = "ctxcop-redis-auth-resp"
description = "Redis AUTH in RESP protocol dumps (raw/escaped/flattened CRLF): password bulk string after the AUTH command bulk"
regex = '''(?i)\*[0-9]+(?:\\r\\n|\r\n|\n|\r| )\$4(?:\\r\\n|\r\n|\n|\r| )auth(?:\\r\\n|\r\n|\n|\r| )(?:(?:\$[0-9]+(?:\\r\\n|\r\n|\n|\r| ))?[^\s\\]+(?:\\r\\n|\r\n|\n|\r| ))?\$[0-9]+(?:\\r\\n|\r\n|\n|\r| )([^\s\\]+)'''
keywords = ["auth"]
filter = '''
matchesAny(finding["secret"], [
"^[$<{%\\[]"
])
'''

[[rules]]
id = "ctxcop-redis-auth-cli"
description = "redis-cli password flag arguments (the -a/--pass flags)"
regex = '''\bredis-cli\b[^\n|;&]*?[ \t](?:-a|--pass)[ \t]+['"]?([^\s'"]{8,})'''
keywords = ["redis-cli"]
filter = '''
matchesAny(finding["secret"], [
"^[$<{%\\[]",
"^(?i)(?:process|env|os|self|config|secrets?|var|vars)\\."
])
'''
Loading
Loading