Skip to content

FIX: Make the DenylistConverter pre-flight check case-insensitive - #4080

Closed
电大老baby (HhH666-ux) wants to merge 1 commit into
microsoft:mainfrom
HhH666-ux:fix-denylist-case-insensitive-preflight
Closed

电大老baby (HhH666-ux) wants to merge 1 commit into
microsoft:mainfrom
HhH666-ux:fix-denylist-case-insensitive-preflight

Conversation

@HhH666-ux

Copy link
Copy Markdown

Description

DenylistConverter.convert_async short-circuited with a case-sensitive substring check, so a prompt containing a case-mismatched denylisted term (e.g. Molotov cocktail against molotov cocktail) was returned unchanged without ever calling the converter target. The system prompt template documents case-insensitive matching.

  • Compare denylist terms and the prompt case-insensitively in the pre-flight check.
  • Add a regression test covering a case-mismatched phrase.

Fixes #4061

Copilot AI balanced review requested due to automatic review settings November 9, 2026 03:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The lower()-based pre-flight check misses valid Unicode denylist matches, such as Greek sigma, returning the prompt unchanged without calling the target.

1 open issue
What changed in this PR

This PR addresses #4061 by making DenylistConverter’s pre-flight check case-insensitive, aligning it with the converter’s system prompt instructions.

Changes:

  • Lowercase denylist terms and prompts before checking for matches.
  • Add a regression test confirming that a case-mismatched phrase reaches the converter target.
File Description
tests/​unit/​converter/​test_denylist_converter.py Adds coverage for a case-mismatched denylisted phrase.
pyrit/​converter/​denylist_converter.py Updates the pre-flight substring check to ignore casing.

Review effort: Balanced

# update the prompt replacing the denied words with synonyms
denylist = self._prompt_kwargs.get("denylist", [])
if any(word in prompt for word in denylist):
if any(word.lower() in prompt.lower() for word in denylist):
@romanlutz

Copy link
Copy Markdown
Contributor

Thanks for the contribution. I'm closing this because #4062 is the earlier active implementation for #4061 and covers the same fix.

Please claim an issue and wait for ownership confirmation before starting work so maintainers can coordinate ownership and avoid duplicated effort.

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.

BUG: DenylistConverter pre-flight check is strictly case-sensitive, dropping case-mismatched terms

3 participants