Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10056 +/- ##
==========================================
- Coverage 89.73% 89.73% -0.01%
==========================================
Files 1051 1051
Lines 92740 92717 -23
Branches 32831 32820 -11
==========================================
- Hits 83219 83195 -24
- Misses 9521 9522 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new Redteam “unicode-normalization” strategy to generate probes that normalize the injected variable using Unicode NFC/NFD/NFKC/NFKD (defaulting to NFKD), helping surface defenses or pipelines that behave differently across equivalent Unicode representations.
Changes:
- Introduces
src/redteam/strategies/unicodeNormalization.tswith form validation, normalization, and test-case rewriting (including metadata about the change). - Registers the new strategy across strategy catalogs/metadata/risk scoring/framework mapping and the Web UI probe multiplier.
- Adds targeted Vitest coverage and documentation for usage and composition with existing strategies.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/redteam/strategies/unicodeNormalization.test.ts | New unit tests covering form validation, normalization behavior, and test-case transformation/metadata. |
| test/redteam/strategies/strategyId.test.ts | Adds the new strategy ID → file mapping expectation. |
| test/redteam/strategies/index.test.ts | Extends strategy validation tests to include valid/invalid unicode-normalization forms. |
| src/redteam/strategies/unicodeNormalization.ts | Implements the strategy (form resolution, normalization wrapper, test-case rewrite + metadata). |
| src/redteam/strategies/index.ts | Registers the strategy action and validates config form during validateStrategies. |
| src/redteam/riskScoring.ts | Adds risk metadata for unicode-normalization. |
| src/redteam/constants/strategies.ts | Adds unicode-normalization to strategy catalogs/encoding strategy set. |
| src/redteam/constants/plugins.ts | Adds unicode-normalization to canary-breaking strategy exclusions. |
| src/redteam/constants/metadata.ts | Adds display name + descriptions for the strategy in UI metadata. |
| src/redteam/constants/frameworks.ts | Adds unicode-normalization to the OWASP LLM red team mapping. |
| src/app/src/pages/redteam/setup/components/strategies/utils.ts | Adds probe multiplier entry for unicode-normalization in the setup UI. |
| site/static/config-schema.json | Updates generated schema enum/documentation to include unicode-normalization. |
| site/docs/red-team/strategies/unicode-normalization.md | New docs page describing semantics, configuration, and composition with homoglyph/layer. |
| site/docs/_shared/data/strategies.ts | Adds the strategy to the docs strategy catalog data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cfcc98a to
2183ebc
Compare
2183ebc to
2eaeb26
Compare
mldangelo-oai
left a comment
There was a problem hiding this comment.
Release audit on c895fdd: reviewed the Unicode-normalization strategy, schema/UI wiring, and affected tests; focused backend/UI suites pass (125 tests) and CI is green. No release-blocking findings.
…anged The unicode-normalization strategy is a no-op on ASCII payloads, so an all-ASCII batch emits probes that are byte-identical to the baseline. This is documented and intentional, but it silently doubles scan cost and labels duplicate probes as a "Unicode Normalization attack" in the report. Emit a single logger.warn when every test case in a batch comes back unchanged, naming the count and the normalization form. Purely additive: the returned test cases, metadata, and metric names are unchanged.
…ation warning
The warning added in the previous commit broke two CI gates:
- test/test-hygiene.test.ts rejected the new logger mock: a module-scope
persistent setter (`getLogLevel: vi.fn().mockReturnValue('info')`) must be
paired with a reset in beforeEach to survive random test order. The test
never reads getLogLevel, so drop the return value and reset logger.warn
explicitly, per the mock-isolation rule in test/AGENTS.md.
- The `logger` import widened redteam -> legacy-runtime from 142 to 143,
tripping the architecture baseline ratchet. Importing logger into a strategy
is the established pattern (18 sibling strategies in src/redteam/strategies/
already do it), so regenerate the baseline as the check instructs. The diff
also locks in a pre-existing redteam -> node reduction (211 -> 210).
GitHub did not dispatch any workflow runs for 0b72726 (0 check runs, no pending approval). All gates verified locally on that commit: test-hygiene 88 passed, architecture:check passed, redteam suite 140 files / 2557 tests passed, biome clean.
mldangelo
left a comment
There was a problem hiding this comment.
Thanks for this — a clean, well-integrated strategy addition.
Heads-up: I pushed three commits to your branch
So you aren't surprised by commits you didn't write, I pushed to feat/unicode-normalization:
d2ba7f4— alogger.warninaddUnicodeNormalizationwhen every case in a batch comes backnormalizationChanged: false, plus 4 tests0b72726— test hygiene +architecture/edge-baseline.jsonregen for the newloggerimport377c0a9— empty commit to retrigger CI
Purely additive: same returned array, same metadata, same metric names. Your records when normalization leaves an ASCII-only prompt unchanged test still passes, and npx vitest run test/redteam is 140 files / 2557 tests green. Revert it freely if you'd rather solve the underlying issue differently.
What works well
- The tests are load-bearing, not decorative. Replacing
return text.normalize(form)withreturn textfails 7 tests acrossunicodeNormalization.test.tsandindex.test.ts. resolveUnicodeNormalizationFormthrowing on an invalid form instead of silently defaulting is the right call.- Integration is genuinely complete — constants, registry, riskScoring metadata, canary exclusions, UI dialog, sidebar — and the docs page honestly calls out the homoglyph ordering interaction rather than glossing over it.
1. Is the ASCII no-op the behavior you want? (P2 — design question)
The docs say "ASCII-only prompts usually remain unchanged" and a test pins it, so I read this as deliberate. I mainly want to check you've seen the downstream cost. Measured through the real CLI (intent plugin, strategies: [basic, unicode-normalization]):
redteam generate -> Total tests: 6 | Plugin tests: 3
basic -> 3 probes | unicode-normalization -> 3 probes
uni[0..2] byte-identical to a basic probe: true (normalizationChanged: false)
eval --no-cache -> 6 provider calls issued for 3 distinct probes
All four forms are exact identity on ASCII (5/5 realistic payloads x 4/4 forms). Two consequences worth your call:
getStrategyIdFromTest(src/app/src/pages/redteam/report/components/shared.ts:25) readsmetadata.strategyIdverbatim, so a plain baseline failure is reported as a successful "Unicode Normalization" attack that performed no transformation.normalizationChangedhas zero production consumers — nothing filters, warns, or annotates on it, andapplyStrategiespushes every returned case with no dedupe.
Would you consider returning undefined for unchanged cases in unicodeNormalization.ts:51? applyStrategies already filters null/undefined, so it's framework-native. It does contradict your existing test, which is why I'm asking rather than pushing it.
2. src/redteam/constants/frameworks.ts:343 — OWASP preset addition (P2)
This takes owasp:llm:redteam:implementation from 11 to 12 strategies (+9.1%) for everyone already using that preset. 9 of its 10 plugins emit English ASCII prose; the tenth, ascii-smuggling, relies on tag-block / zero-width / variation-selector characters, all of which I verified survive NFKD unchanged. Deleting the line and running npx vitest run test/redteam gives 140 files / 2553 tests green — no test asserts the preset's contents, so this is completely unguarded either way. Worth dropping from this PR (users can still opt in explicitly), or landing it once #1 is settled. If it stays, an assertion on the preset list would be good.
3. site/docs/red-team/plugins/coding-agent.md:158 (P3 — quick fix)
You added unicode-normalization to CANARY_BREAKING_STRATEGY_IDS, but that line hardcodes the exclusion list as prose and now omits it. A user pairing coding-agent:* with this strategy will read that page, expect it to run, and have it silently dropped at src/redteam/plugins/index.ts:156.
Nits (take or leave)
src/redteam/strategies/types.ts:3— the addedexport type { TestCase };exists only sounicodeNormalization.ts:7can import from./types. Every sibling strategy (homoglyph.ts:1,rot13.ts:1,base64.ts:1, ~20 more) imports it from../../types/index; matching them revertstypes.tsto untouched.unicodeNormalization.ts:9-14— the re-exports ofDEFAULT_UNICODE_NORMALIZATION_FORM/UNICODE_NORMALIZATION_FORMS/UnicodeNormalizationFormhave no consumers outside the new test file (the UI imports them from@promptfoo/redteam/constants/strategiesdirectly). AGENTS.md asks for direct imports over re-exports, and Knip may flag these.- The
typeof x === 'string' && UNICODE_NORMALIZATION_FORMS.includes(...)predicate is duplicated inresolveUnicodeNormalizationFormandStrategyConfigDialog.tsx:56-59, costing threeas UnicodeNormalizationFormcasts. AnisUnicodeNormalizationFormtype guard beside the constants would narrow and delete all three — same pattern asisMultiTurnStrategy(constants/strategies.ts:32) andisFanoutStrategy(:194).
Nothing here blocks on my end once #1 and #2 have your answer.
Resolves a conflict in architecture/edge-baseline.json: main regenerated the baseline while this branch had also regenerated it for the strategy's logger import. Resolved by regenerating from the merged tree rather than taking either side, so the file reflects the actual merged import graph. Net delta versus main is the single expected edge: redteam -> legacy-runtime: 142 -> 143 `npm run architecture:check` passes. The PR was in a DIRTY merge state, which is why GitHub stopped dispatching pull_request workflows for the last two commits.
|
Thanks for the detailed review, @mldangelo, and for the commits you added to the branch. I compared every item against the current implementation and synced the branch with the latest
I intentionally kept the local Fresh validation on current head
All actionable review items appear addressed. When convenient, could you take another look at the updated head and let us know if anything remains? |
|
Hi @mldangelo — just following up when you have a chance. We addressed the review items on the current head 0a35e9d, and all checks are green. Is there anything else you would like changed before this is ready to merge? No rush, and thanks for taking another look. |
|
Hi @mldangelo — following up once more since the approval a couple of weeks back. Happy to rebase onto current main or adjust anything else if that would help get this over the line. |
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
👍 All Clear
Reviewed the Unicode Normalization strategy additions and related changes across strategy composition, validation, server routing, and UI. These updates focus on pre-LLM test-case transformation, validation, and user feedback. No new tool access, execution sinks, or LLM prompt flows were introduced by this PR.
Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more
# Conflicts: # architecture/edge-baseline.json # site/static/config-schema.json # src/redteam/riskScoring.ts # src/redteam/strategies/index.ts # src/types/api/redteam.ts
There was a problem hiding this comment.
👍 All Clear
Reviewed the PR adding the Unicode Normalization red-team strategy, related UI/config wiring, validation, and server handling for no-op cases. I traced inputs from the redteam generation API through strategy selection/execution and output reporting. No LLM security-relevant changes were found that introduce prompt injection risks, data exfiltration paths, insecure output handling, excessive agency, or jailbreak-only controls.
Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more
There was a problem hiding this comment.
👍 All Clear
Reviewed the PR adding a Unicode Normalization red-team strategy, related UI, validation, and server handling. The changes focus on preprocessing test cases, configuration validation, and returning empty batches when normalization is a no-op. No direct LLM call sites or privileged tool integrations are modified in this diff, and no exploitable LLM security issues were identified.
Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more
There was a problem hiding this comment.
👍 All Clear
Reviewed the Unicode Normalization strategy addition and related pipeline, validation, and server/UI handling. The changes add deterministic prompt transformations, strict config validation (including nested layers), and safer no-op handling without expanding agent capabilities. No LLM security vulnerabilities were identified in this PR.
Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more
Summary
unicode-normalizationred-team strategy with NFC, NFD, NFKC, and NFKD support, defaulting to NFKDDesign notes
Unicode normalization and homoglyph substitution remain separate strategies. Promptfoo already maintains the
homoglyphstrategy and substitution table, so users can compose the two with Layer when they need both behaviors.The implementation uses the runtime's standards-compliant
String.prototype.normalize()behavior and validates the requested form before generation. Changed probes retain assertions and existing metadata while recording the original text and applied normalization form. Assertions without a metric name remain unchanged.No-op behavior is deliberate: standalone unchanged probes are filtered to avoid duplicate provider calls and false strategy attribution. Within a Layer pipeline, unchanged values continue to later transforms; a fully unchanged Unicode-only pipeline is reported as skipped. At runtime, unchanged per-turn prompts pass through so an agentic conversation is not interrupted.
The Web UI and backend share the same normalization-form constants and default. Existing configurations remain backward compatible because an omitted form still resolves to NFKD.
Validation
git diff --check, architecture boundaries, and Knip passedFixes #10039