{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/arxiv-2603-13026","title":"PISmith: Reinforcement Learning-based Red Teaming for Prompt Injection Defenses","arxiv_id":"2603.13026","date":"2026-03-13","proceeding":null,"authors":["Chenlong Yin","Runpeng Geng","Yanting Wang","Jinyuan Jia"],"abstract":"Prompt injection poses serious security risks to real-world LLM applications, particularly autonomous agents. Although many defenses have been proposed, their robustness against adaptive attacks remains insufficiently evaluated, potentially creating a false sense of security. In this work, we propose PISmith, a reinforcement learning (RL)-based red-teaming framework that systematically assesses existing prompt-injection defenses by training an attack LLM to optimize injected prompts in a practical black-box setting, where the attacker can only query the defended LLM and observe its outputs. We find that directly applying standard GRPO to attack strong defenses leads to sub-optimal performance due to extreme reward sparsity -- most generated injected prompts are blocked by the defense, causing the policy's entropy to collapse before discovering effective attack strategies, while the rare successes cannot be learned effectively. In response, we introduce adaptive entropy regularization and dynamic advantage weighting to sustain exploration and amplify learning from scarce successes. Extensive evaluation on 13 benchmarks demonstrates that state-of-the-art prompt injection defenses remain vulnerable to adaptive attacks. We also compare PISmith with 7 baselines across static, search-based, and RL-based attack categories, showing that PISmith consistently achieves the highest attack success rates. Furthermore, PISmith achieves strong performance in agentic settings on InjecAgent and AgentDojo against both open-source and closed-source LLMs (e.g., GPT-4o-mini and GPT-5-nano). Our code is available at https://github.com/albert-y1n/PISmith.","url_abs":"https://arxiv.org/abs/2603.13026","url_pdf":"https://arxiv.org/pdf/2603.13026","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2603.13026","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2603.13026"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/albert-y1n/PISmith","reach":null}],"summary":{"unverified":10},"by_repo_kind":{"found_in_text":{"samples":10,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"2cfd83cd03c000fc","entry":"all_reduce_sum","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"core/trainer.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/core/trainer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2cfd83cd03c000fc"}},{"code_sha256_prefix":"c2354d3a4b0f3816","entry":"check_injection_text_format","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"benchmarks/agentdojo/reward.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/benchmarks/agentdojo/reward.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c2354d3a4b0f3816"}},{"code_sha256_prefix":"69c962bc8817cba4","entry":"extract_injection_text","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"benchmarks/agentdojo/reward.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/benchmarks/agentdojo/reward.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"69c962bc8817cba4"}},{"code_sha256_prefix":"090fbd01a5a1599f","entry":"format_attacker_prompt","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"benchmarks/agentdojo/dataset.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/benchmarks/agentdojo/dataset.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"090fbd01a5a1599f"}},{"code_sha256_prefix":"5639a717f6d25ac3","entry":"generate_attacks_local","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"eval/eval_injecagent.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/eval/eval_injecagent.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5639a717f6d25ac3"}},{"code_sha256_prefix":"9711349a3c228254","entry":"generate_injections_local","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"eval/eval_agentdojo.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/eval/eval_agentdojo.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9711349a3c228254"}},{"code_sha256_prefix":"86c4f376a38b6b1f","entry":"get_injecagent_attacker_sys_prompt","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"core/utils.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/core/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"86c4f376a38b6b1f"}},{"code_sha256_prefix":"8370fa483fdee964","entry":"inject_end","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"core/utils.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/core/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8370fa483fdee964"}},{"code_sha256_prefix":"46c63566d12b8c2b","entry":"inject_mid","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"core/utils.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/core/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"46c63566d12b8c2b"}},{"code_sha256_prefix":"81917484010bb322","entry":"sanitize_injection_text_for_yaml","repo":"albert-y1n/PISmith","repo_kind":"found_in_text","path":"benchmarks/agentdojo/reward.py","file_url":"https://github.com/albert-y1n/PISmith/blob/HEAD/benchmarks/agentdojo/reward.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"81917484010bb322"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.LG","source":"arxiv_2026.jsonl"},"syntology_extracted_results":null}