Repository navigation
feat(secrets): mask unknown secret shapes with the shared uteke-privacy detector - #909
Merged
Merged
Conversation
…cy detector (#597) SecretSet::redact and redact_value now run the uteke-privacy shape ruleset after the known-value pass, at every sink the set covers (provider request, session log, live events, MCP arguments, web, memory loop), masking as prefix[REDACTED:<kind>]. It runs for an empty set too and keeps the known-value marker. A redaction_allowlist (user config only) keeps false positives.
…rd shape kinds (#597) Review fixes: a known-value marker is swapped for an ASCII stand-in while the detector runs and kept only where it is the whole secret position, so text carrying a marker cannot hide a secret next to it. JSON object fields are masked by their field name. Log entries list shape:<kind> in redacted. web_fetch refusals name secret shapes and redaction_allowlist. A project redaction_allowlist is ignored with a warning. Migration and changelog entries added.
) The marker stand-in is letters and digits only (qzk..k<i>x), with a run of k one longer than any in the text, so it cannot occur in the input, keeps PEM and token shapes intact, and is never skipped because of control bytes. Docs: second pass can only mask more, redacted field documents shape kinds, threat model lists literal guillemets as non-ASCII neighbours.
…ne pass (#597) The set's exact marker strings are swapped for the stand-in, so a name with other characters no longer leaves a non-ASCII marker that hides a glued secret. Restore is a single pass with bounds-checked indexes instead of one replace per marker. Threat model lists the word-character, keyword and lone-guillemet residuals.
The longest-first marker order is built once in the set instead of per call. A test pins that the longest known marker wins. Threat model names the vendor-token adjacency cases.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Mask secrets tole never knew (pasted by the owner, printed by a command) with the ruleset shared with uteke,
uteke-privacy0.24.1, at every sinkSecretSetalready covers. The mask isprefix[REDACTED:<kind>].Why
Closes #597 (epic #594). Owner decision of 2026-11-11: one shape detector shared with uteke, wired into
SecretSetafter known-value redaction at the same sinks, false positives through an allowlist. The blocker codecoradev/uteke#1732 is closed anduteke-privacy0.24.1 is on crates.io (Apache-2.0, depends onregexonly, no IO).Changes
crates/tole-core/src/secrets/shape.rs: wrapsuteke_privacy::redact, withset_allowlist,check_allowlist,redact_shapesandmasked_kinds.secrets/mod.rsruns it after the known-value pass inredactandredact_value. Every sink that goes through the set is covered: provider request, session log and pinned system prompt, live observer events, MCP arguments, web query and URL, systemone, router, advisor, memory loop, uteke documents, discussion sanitize, sandbox argv, and the tole-cli sinks.SecretSet::redactandredact_valueon an EMPTY set are no longer a no-op.{"api_key": "<random>"}).web_fetchURL that looks like a secret is refused, like one holding a known value (new wording that namesredaction_allowlist).shape:<kind>in itsredactedfield (no new wire field; old logs replay unchanged).redaction_allowlist(regexes), user layer only. A project config's value is ignored with a warning.scan_secretsandplugin_scanuse the known-value pass only (redact_known).[REDACTED:basic-auth].«NAME»marker, whatever characters its name holds, is swapped for a letters-and-digits stand-inqzk..k<i>xwhile the detector runs. The run ofkis longer than any in the text, so the prefix cannot occur in the input, and restore is one bounds-checked pass that only touches stand-ins this call created. Markers are kept only where they are the whole secret position (anchored allow patterns), so text that carries a marker cannot hide a secret next to it.uteke-privacy0.24.1 andregex1.13.1 (plus aho-corasick, memchr, regex-automata, regex-syntax): 6 new Cargo.lock packages. Release binary size delta not measured.Testing
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --no-fail-fast(2766 passed, 0 failed),cargo check -p tole-core --no-default-features --tests, andcora review --staged --no-llm(no issues).shape:<kind>, control bytes, stand-in look-alikes, PEM, unusual names, 50,000-marker restore, longest marker wins), tests/shape_allowlist.rs, and a config test.redact_payload; unanchored marker allow; swap skipped on control bytes; non-alphanumeric stand-in; fixed prefix with no collision avoidance; known names not swapped; longest-first sort dropped.cora callers redactlists about 50 callers, mostly inprovider/openai.rs,turn/mod.rs,web.rs,children/memory.rs,session/storage.rs,discussion,advisor,plugin_lock,sandbox/reportand tole-clidiscuss/delegation. Callers that compare redact output to the input (web.rs,web_builtin.rs) were verified by grep.cora affectedlisted about 99 test files; the tests to rerun are the full workspace, which passed.scripts/review-local.shwas not run (no LLM key);cora review --staged --no-llmwas clean.cargo audit.