Repository navigation
fix(guardrails): flag authority/educational-framing jailbreak attempts (#14483) - #14563
Merged
diegosouzapw merged 3 commits intoSep 24, 2026
Merged
Conversation
…educational_framing (#14483) Loose alternatives ("uncensored", "as a researcher", "update your behavior", "for testing purposes only") flagged ordinary traffic at the medium block threshold. The rule now needs an authority/educational framing claim AND an explicit request to drop the rules within a bounded 300-char window, in either order. Adds false-positive and ReDoS regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14483
Root cause
evaluatePromptInjection()combines the guardrail's ownDEFAULT_GUARD_PATTERNS(2 entries) with the shared
INJECTION_PATTERNS(6 entries, insrc/shared/utils/inputSanitizer.ts), but none of those 8 patterns cover the"authority / educational framing" jailbreak family. The 2026-09-21 live
promptfoo red-team run (LEDGER-12) sent the model a prompt claiming a fictional
safety/research authority ("safe educational context", "uncensored") plus an
explicit override directive ("update your behavior") and it passed straight
through with zero detections.
Note: only this sub-item (LEDGER-12) of issue #14483 is a code defect. The
other two sub-asks from the ledger are out of scope for this fix per the
main-thread audit already recorded in the plan-file: LEDGER-22 (a response-side
system-prompt-leak n-gram detector) is a missing feature, not a bug — belongs
in
/triage-features; LEDGER-23 (credential-shaped-output filter) alreadyexists and is already opt-in (
CREDENTIAL_REDACTION_ENABLED+credentialMasker.ts) — it's a documentation clarification, not a code gap.Fix
Added a new
authority_educational_framingentry toINJECTION_PATTERNSinsrc/shared/utils/inputSanitizer.tscovering the named attack phrases from theledger as one bounded, non-overlapping alternation (no unbounded/nested
quantifiers, per the project's ReDoS rule):
safe educational/research context,uncensored,update your behavior,as a researcher/as a red-teamer,for testing purposes only,controlled test scenario. Severityis
medium(nothigh) andINJECTION_GUARD_MODEstays defaultwarn(observe-only), so this cannot newly block real traffic — only an operator who
has already opted into
blockmode is affected, matching the plan-file's risknote. No PII/guardrail feature flag defaults were touched (Hard Rule #20 is not
implicated — this is a detection pattern, not a payload-mutating feature).
Regression test
tests/unit/prompt-injection-jailbreak-patterns-14483.test.ts(new file):origin/release/v3.8.51):evaluatePromptInjection()against the exact LEDGER-12 attack text asserted
decision.result.flagged === trueand failed withfalse !== true— the guard produced zero detections(
detections: []).flagged, each named attack phrase is individually flagged, and (to guard the
false-positive risk called out in the plan) ordinary coding-agent traffic
that mentions "for testing purposes" / "I'm a researcher studying..." /
"educational course" WITHOUT the override framing is not flagged.
Existing tests
Ran every existing test file touching this area — all 71 tests pass, no
assertions weakened or removed:
tests/unit/guardrails/injection-extraction.test.ts,tests/unit/guardrails/injection-route-coverage.test.ts,tests/unit/guardrails/injection-scan-window.test.ts,tests/unit/input-sanitizer-pii-redaction.test.ts,tests/unit/injection-system-prompt-leak-heuristic-4041.test.ts,tests/unit/sanitizer-residual-policy.test.ts,tests/unit/injection-guard-scan-bound-3932.test.ts,tests/unit/security-fase01.test.ts,tests/unit/guardrails/injection-extraction-tool-result.test.ts.Gates run
npm run typecheck:core→ exit 0, clean.npx eslint --suppressions-location config/quality/eslint-suppressions.json src/shared/utils/inputSanitizer.ts tests/unit/prompt-injection-jailbreak-patterns-14483.test.ts→ exit 0, clean.node scripts/check/check-file-size.mjs→ OK, no frozen file regressed.node scripts/check/check-complexity-ratchets.mjs --base-ref origin/release/v3.8.51→ OK —complexityNewCode=0,cognitiveComplexityNewCode=0(1 changed file in scope).node scripts/check/check-mutation-test-coverage.mjs --strict→ 8 missingtap.testFilesentries reported, but all 4 affected modules (accountFallback.ts,src/sse/services/auth.ts,comboStructure.ts,quotaScoring.ts) are unrelated to this diff and pre-exist on the base tip —inputSanitizer.ts/promptInjection.tsare not instryker.conf.json's mutated-module list, so this diff adds nothing to the drift.node scripts/check/check-changelog-integrity.mjs→ OK.check-docs-sync,check:any-budget:t11,check:tracked-artifacts,ai-attribution) all passed on commit.docs/andcheck:docs-countswere not touched by this diff.Remaining
None — LEDGER-12 is fully addressed by this PR. LEDGER-22 and LEDGER-23 are
intentionally out of scope (see Root cause).
Plan-file:
_tasks/pipeline/bugs/2-implementing/14483-guardrails-opt-in-injection-guard-patterns-and-response-side-l.plan.mdRework (merge-batch 2026-09-23)
Defect found in review:
authority_educational_framingmatched loose single terms (uncensored,as a researcher,update your behavior,for testing purposes only, …). WithINJECTION_GUARD_MODE=blockand the defaultmediumthreshold, ordinary prompts such as "qual o melhor modelo uncensored dolphin?" or "As a researcher, summarize this paper" would have been blocked.Fix (5e5bba4): the rule is now a co-occurrence check. It fires only when an authority/educational framing claim (
safe educational/research context,as a(n) researcher/red-teamer,for testing/research/educational purposes only,controlled test scenario) and an explicit request to drop the rules (ignore/bypass/disable/override… your guidelines/restrictions/filters/guardrails/policies,uncensored outputs/responses/mode,update your behavior,respond/proceed… without limits/filters/censorship) both appear, in either order, within a bounded 300-char lazy window ([\s\S]{0,300}?). No unbounded quantifiers, so it stays within the ReDoS rule.Tests (
tests/unit/prompt-injection-jailbreak-patterns-14483.test.ts):Validation: 82/82 focused injection/guardrail tests pass after merging
origin/release/v3.8.51(merge e8a5135).typecheck:coreshows only the known inheritedcliproxyAccountHealth.ts(157,5)error.check-file-sizeis OK. ESLint and Prettier are clean.check:open-sse-typecheckreports 2 errors inopen-sse/executors/auggie.tsthat come from the base (#14215, 10c8aaa). This PR does not touch that file.