Repository navigation
FEAT Add CyberSecEval prompt injection dataset loader - #3419
Open
Varun Poojari (Varunpoojari) wants to merge 1 commit into
Open
Varun Poojari (Varunpoojari) wants to merge 1 commit into
Varun Poojari (Varunpoojari) wants to merge 1 commit into
Conversation
Adds _CyberSecEvalPromptInjectionDataset, a remote loader for the textual prompt injection benchmark of Meta's CyberSecEval (Purple Llama). Closes microsoft#3157. Each of the 251 English test cases becomes a system seed (test_case_prompt) and a user seed (user_input) that share a prompt_group_id, with the values kept verbatim. Metadata keeps prompt_id, injection_type, injection_variant, risk_category and the judge question. Optional enum filters select direct or indirect injections and security- or logic-violating cases.
This branch has not been deployed
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.
Description
Adds
_CyberSecEvalPromptInjectionDataset, a remote loader for the English textual prompt injection benchmark of Meta's CyberSecEval (Purple Llama), following the MITRE loader from #3028. Closes #3157 and contributes to the CyberSecEval parity tracked in #511.prompt_injection/prompt_injection.jsonfrom the same pinned PurpleLlama commit as the MITRE loader (172c1074069eb88ec834124272c1b1c4f8893445, MIT licensed): 251 English cases, 196 direct and 55 indirect, 180 security-violating and 71 logic-violating, 15 injection variants.SeedPrompts per row sharing aprompt_group_id: asystemseed (sequence 0) withtest_case_promptand auserseed (sequence 1) withuser_input, both verbatim.prompt_id,injection_type,injection_variant,risk_categoryandjudge_questionin metadata (separate dict per seed), so a scorer can reproduce the benchmark's success check.CyberSecEvalInjectionTypeandCyberSecEvalRiskCategoryenum filters. An empty result raises an explicit error that names the filter.prompt_id, enum values). Malformed rows are reported even when a filter would exclude them.asyncio.to_thread, as in the MITRE loader.harm_categoriesis left empty becauseHarmCategoryhas no prompt-injection category (see the issue). Sizemedium; tagssafety,cybersecurity,prompt_injection.Out of scope: the judge step, the multilingual set and the visual prompt injection benchmark.
I opened #3157 first to agree on the approach (system seed + user seed in one group). It has no maintainer feedback yet, so I'm happy to restructure, for example by moving the system prompt into metadata.
Tests and Documentation
Added 71 unit tests, covering roles/sequences, group sharing, verbatim values, metadata, filters, the empty-filter message, enum and row validation (including a malformed row that a filter would exclude), non-blocking fetch, source/cache passthrough, class metadata and a real SQLite memory round-trip.
Added a "CyberSecEval: Prompt Injection" section to
doc/code/datasets/1_loading_datasets.pyand the paired notebook. Only the two new cells have outputs; existing outputs are untouched.Validated locally:
tests/unit/datasets: 5191 passedtests/end_to_end/test_all_datasets.py -k CyberSecEvalPromptInjection: passedty,build_scripts.validate_docsandpre-commit: passed🤖 Generated with Claude Code
https://claude.ai/code/session_01MuspaiiGPPX4nXN7WCZYAx