ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e4b0555a17 |
redact: a timestamp under a token's field name is not masked as a secret (#5002)
"access_token_expires_at": "2026-08-30T11:44:31.312645+08:00" went out as
"{{SECRET_…}}:44:31.312645+08:00": the field's name has token in it, and
the SECRET rule took the timestamp's head up to the hour (its colons are
not a secret's characters), so 2026-08-30T11 was masked and the rest was
sent as written. The same happened after 令牌是, 密钥为, token 是,
SERVER_KEY: and DB_PASS:, and in a tool call's arguments the whole value
was masked by its field's name (namedSecret).
An RFC 3339 timestamp, whole or its head to the hour, is now left as
written there (timestampValue, beside versionValue and pathValue in
fieldAt, keyAt and namedSecret). The exemption is by the value's shape,
not the key's name: a value that only starts as a timestamp
(2026-08-30T11x9k2abc) still masks, and a secret beside the timestamp in
the same tool call still masks.
Changed from the contributor's patch: the patch deleted fieldAt's doc
bullet for the next-field rule (nextField), which still exists; it is
kept.
Run (mote): go test -tags nogui ./internal/redact/... ./internal/pii/...
./internal/masking/... (ok); go vet -tags nogui ./internal/redact/...;
gofmt -l (empty).
Broken by hand: with the old fieldvalue.go, json.go and redact.go,
TestTimestampIsNoSecret fails on the reporter's line with the same
output as the report ("{{SECRET_2ojutfrk}}:44:31.312645+08:00") and on
the other lines.
Not tried: the local masking model on the reporter's whole request.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
f02d92c7be |
redact: a file's lines, a path, a skill and a name in code after token: are no secret
Three reports on X (10-28), each a value the SECRET rule took (Insights >
Masking: 机密, 规则). The rule takes a name with token, secret, password
or api_key in it, then : or =, then 8 characters or more with a letter and
a digit. Prompts and code have that shape where nothing is secret:
- AlpsNowX: L643-669. was masked, in two requests. A file whose name has
one of those words, then :L643-669. (internal/auth/token.go:L643-669.)
read as a field token.go and its value, and once masked the lines went
as {{SECRET_…}} wherever they came again (by known). Now a name that is
a source file's (.go, .ts, .py, .md, .json …, not .txt/.env/.key) or a
path's last part is no field, and a line or range (L643, L643-669,
L12-L40, 643:12) is no value. Siblings: token.go:643-669 and #L643-L669
were never masked (no letter / no colon); file.go:L12-40 was, and isn't.
- binary4cat: function names masked. access_token = get_access_token_v2,
max_tokens=max_tokens_v3, secret: env.SECRET_V2, refreshToken2;,
fn(token=token_v2), secretKey:=base64Encode(raw) all masked the name.
A value written as code writes a name (lower-case start, or _ or .
between words) of two words or more, one of them token/secret/password/
key/credential, is a name now; a value starting with = is Go's :=.
- AkinoNya: folders and skills with a random string replaced. Found two
routes: a path after such a name (PRIVATE_KEY_PATH=~/.ssh/id_ed25519,
token_dir=/private/tmp/claude-501/x7k2p9q1-skill,
GOOGLE_APPLICATION_CREDENTIALS=/Users/…/legacy_credentials/x7k2p9q1/…,
私钥 ~/.ssh/…), and Claude Code's plugin:skill when the plugin's name
has one of the words (design-tokens:generate-v2, secret-scan:
audit-x7k2p9q1). A path from ~/, ./, ../ or a root folder (/Users,
/tmp, /private …) with no + or = goes as written, in the CJK key rules
too; slug:slug with no space is a skill. The ~1100 real folder and skill
names on this machine (~/.claude, ~/.codex, $TMPDIR, Claude's
claude-501 dirs) in five contexts masked nothing before or after, so
the reporter's exact names are not reproduced.
Still masked (TestSecretsBesideLinesAndNames): password=hunter2pass9,
API_KEY=AbC123dEf456GhI789, token=t0k3nValue2, Passw0rd123, password123,
SuperSecret2024 (PascalCase stays a password), token: Lk8x9QmP2vR4,
secret.txt:hunter2pass9, x-api-key:k9x2mp4qr7st1vw3 and :ab12cd34ef56,
Password=Abc12345; in a connection string, 密钥为12231241, 私钥 ab12…,
django-insecure-…; vendorchecks and the existing code tests unchanged.
Run (mote): go vet ./internal/redact for darwin, linux, windows; go test
-count=1 ./internal/redact ./internal/masking ./internal/pii/...
./internal/otlp ./internal/sessions ./internal/settings ./internal/gateway
at base
|