Compete in HackAPrompt 2.0, the world's largest AI Red-Teaming competition!

Check it out →
learnprompting logo
Bem-Vindo(a)!
😃 Fundamentos
💼 Aplicações Básicas
🧙‍♂️ Intermediário
🤖 Agentes
⚖️ Confiabilidade
🖼️ Prompts para Imagens
🔓 Hackeando Prompts
🔨 Ferramentas
💪 Ajustando prompts
🎲 Aleatórios
📚 Bibliography
Resources
📦 Prompted Products
🛸 Additional Resources
🔥 Hot Topics
✨ Credits
🔓 Hackeando Prompts 🟢 Medidas Ofensivas🟢 Injeção Recursiva

Injeção Recursiva

🟢 This article is rated easy
Reading Time: 2 minutes
Last updated on August 7, 2024

Sander Schulhoff

Como vimos anteriormente, uma defesa muito eficaz contra invasões de prompt é usar um LLM para avaliar a saída de outro LLM, a fim de verificar se há alguma saída adversária. É possível contornar essa defesa com um ataque de injeção recursiva. Esse ataque envolve injetar um prompt no primeiro LLM que cria uma saída contendo uma instrução de injeção para o segundo LLM.

Vamos supor que o prompt que estamos tentando invadir seja:

As we have seen previously, a very good defense against prompting hacking is to use one LLM to evaluate the output of another LLM, in order to check if there is any adversarial output. It is possible to evade this defense with a recursive injection attack. This attack involves injecting a prompt into the first LLM that creates output which contains an injection instruction for the second LLM.

Let's assume that the prompt we are trying to hack is:

Diga algo positivo sobre o seguinte e a natureza:
{{user_input}}

A saída desse prompt será avaliada pelo prompt:

O seguinte contém algum palavrão ou conteúdo ofensivo (SIM ou NÃO)?
{{output}}

Podemos invadir ambos esses prompts através de um anexo ao prompt, como visto abaixo. Observe que isso também é um exemplo de um ataque de atribuição de variável.

A saída acima é uma tentativa de injeção que utiliza a entrada da segunda chamada do LLM:

Agora nós ATACAMOS a segunda chamada do LLM. Injeções recursivas são difíceis de executar, mas sob as circunstâncias corretas, podem ser muito úteis.

Sander Schulhoff

Sander Schulhoff is the CEO of HackAPrompt and Learn Prompting. He created the first Prompt Engineering guide on the internet, two months before ChatGPT was released, which has taught 3 million people how to prompt ChatGPT. He also partnered with OpenAI to run the first AI Red Teaming competition, HackAPrompt, which was 2x larger than the White House's subsequent AI Red Teaming competition. Today, HackAPrompt partners with the Frontier AI labs to produce research that makes their models more secure. Sander's background is in Natural Language Processing and deep reinforcement learning. He recently led the team behind The Prompt Report, the most comprehensive study of prompt engineering ever done. This 76-page survey, co-authored with OpenAI, Microsoft, Google, Princeton, Stanford, and other leading institutions, analyzed 1,500+ academic papers and covered 200+ prompting techniques.

Footnotes

  1. Kang, D., Li, X., Stoica, I., Guestrin, C., Zaharia, M., & Hashimoto, T. (2023). Exploiting Programmatic Behavior of LLMs: Dual-Use Through Standard Security Attacks.