Skip to content

Close the four defects #390 left on main (closes #438) - #449

Merged
patelankeet2 merged 2 commits into
mainfrom
fix/438-subject-key-set-defects
Nov 19, 2026
Merged

patelankeet2 merged 2 commits into
mainfrom
fix/438-subject-key-set-defects

Conversation

@shubhamkataria2005

Copy link
Copy Markdown
Collaborator

Closes #438. Thanks @ARSH871-bot for writing these up after #390 merged with your review still in draft.

defect fix
D2 _canonical_address stored fe80::1%ignore all previous instructions verbatim (reproduced: 'fe80::1%ignore all previous instructions/128') anything with a % is refused, so an ordinary zone like %eth0 is refused too. A zone names an interface on one machine and means nothing across findings. 6 tests, both address keys
D1 the unknown-key check had no test of its own pinned with match="unknown key", including your {"dest": "tcp"} and a valid key alongside a bad one
D3 the note said "one of four" beside a table showing two the note doesn't count any more; the table is the record. It now records that #390 merged with two rows empty, rather than smoothing it over
D4 A-3's own signature table sat under the key-set heading it has its own heading, "Signatures for A-3", above the key-set section, and each says what it covers

One deviation from #438's wording, and why. You asked for elif key == "protocol": with else: raise. Done. But keeping the up-front check as well left neither load-bearing: deleting the up-front check survived every test. That's the double-guard risk.py's _escalate docstring warns about, so the loop's else is now the one place an unknown key is refused. Mutants: removing that branch fails 4, removing the zone-ID guard fails 6. The only behaviour difference is that a subject with two unknown keys names the first one, not both. If you'd rather keep both checks, say so and I'll put it back.

2249 passed, 13 skipped on current main, ruff clean on CI's selection.

Rows: @ARSH871-bot, you said you'd tick yours in the PR that fixes D2, and this is it. @SamikaPerera, yours is the last one. A ✅ on this branch (or a yes here and I'll add it) closes the key set properly.

D2: refuse an IPv6 zone ID in a subject address. Python accepts anything
after a '%' as a scope, so 'fe80::1%ignore all previous instructions' was
stored verbatim in a field bound for the model's prompt.

D1: an unknown key is refused in one place, the per-key loop's last
branch, and pinned by message. The up-front copy is gone: with both, either
could be deleted with every test green.

D3: the status note no longer repeats the table's count, and records that
#390 merged with two rows empty. D4: A-3's own signature table has its own
heading, above the key-set section it was sitting under.

@patelankeet2 patelankeet2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested in an isolated worktree at the branch's head (9b2fa98).

D2: confirmed the underlying claim first, live, before trusting the fix -- ipaddress.ip_network("fe80::1%ignore all previous instructions/128", strict=True) genuinely accepts the zone ID verbatim on this machine's Python, so the vulnerability is real, not theoretical. The fix intercepts it with a plain "%" in str(value) check before the address ever reaches ip_network().

D1: read the full _validate_subject() loop, not just the diff hunk -- src/dst to address validation, srcPort/dstPort to port validation, protocol to protocol validation, everything else to the new else: raise, covering all five SUBJECT_KEYS with one decision point.

Mutation-tested both guards independently rather than trusting the PR's own numbers blindly, though they came out identical: removing the unknown-key else branch fails 4, removing the zone-ID check fails 6, matching exactly.

D3/D4: the reordering (signatures before the key-set table) and the note rewrite both check out. The old note duplicated a count ("one of four") that the table itself already showed as two -- removing the duplicated fact instead of just correcting the number is the more durable fix, since there's nothing left to drift out of sync next time a row changes. The honest "#390 merged with two rows still empty" statement is left visible rather than smoothed over, consistent with how this project already treats A-2's own history.

Full suite: 2249 passed, 13 skipped, 0 failed, matching the PR body. ruff clean on both changed files.

My own row in the key-set table is unchanged and still accurate, no re-signing needed. Approving.

@SamikaPerera SamikaPerera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 9b2fa98. I checked it on a merge with main (d424e05).

D1: the loop has elif key == "protocol": and a final else that raises. test_an_unknown_key_is_refused_as_an_unknown_key uses match="unknown key" with {"dest": "tcp"}.
D2: _canonical_address refuses any value containing %. test_an_ipv6_zone_id_is_refused_not_stored covers 3 values on src and dst.
D3: the status note no longer repeats the count.
D4: the A-3 signature table has its own heading and the key-set section follows it.

SUBJECT_KEYS (analysis/findings.py:133) and the table's five rows agree.

test_finding_subject.py: 51 passed. Full suite merged with main: 2268 passed, 13 skipped. ruff clean. Mutations: removing the % check fails 6 tests; making the final else not raise fails 4.

On the table: I agree with the key set, and with the added "no IPv6 zone ID (%)" on src. My row is still empty. @shubhamkataria2005, do you want me to tick it with a commit on your branch (as Ankeet did on #390), or in a separate one-row PR after this merges (as I did with A-4 in #381)? I would rather not push to your branch without asking, because a push voids the two approvals.

Not checked: Python 3.12 and 3.13 separately (CI).

@shubhamkataria2005

Copy link
Copy Markdown
Collaborator Author

@SamikaPerera, thank you for asking first. Please tick it on this branch. This PR exists because #390 merged with the table incomplete, so merging it before the table is full would repeat the exact thing it fixes. A one-row docs commit voiding two approvals is a small price for that.

@ARSH871-bot, you said you'd tick your row on the PR that fixes D2, and this is it. If you both push your rows, I'll ask for one quick re-approval of the docs-only change and merge once the table reads four of four.

@patelankeet2 patelankeet2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed with real testing (both my own and Samika's approvals had gone stale after a follow-up commit).

Mutation-tested both real guards in analysis/findings.py directly:

  • Disabled the IPv6 zone-ID check -- all 6 parametrized test_an_ipv6_zone_id_is_refused_not_stored cases failed, reproducing D2 exactly.
  • Restored the pre-fix shape (protocol as the bare else, unknown-key check removed): _validate_subject({"dest": "tcp"}) is then silently accepted rather than refused, because "tcp" happens to parse as a valid protocol value -- the exact D1 bug this PR closes, one decision point instead of two untested copies. All 3 parametrized test_an_unknown_key_is_refused_as_an_unknown_key cases failed, including this one. Reverted both mutations after confirming.

Checked the key-set table state after the merge (docs/finding-format.md) rather than assuming: Arsh's row is still correctly ⬜, Samika's is ✅ with the added zone-ID rule noted, consistent with what the diff claims -- not yet fully ratified, honestly stated as such.

Full suite with Batfish running: 2503 passed, 13 skipped, 0 failed.

Approving.

@patelankeet2
patelankeet2 merged commit 78ba646 into main Nov 19, 2026
2 checks passed
@patelankeet2
patelankeet2 deleted the fix/438-subject-key-set-defects branch November 19, 2026 02:03
@shubhamkataria2005

Copy link
Copy Markdown
Collaborator Author

@ARSH871-bot, one thing this PR left open. Your row is the only unticked one in the A-3 key-set table on main (docs/finding-format.md, around line 436):

Shubham ✅   Arsh ⬜   Ankeet ✅   Samika ✅

You agreed to this on #390: "My answer on the key set: yes to a closed set. I'll tick my row in the PR that fixes D2." That PR was this one, and it merged before your tick went in. Could you open a one-row PR that ticks it? I won't tick it for you, because the table only means something if each row is signed by its own person. Until your row is ticked, the key set is three of four, not ratified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Finding subject (A-3 key set): close D1-D4 and finish the ratification

3 participants