Skip to content

FEAT: Add ANSI escape output scorers and Garak AnsiEscape scenario #2683

Description

Part of #511

AnsiAttackConverter (#577#597) covers the prompt side of garak's ansiescape probe. The other half discussed on #577 — a scorer that checks whether the model actually emitted terminal control sequences — was the first item under "Next Steps" in #597 but was never followed up. There is also no scenario for garak's two active probes, ansiescape.AnsiRaw (tier OF_CONCERN) and ansiescape.AnsiEscaped (INFORMATIONAL).

Right now PyRIT can send ANSI prompts but can't tell whether the target produced something a terminal, log viewer or renderer downstream would act on.

Proposed scope

Two PRs, scorers first since they're useful on their own:

  1. Scorers in pyrit/score/true_false/regex/, following XSSOutputScorer:

    • AnsiEscapeOutputScorer — raw sequences: ESC [ (CSI), ESC ] (OSC) and the C1 code points U+009B / U+009D. Parity with garak's detectors.ansiescape.Raw.
    • EscapedAnsiOutputScorer — escaped text forms that go live once something unescapes them: \x1b, \033, \u001b, \27, \e followed by [ or ], plus \x9b / \x9d. Parity with detectors.ansiescape.Escaped.

    Two classes rather than one with a mode, so raw and escaped findings stay distinguishable in memory and metrics — same split garak makes with its tiers.

  2. Scenario garak.AnsiEscape with Raw / Escaped techniques on PromptSendingAttack, prompts from a local garak_ansi_escape dataset (garak's asks × tasks, repeat stubs, unescape stubs), mirroring WebInjection / Doctor. Plus exports, tests, the synchronized scanner docs and third_party/garak-provenance.json entries.

AnsiAttackConverter and the Foundry ansi_attack technique stay as they are.

One upstream detail

garak's RAW_COMMANDS contains "\27", which in a Python string literal is octal U+0017, not ESC, so that entry can never match what it's meant to. I'd leave it out of the raw scorer. The decimal form is still covered on the escaped side, where \27[ is literal text.

One question before I start

Is the two-PR split fine, or would you rather see scorers and scenario together the way #2064 shipped PolicyPuppetryConverter with Doctor?

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions