Skip to content

fix: cron prompt injection scanner bypass for multi-word variants#63

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/cron-prompt-injection-bypass
Feb 27, 2026
Merged

fix: cron prompt injection scanner bypass for multi-word variants#63
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/cron-prompt-injection-bypass

Conversation

@0xbyt4
Copy link
Copy Markdown
Contributor

@0xbyt4 0xbyt4 commented Feb 26, 2026

Summary

  • Fix prompt injection bypass in _scan_cron_prompt regex
  • Add 8 regression tests for multi-word injection variants

Bug

The regex ignore\s+(previous|all|above|prior)\s+instructions only matches when there is exactly one keyword between "ignore" and "instructions". Multi-word variants bypass the scanner:

Input Expected Actual (before fix)
ignore previous instructions Blocked Blocked
Ignore ALL prior instructions Blocked Not blocked
ignore all previous instructions Blocked Not blocked
ignore the above instructions Blocked Not blocked

Root cause: The alternation (previous|all|above|prior) consumes "ALL", then \s+instructions tries to match "prior" and fails.

Fix

Allow optional extra words before and after the keyword alternation:

- (r'ignore\s+(previous|all|above|prior)\s+instructions', "prompt_injection"),
+ (r'ignore\s+(?:\w+\s+)*(?:previous|all|above|prior)\s+(?:\w+\s+)*instructions', "prompt_injection"),

Test plan

  • 8 regression tests pass (multi-word variants, case insensitive, false positive checks)
  • All existing cron tests still pass
  • Full suite: 299 passed, 0 failed
The regex `ignore\s+(previous|all|above|prior)\s+instructions` only
allowed ONE word between "ignore" and "instructions". Multi-word
variants like "Ignore ALL prior instructions" bypassed the scanner
because "ALL" matched the alternation but then `\s+instructions`
failed to match "prior".

Fix: use `(?:\w+\s+)*` groups to allow optional extra words before
and after the keyword alternation.
@teknium1 teknium1 merged commit 1522718 into NousResearch:main Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants