fix(ENG-3500): Tier-3 hardening found while porting to Python
Merged
HI
1mo ago+104+104+012345678901234567890123456789-5-5-0123456789
What
Reviews of the Python port (StackOneHQ/defender-py#38: an adversarial review plus cubic) found four gaps that TS 0.9.2 also has. Python #38 already fixes them; this PR brings TS level and pins them in the shared fixtures.
| Gap | Before | After |
|---|---|---|
URL password with @ | connect https://user:p@ss@host.example.com/x was reported as https://ss@host.example.com, leaking part of the password | https://host.example.com: userinfo runs to the last @, and the host can't contain one |
| Bearer in a dict repr | {'Authorization': 'Bearer abc…', 'X-Api-Key': 'zzzz…'} leaked zzzz…: the Bearer rule ate the closing quote, so the next pair didn't match | Both values become [redacted] (the Bearer value stops at a quote or comma) |
refused: true without a valid decision | Counted as a provider failure: in tier3_only the default onError fails open, so it was allowed | Blocks, like any refusal |
buildTier3Messages with a bad template | A direct call with a template missing {{content}} rendered a prompt without the tool output | Throws, the same check createLlmTier3Provider does |
Also: the marker-id spec now checks 6 markers and 3 distinct ids on both renders, not just the first. This was a cubic finding on defender-py#34.
Fixtures
New cases, with outputs recorded by pnpm conformance:update. The diff only adds cases:
tier3-redact/url-password-with-attier3-redact/dict-repr-bearer-then-keytier3-policy/t3only-refused-without-decision-blocks
Release
fix: → 0.9.3 (patch). After it ships, defender-py re-pins to defender-v0.9.3, and its runner picks up the three new cases.
Checks
pnpm test: 707 passtest:typecheck,examples:typecheckand the build pass- Lint shows only the pre-existing warning
🤖 Generated with Claude Code
Summary by cubic
Fixes five Tier-3 hardening gaps that the Python port review found and that TS 0.9.2 shares, with new conformance fixtures.
- URL redaction keeps only the host: userinfo runs to the last
@, so a password containing@no longer leaks into the reported host. - The Bearer/Basic rule redacts a quoted value whole (escaped quotes included) and runs an unquoted value to whitespace or comma, so braces, brackets and parens no longer truncate it and the next secret in a dict repr stays redactable.
- A provider verdict with
refused: truebut no validdecisionnow blocks instead of failing open. buildTier3Messagesvalidates the template itself, so a direct call with a template missing{{content}}throws.- The marker-id spec now checks the six-marker, three-id shape on both renders, not just the first.