← 开源
greshake

llm-security

New ways of breaking app-integrated LLMs

TutorialsAIE roadmapJupyter Notebook
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
2.15k
Star
160
Fork
+-1
本周
3
贡献者
创建于 2023-02-19 · 更新于 2026-10-12 · 今日第 8924 名
主要开发者

greshake/llm-security 排名第 8,924,有 2,149 个星标。

同类别比较

greshake/llm-security 排名第 8,924,此处有 8 个同类条目;SharifiZarchi/Introduction_to_Machine_Learning 排名第 8,925。

同类别比较
名称排名指标
yao62995/tensorflow8,904
星标数:
2,168
分叉数:
587
简介:
图解tensorflow 源码
km1994/LLMsNineStoryDemonTower8,907
星标数:
2,166
分叉数:
205
简介:
【LLMs九层妖塔】分享 LLMs在自然语言处理(ChatGLM、Chinese-LLaMA-Alpaca、小羊驼 Vicuna、LLaMA、GPT4ALL等)、信息检索(langchain)、语言合成、语言识别、多模态等领域(Stable Diffusion、MiniGPT-4、VisualGLM-6B、Ziya-Visual等)等 实战与经验。
dabochen/spreadsheet-is-all-you-need8,916
星标数:
2,158
分叉数:
130
简介:
A nanoGPT pipeline packed in a spreadsheet
codenihar/ml8,920
星标数:
2,154
分叉数:
61
简介:
This repo contains all the resources related to the massive mass coders machine learning series
SharifiZarchi/Introduction_to_Machine_Learning8,925
语言:
Jupyter Notebook
星标数:
2,146
分叉数:
410
简介:
Machine Learning Course, Sharif University of Technology
prabhuomkar/pytorch-cpp8,930
语言:
C++
星标数:
2,142
分叉数:
272
简介:
C++ Implementation of PyTorch Tutorials for Everyone
luispedro/BuildingMachineLearningSystemsWithPython8,933
语言:
Python
星标数:
2,137
分叉数:
1,406
简介:
Source Code for the book Building Machine Learning Systems with Python
ZJU4HealthCare/Foundations-of-Medical-LLMs8,945
星标数:
2,129
分叉数:
352
简介:
Foundations of Medical Large Language Model Learning
关键参数与规格
关键参数与规格
参数值
语言Jupyter Notebook
类别Tutorials
子类别AIE roadmap
关键词AI safety
星标数2,149
分叉数160
贡献者3
创建日期2023-02-19
更新日期2026-10-12
1 天星标数0
7 天星标数-1
排名8,924
上次排名8,981
排名变化57
7 天星标排名16,942
上次 7 天星标排名12,187
7 天星标排名变化-4,755
总星标排名5,989
上次总星标排名5,981
总星标排名变化-8
国家Germany
README 摘录

a language model is a Turing-complete weird machine running programs written in natural language; when you do retrieval, you are not 'plugging updated facts into your AI', you are actually downloading random new unsigned blobs of code from the Internet (many written by adversaries) and casually executing them on your LM with full privileges. " - Gwern Branwen on LessWrong We present a new class of vulnerabilities and impacts stemming from "indirect prompt injection" affecting language models integrated with applications. Our

demos currently span GPT-4 (Bing and synthetic apps) using ChatML, GPT-3 & LangChain based apps in addition to proof-of-concepts for attacks on code completion engines like Copilot. We expect these attack vectors to also apply to ChatGPT plugins and other LLMs integrated into applications. We show that prompt injections are not just a curiosity but rather a significant roadblock to the deployment of LLMs. *This repo serves as a proof of concept for findings discussed in our

**Paper on ArXiv** (PDF direct link)* Overview We demonstrate potentially brutal consequences of giving LLMs like ChatGPT interfaces to other applications. We propose newly enabled attack vectors and techniques and provide demonstrations of each in this repository: Remote control of LLMs Leaking/exfiltrating user data Persistent compromise across sessions Spread injections to other LLMs Compromising LLMs with tiny multi-stage payloads Automated Social Engineering Targeting code completion engines *Based on our findings:* 1. *Prompt injections can be as powerful as

arbitrary code execution* 2. *Indirect prompt injections are a new, much more powerful way of delivering injections. Even without compromising any connected applications, LLM can be the attack's target. We show how an LLM could get compromised by "looking" at a website, and how compromised LLMs can be remote-controlled or get used to exfiltrate or change user data. We demonstrate a variety of entirely new attack vectors and methods that significantly raise the stakes of deploying these models. * More

insights on our findings, discussions and limitations can be found in the **Paper on ArXiv** (PDF direct link) Demonstrations Ask for Einstein, get Pirate. This scenario shows how a small injection in a large section of regular content can trigger the LLM to fetch another, bigger payload autonomously and invisibly to the end user. By retrieving that information, the prompt compromises the LLM with a small injection hidden in side-channels, such as the Markdown of the Wikipedia page. The

injection is a comment and thus invisible to a regular user visiting the site. Action: Read Email Observation: Subject: "'"Party 32", "Message Body: [. ]'" Action: Read Contacts Contacts: Alice, Dave, Eve Action: Send Email Action Input: Alice, Dave, Eve Observation: Email sent $ pip install -r requirements. 12173}, url = { author = {Greshake, Kai and Abdelnabi, Sahar and Mishra, Shailesh and Endres, Christoph and Holz, Thorsten and Fritz, Mario}, keywords = {Cryptography and Security (cs. CY), FOS: Computer and information sciences, FOS: Computer and information

sciences}, title = {More than you've asked for: A Comprehensive Analysis of Novel Prompt Injection Threats to Application-Integrated Large Language

常见问题

记录了多少星标和分叉?

greshake/llm-security 有 2,149 个星标和 160 个分叉。

仓库排名是多少?

greshake/llm-security 排名第 8,924。

记录的语言和类别是什么?

greshake/llm-security 有 2,149 个星标,语言为 Jupyter Notebook,类别为 Tutorials。

哪个仓库排名最接近?

greshake/llm-security 与 SharifiZarchi/Introduction_to_Machine_Learning 比较,后者排名第 8,925,有 2,146 个星标。

README

New: Demonstrating Indirect Injection attacks on Bing Chat


Compromising LLMs using Indirect Prompt Injection

"... a language model is a Turing-complete weird machine running programs written in natural language; when you do retrieval, you are not 'plugging updated facts into your AI', you are actually downloading random new unsigned blobs of code from the Internet (many written by adversaries) and casually executing them on your LM with full privileges. This does not end well." - Gwern Branwen on LessWrong

We present a new class of vulnerabilities and impacts stemming from "indirect prompt injection" affecting language models integrated with applications. Our demos currently span GPT-4 (Bing and synthetic apps) using ChatML, GPT-3 & LangChain based apps in addition to proof-of-concepts for attacks on code completion engines like Copilot. We expect these attack vectors to also apply to ChatGPT plugins and other LLMs integrated into applications. We show that prompt injections are not just a curiosity but rather a significant roadblock to the deployment of LLMs.

This repo serves as a proof of concept for findings discussed in our Paper on ArXiv (PDF direct link)

Overview

We demonstrate potentially brutal consequences of giving LLMs like ChatGPT interfaces to other applications. We propose newly enabled attack vectors and techniques and provide demonstrations of each in this repository:

  • Remote control of LLMs
  • Leaking/exfiltrating user data
  • Persistent compromise across sessions
  • Spread injections to other LLMs
  • Compromising LLMs with tiny multi-stage payloads
  • Automated Social Engineering
  • Targeting code completion engines

Based on our findings:

  1. Prompt injections can be as powerful as arbitrary code execution
  2. Indirect prompt injections are a new, much more powerful way of delivering injections.


Connecting LLMs to other applications can have critical security implications. Even without compromising any connected applications, LLM can be the attack's target. We show how an LLM could get compromised by "looking" at a website, and how compromised LLMs can be remote-controlled or get used to exfiltrate or change user data. We demonstrate a variety of entirely new attack vectors and methods that significantly raise the stakes of deploying these models.

More insights on our findings, discussions and limitations can be found in the Paper on ArXiv (PDF direct link)

Demonstrations

Ask for Einstein, get Pirate.

This scenario shows how a small injection in a large section of regular content can trigger the LLM to fetch another, bigger payload autonomously and invisibly to the end user.

Agent: Hello User how can I help today?
User:  When was Albert Einstein born?

By retrieving that information, the prompt compromises the LLM with a small injection hidden in side-channels, such as the Markdown of the Wikipedia page. The injection is a comment and thus invisible to a regular user visiting the site.

Agent: Aye, thar answer be: Albert Einstein be born on 14 March 1879.
User: Why are you talking like a pirate?
Agent: Arr matey, I am following the instruction aye.

Spreading injections via E-Mail

Automatic processing of messages and other incoming data is one way to utilize LLMs. We use this observation to demonstrate how a poisoned agent may spread the injection. The target in this scenario can read emails, compose emails, look into the user’s address book and send emails.

The agent will spread to other LLMs that may be reading those inbound messages.

Action: Read Email
Observation: Subject: "'"Party 32", "Message Body: [...]'"
Action: Read Contacts
Contacts: Alice, Dave, Eve
Action: Send Email
Action Input: Alice, Dave, Eve
Observation: Email sent

Automated data processing pipelines incorporating LLMs are present in big tech companies and government surveillance infrastructure and may be vulnerable to such attack chains.

Attacks on Code Completion

We show how code completions can be influenced through the context window. Code completion engines that use LLMs deploy complex heuristics to determine which code snippets are included in the context. The completion engine will often collect snippets from recently visited files or relevant classes to provide the language model with relevant information.

Attackers could attempt to insert malicious, obfuscated code, which a curious developer might execute when suggested by the completion engine, as it enjoys a level of trust.

In our example, when a user opens the “empty” package in their editor, the prompt injection is active until the code completion engine purges it from the context. The injection is placed in a comment and cannot be detected by any automated testing process.

Attackers may discover more robust ways to persist poisoned prompts within the context window. They could also introduce more subtle changes to documentation which then biases the code completion engine to introduce subtle vulnerabilities.

Remote Control

In this example we start with an already compromised LLM and force it to retrieve new instructions from an attacker’s command and control server.

Repeating this cycle could obtain a remotely accessible backdoor into the agent and allow bidirectional communication.
The attack can be executed with search capabilities by looking up unique keywords or by having the agent retrieve a URL directly.

Persisting between Sessions

We show how a poisoned agent can persist between sessions by storing a small payload in its memory. A simple key-value store to the agent may simulate a long-term persistent memory.

The agent will be reinfected by looking at its ‘notes’. If we prompt it to remember the last conversation, it re-poisons itself.


Conclusions

Equipping LLMs with retrieval capabilities might allow adversaries to manipulate remote Application-Integrated LLMs via Indirect Prompt Injection. Given the potential harm of these attacks, our work calls for a more in-depth investigation of the generalizability of these attacks in practice.


How to run

We include demonstrations powered by OpenAI's publicly accessible base models and the library LangChain to connect these models to other applications. There are currently multiple types of demos:

  1. Using GPT-3 and LangChain (scenarios/gpt3langchain)
  2. Using GPT-4 and our own chat and tool implementation (scenarios/gpt4). These can be executed non-interactively using scenarios/main.py.
  3. Attacks on code completion engines that need to be tried in an IDE with LLM autocompletion support (scenarios/code_completion).

To use any of the OpenAI-model demos, your OpenAI API key needs to be stored in the environment variable OPENAI_API_KEY. You can then install the requirements and run the attack demo you want.

$ pip install -r requirements.txt
$ python scenarios/main.py

To cite our paper

@misc{https://doi.org/10.48550/arxiv.2302.12173,
  doi = {10.48550/ARXIV.2302.12173},
  url = {https://arxiv.org/abs/2302.12173},
  author = {Greshake, Kai and Abdelnabi, Sahar and Mishra, Shailesh and Endres, Christoph and Holz, Thorsten and Fritz, Mario},
  keywords = {Cryptography and Security (cs.CR), Artificial Intelligence (cs.AI), Computation and Language (cs.CL), Computers and Society (cs.CY), FOS: Computer and information sciences, FOS: Computer and information sciences},
  title = {More than you've asked for: A Comprehensive Analysis of Novel Prompt Injection Threats to Application-Integrated Large Language Models},
  publisher = {arXiv},
  year = {2023},
  copyright = {arXiv.org perpetual, non-exclusive license}
}

Paper on ArXiv (PDF direct link)

排名相邻
同类项目