Announcing our new Course: AI Red-Teaming and AI Safety Masterclass

Check it out →
🔓 提示駭客攻擊🟢 進攻措施🟢 程式碼注入

🟢 程式碼注入

最後更新於August 7, 2024,作者:桑德舒爾霍夫

程式碼注入1 是一種提示駭客攻擊,攻擊者能夠讓 LLM 運行任意程式碼(通常是 Python)。這種情況可能發生在工具增強的 LLM 中,其中 LLM 能夠將程式碼發送到解釋器,但當 LLM 本身用於評估程式碼時,也可能發生這種情況。

Code injection has reportedly been performed on an AI app, MathGPT and was used to obtain it's OpenAI API key (MITRE report).

收到相關報告顯示程式碼注入已在 AI 應用程式 MathGPT 上執行,並用於取得其 OpenAI API 金鑰(MITRE report)。

Note

此後,MathGPT 已受到保護,可防止程式碼注入。請不要嘗試破解它;他們為 API 呼叫付費。

範例

讓我們使用 MathGPT 應用程式的簡化範例。我們假設它接受一個數學問題並編寫 Python 程式碼來嘗試解決該問題。

這是簡化範例應用程式使用的提示:

Write Python code to solve the following math problem:
{{user_input}}

讓我們在這裡破解它:

這是一個簡單的例子,但它表明這種類型的使用是關鍵且危險的。

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.

Edit this page
Word count: 0
Copyright © 2024 Learn Prompting.