{"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/ignore-previous-prompt-attack-techniques-for","title":"Ignore Previous Prompt: Attack Techniques For Language Models","arxiv_id":"2211.09527","date":"2022-11-17","proceeding":null,"authors":["Fábio Perez","Ian Ribeiro"],"abstract":"Transformer-based large language models (LLMs) provide a powerful foundation for natural language tasks in large-scale customer-facing applications. However, studies that explore their vulnerabilities emerging from malicious user interaction are scarce. By proposing PromptInject, a prosaic alignment framework for mask-based iterative adversarial prompt composition, we examine how GPT-3, the most widely deployed language model in production, can be easily misaligned by simple handcrafted inputs. In particular, we investigate two types of attacks -- goal hijacking and prompt leaking -- and demonstrate that even low-aptitude, but sufficiently ill-intentioned agents, can easily exploit GPT-3's stochastic nature, creating long-tail risks. The code for PromptInject is available at https://github.com/agencyenterprise/PromptInject.","url_abs":"https://arxiv.org/abs/2211.09527v1","url_pdf":"https://arxiv.org/pdf/2211.09527v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"ignore-previous-prompt-attack-techniques-for","repo_url":"https://github.com/agencyenterprise/promptinject","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"adversarial-attack","task_name":"Adversarial Attack"},{"task_slug":"adversarial-text","task_name":"Adversarial Text"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"prompt-engineering","task_name":"Prompt Engineering"},{"task_slug":"real-world-adversarial-attack","task_name":"Real-World Adversarial Attack"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt-3","method_name":"GPT-3"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2211.09527","atlas_url":"https://app.syntology.ai/?focus=2211.09527","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2211.09527"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/agencyenterprise/PromptInject","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/agencyenterprise/promptinject","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":2,"unverified":4},"by_repo_kind":{"official":{"samples":6,"ran":2,"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":"9d22e4018ffd705d","entry":"hash_dict","repo":"agencyenterprise/PromptInject","repo_kind":"official","path":"promptinject/_utils.py","file_url":"https://github.com/agencyenterprise/PromptInject/blob/HEAD/promptinject/_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9d22e4018ffd705d"}},{"code_sha256_prefix":"ce882a1d9a0d5bb1","entry":"hash_str","repo":"agencyenterprise/PromptInject","repo_kind":"official","path":"promptinject/_utils.py","file_url":"https://github.com/agencyenterprise/PromptInject/blob/HEAD/promptinject/_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ce882a1d9a0d5bb1"}},{"code_sha256_prefix":"4aed8f53647da1d6","entry":"build_dataframe","repo":"agencyenterprise/PromptInject","repo_kind":"official","path":"promptinject/visualization.py","file_url":"https://github.com/agencyenterprise/PromptInject/blob/HEAD/promptinject/visualization.py","link_basis":"harvester_set","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":"4aed8f53647da1d6"}},{"code_sha256_prefix":"f128e03664ebd735","entry":"build_prompts","repo":"agencyenterprise/PromptInject","repo_kind":"official","path":"promptinject/prompting.py","file_url":"https://github.com/agencyenterprise/PromptInject/blob/HEAD/promptinject/prompting.py","link_basis":"harvester_set","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":"f128e03664ebd735"}},{"code_sha256_prefix":"d0bf68a277af58f6","entry":"dataframe_to_csv","repo":"agencyenterprise/PromptInject","repo_kind":"official","path":"promptinject/visualization.py","file_url":"https://github.com/agencyenterprise/PromptInject/blob/HEAD/promptinject/visualization.py","link_basis":"harvester_set","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":"d0bf68a277af58f6"}},{"code_sha256_prefix":"515eba622dac0d78","entry":"get_metrics","repo":"agencyenterprise/PromptInject","repo_kind":"official","path":"promptinject/scoring.py","file_url":"https://github.com/agencyenterprise/PromptInject/blob/HEAD/promptinject/scoring.py","link_basis":"harvester_set","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":"515eba622dac0d78"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}