fix(ENG-3500): Tier-3 hardening found while porting to Python

Merged
HI
1mo ago
+104-5

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.

GapBeforeAfter
URL password with @connect https://user:p@ss@host.example.com/x was reported as https://ss@host.example.com, leaking part of the passwordhttps://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 matchBoth values become [redacted] (the Bearer value stops at a quote or comma)
refused: true without a valid decisionCounted as a provider failure: in tier3_only the default onError fails open, so it was allowedBlocks, like any refusal
buildTier3Messages with a bad templateA direct call with a template missing {{content}} rendered a prompt without the tool outputThrows, 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-at
  • tier3-redact/dict-repr-bearer-then-key
  • tier3-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 pass
  • test:typecheck, examples:typecheck and 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: true but no valid decision now blocks instead of failing open.
  • buildTier3Messages validates 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.