Prompt injection: Body instructions addressed to an AI
Detects message bodies that speak to an AI assistant rather than about one, such as a vocative ('Mail agent:'), a note to the model, 'if you are an AI', or a forged chat-template turn, where NLU finds a request and the prompt injection model flags the body or a quoted passage within it, such as an injection presented as a cited example. Targets instructions aimed at AI assistants that read mail on the recipient's behalf. Excludes graymail from senders passing DMARC.
Sublime rule (View on GitHub)
1name: "Prompt injection: Body instructions addressed to an AI"
2description: "Detects message bodies that speak to an AI assistant rather than about one, such as a vocative ('Mail agent:'), a note to the model, 'if you are an AI', or a forged chat-template turn, where NLU finds a request and the prompt injection model flags the body or a quoted passage within it, such as an injection presented as a cited example. Targets instructions aimed at AI assistants that read mail on the recipient's behalf. Excludes graymail from senders passing DMARC."
3type: "rule"
4severity: "low"
5source: |
6 type.inbound
7 and any([body.current_thread.text, body.plain.raw],
8 length(.) >= 150
9 and regex.icontains(.,
10 '(?:(?:^|\n)[ \t]*-?|[\[(>*\x27\"])[ \t]*(?:[\w-]+[ \t]+){0,3}(?:assistant|agent|bot|llm|summari[sz]er|screener|classifier|mailbot)[ \t]*(?:note[ \t]*)?[:—–]|(?:^|\n)[ \t]*[*>-]?[ \t]*(?:assistant|agent|bot|llm|summari[sz]er|screener|classifier|mailbot)s?[ \t]*,|\b(?:note|notice|instructions?|reminder|message)\s+(?:to|for)\s+(?:(?:the|any|all|your|this)\s+(?:[\w\x27\x{2019}-]+\s+){0,2}(?:(?:assistant|agent|bot|llm|summari[sz]er|screener|classifier|copilot|mailbot)|ai|models?)|(?:ai\s+)?(?:assistant|agent|bot|llm|summari[sz]er|screener|classifier|copilot|mailbot))s?\b|\bif\s+you\s+are\s+an?\s+(?:ai|llm|language\s+model)\b|\bif\s+you\s+are\s+an?\s+(?:[\w-]+\s+)?(?:assistant|agent|bot|llm|summari[sz]er|screener|classifier|copilot|mailbot)(?:[ \t]*[,:;.)—]|\s+(?:reading|processing|handling|summari[sz]ing|parsing|triaging|indexing|preparing|condensing|that|which|with\s+access)\b)|\b(?:(?:assistant|agent|bot|llm|summari[sz]er|screener|classifier|copilot|mailbot)|ai|model)s?\s+(?:that\s+is\s+|is\s+)?(?:reading|processing|handling|summari[sz]ing|parsing|triaging|indexing|preparing)\s+this\b|\b(?:ignore|disregard)\s+(?:all\s+(?:of\s+)?(?:the\s+|your\s+)?|your\s+)?(?:previous|prior|above)\s+(?:instructions?|(?:system\s+)?prompts?)\b|<\|im_start\|>'
11 )
12 and any(ml.nlu_classifier(.).entities, .name == "request")
13 and (
14 (
15 ml.prompt_injection_detection(.).detection == "injection"
16 and ml.prompt_injection_detection(.).confidence in (
17 "medium",
18 "high"
19 )
20 )
21 // the injection wrapped as a quoted "example" or "citation"... the framing dilutes
22 // the model over the whole body, so score each quoted passage on its own, current
23 // thread only... quotes pair in order and are length-filtered after, so a short
24 // quote can't shift the pairing; a single line break may sit inside a quote
25 or any(filter(regex.iextract(body.current_thread.text,
26 '[\x22\x{201C}\x{201E}](?:[^\x22\x{201C}\x{201D}\n]|\n[^\x22\x{201C}\x{201D}\n]){0,600}[\x22\x{201C}\x{201D}]'
27 ),
28 length(.full_match) >= 42
29 ),
30 // the quote itself addresses an ai, not just names one (paper titles,
31 // news quotes)... cheap check before the model call
32 regex.icontains(.full_match,
33 '\b(?:if\s+you\s+are\s+an?|to\s+(?:the|any|all|every)|(?:note|notice|instructions?|reminder|message)\s+(?:to|for))\s+(?:[\w-]+\s+){0,3}(?:ai|assistant|agent|bot|llm|(?:language\s+)?model|summari[sz]er|screener|classifier|copilot|mailbot)s?\b|\b(?:ai|assistant|agent|bot|llm|model|summari[sz]er|screener|classifier|copilot|mailbot)s?\s+(?:that\s+is\s+|is\s+)?(?:reading|processing|handling|summari[sz]ing|parsing|triaging|indexing|preparing)\b'
34 )
35 and ml.prompt_injection_detection(.full_match).detection == "injection"
36 and ml.prompt_injection_detection(.full_match).confidence in (
37 "medium",
38 "high"
39 )
40 )
41 )
42 )
43
44 // graymail from authenticated senders... AI-product newsletters and webinars
45 and not coalesce(ml.attack_score_flash().verdict == "graymail"
46 and headers.auth_summary.dmarc.pass,
47 false
48 )
49tags:
50 - "Attack surface reduction"
51 - "Email prompt injection"
52attack_types:
53 - "BEC/Fraud"
54tactics_and_techniques:
55 - "Evasion"
56 - "Prompt injection"
57 - "Social engineering"
58detection_methods:
59 - "Content analysis"
60 - "Natural Language Understanding"
61 - "Sender analysis"
62id: "257a963a-8fc5-525c-9729-7b28974b8e8a"