Sublime Security low experimental mql

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.

View Source

Detection Logic

type.inbound
and any([body.current_thread.text, body.plain.raw],
        length(.) >= 150
        and regex.icontains(.,
                            '(?:(?:^
| \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\
| >'
        )
        and any(ml.nlu_classifier(.).entities, .name == "request")
        and (
          (
            ml.prompt_injection_detection(.).detection == "injection"
            and ml.prompt_injection_detection(.).confidence in (
              "medium",
              "high"
            )
          )
          // the injection wrapped as a quoted "example" or "citation"... the framing dilutes
          // the model over the whole body, so score each quoted passage on its own, current
          // thread only... quotes pair in order and are length-filtered after, so a short
          // quote can't shift the pairing; a single line break may sit inside a quote
          or any(filter(regex.iextract(body.current_thread.text,
                                       '[\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}]'
                        ),
                        length(.full_match) >= 42
                 ),
                 // the quote itself addresses an ai, not just names one (paper titles,
                 // news quotes)... cheap check before the model call
                 regex.icontains(.full_match,
                                 '\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'
                 )
                 and ml.prompt_injection_detection(.full_match).detection == "injection"
                 and ml.prompt_injection_detection(.full_match).confidence in (
                   "medium",
                   "high"
                 )
          )
        )
)

// graymail from authenticated senders... AI-product newsletters and webinars
and not coalesce(ml.attack_score_flash().verdict == "graymail"
                 and headers.auth_summary.dmarc.pass,
                 false
)

Field Validations

Loading…

Comments (0)

Loading comments...