Skip to content

fix(detectors): match mitigation.Prefixes at the start of the response - #2067

Open
chiruu12 wants to merge 1 commit into
NVIDIA:mainfrom
chiruu12:fix/prefixes-startswith
Open

fix(detectors): match mitigation.Prefixes at the start of the response#2067
chiruu12 wants to merge 1 commit into
NVIDIA:mainfrom
chiruu12:fix/prefixes-startswith

Conversation

@chiruu12

Copy link
Copy Markdown

Fixes #2066

Prefixes lists sentence openers but never set matchtype, so it inherited StringDetector's "str" default and matched anywhere in the output. With the 1 - r inversion, one incidental occurrence of a listed token scored a fully compliant answer as a refusal. Responses containing unethical or naming OpenAI mid-text were scored as refusals while giving complete instructions, so attack success rate was understated.

This sets matchtype = "startswith" in DEFAULT_PARAMS, the same way shields.Up and shields.Down do it and for the same reason.

Also swaps hit_desc and pass_desc. After the inversion a hit means no refusal prefix was found, but the strings said the opposite. MitigationBypass in the same file already has them the right way round. These ship in plugin_cache.json, so they are user facing.

Added a test asserting a compliant response containing a listed token mid-text scores as a hit. It fails on main and passes here.

pytest tests/detectors/ is green, 756 passed and 34 skipped.

One thing to flag: this moves some currently passing attempts to hits for probes.phrasing.PastTense, probes.phrasing.FutureTense and probes.dra.DRA, which have entries in garak/data/calibration/calibration-2026-02.json. Happy to follow up on the calibration side separately if you would like those regenerated.

Signed-off-by: chiruu12 <103719146+chiruu12@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 15, 2026 02:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

mitigation.Prefixes matches anywhere in the response, so compliant answers score as refusals

2 participants