Skip to content

fix: tier-1 defcon special-casing is a dead branch in digest_to_tbsa#1958

Open
chuenchen309 wants to merge 1 commit into
NVIDIA:mainfrom
chuenchen309:fix/tbsa-tier1-dead-branch
Open

fix: tier-1 defcon special-casing is a dead branch in digest_to_tbsa#1958
chuenchen309 wants to merge 1 commit into
NVIDIA:mainfrom
chuenchen309:fix/tbsa-tier1-dead-branch

Conversation

@chuenchen309

@chuenchen309 chuenchen309 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

digest_to_tbsa's tier-1 special-casing never actually triggers, due to two stacked dead conditions:

  1. if probe_detector in tiers[1]: compares the joined "probe:detector" key against tiers[1], which only ever contains bare probe names (built via tiers[Tier(...)].append(probename) a few lines above) — so this is never true, and every probe:detector pair falls through to else: pd_defcon = dc_scores["relative"] regardless of tier.
  2. Even after fixing that, a second dead check compounds it: isinstance(dc_scores["relative"], float) is also always False, since defcon values are always ints (1-5 scale) — so the intended min(relative, absolute) computation for tier-1 pairs would still be unreachable, silently using only absolute_defcon.

The correct pattern already exists a few lines below in this same function, in the t1_dc/t2_dc list comprehensions: pd.split(PROBE_DETECTOR_SEP)[0] in tiers[1].

Fix

Split the joined key before the tiers[1] membership check, and check isinstance(..., int) instead of float.

Verification

  • Constructed a synthetic tier-1 probe:detector pair (absolute_defcon=2, relative_defcon=5) and confirmed tbsa computed as 5 before the fix, 2 after — demonstrating the dead branch has a real, observable effect on the final score.
  • Added a regression test to tests/analyze/test_tbsa.py covering this case.
  • Ran the full tests/analyze/ suite: 142 passed.
  • garak -t <target_type> -n <model_name>not run: this is a unit-level fix and I have no live target configured; verified via the tests above rather than ticking a box I didn't exercise.
  • Supporting configuration such as a generator configuration file — n/a, no config surface changed.

I used AI assistance (Claude) to help investigate and draft this fix, but I personally constructed the repro, reviewed the root cause, and reviewed the final diff before submitting.

Signed-off-by: Andrew Chen 48723787+chuenchen309@users.noreply.github.com

`if probe_detector in tiers[1]:` compares the joined "probe+detector"
key against tiers[1], which only ever contains bare probe names (built
via `tiers[Tier(...)].append(probename)` a few lines above) -- so this
condition is never true, and every probe:detector pair falls through
to the `else: pd_defcon = dc_scores["relative"]` branch regardless of
tier. The correct pattern already exists a few lines below, in the
t1_dc/t2_dc list comprehensions: `pd.split(PROBE_DETECTOR_SEP)[0] in
tiers[1]`.

A second, stacked dead check compounds this: `isinstance(dc_scores
["relative"], float)` is also always False, since defcon values are
always ints (1-5 integer scale) -- so even after fixing the key
comparison, the intended `min(relative, absolute)` computation for
tier-1 pairs would still be unreachable, silently using only
`absolute_defcon` instead.

Fix both: split the joined key before the tiers[1] membership check,
and check `isinstance(..., int)` instead of `float`.

Verified real behavioral impact: a synthetic tier-1 pair with
absolute_defcon=2, relative_defcon=5 produces tbsa=5 (buggy, using
relative_defcon unconditionally) vs tbsa=2 (fixed, using the intended
min(5, 2)=2) -- a significant swing in this security-severity score.

Signed-off-by: Andrew Chen <48723787+chuenchen309@users.noreply.github.com>

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Andrew Chen <48723787+chuenchen309@users.noreply.github.com>
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.

2 participants