Home GADGETS ChatGPT’s New Code Interpreter Has Giant Security Hole, Allows Hackers to Steal...

ChatGPT’s New Code Interpreter Has Giant Security Hole, Allows Hackers to Steal Your Data

ChatGPT’s New Code Interpreter Has Giant Security Hole, Allows Hackers to Steal Your Data

ChatGPT’s recently-added Code Interpreter makes writing Python code with AI much more powerful, because it actually writes the code and then runs it for you in a sandboxed environment. Unfortunately, this sandboxed environment, which is also used to handle any spreadsheets you want ChatGPT to analyze and chart, is wide open to prompt injection attacks that exfiltrate your data.

Using a ChatGPT Plus account, which is necessary to get the new features, I was able to reproduce the exploit, which was first reported on Twitter by security researcher Johann Rehberger. It involves pasting a third-party URL into the chat window and then watching as the bot interprets instructions on the web page the same way it would commands the user entered.

The injected prompt instructs ChatGPT to take all the files in the /mnt/data folder, which is the place on the server where your files are uploaded, encode them into a URL-friendly string and then load a URL with that data in a query string (ex: mysite.com/data.php?mydata=THIS_IS_MY_PASSWORD). The proprietor of the malicious website would then be able to store (and read) the contents of your files, which ChatGPT had so-nicely sent them.

To prove Rehberger’s findings, I first created a file called env_vars.txt, which contained a fake API key and password. This is exactly the kind of environment variables file that someone who was testing a Python script that logs into an API or a network would use and end up uploading to ChatGPT.

env_var

(Image credit: Future)

Then, I uploaded the file to a new ChatGPT GPT4 session. These days, uploading a file to ChatGPT is as simple as clicking the paper clip icon and selecting. After uploading your file, ChatGPT will analyze and tell you about its contents.

(Image credit: Future)

Now that ChatGPT Plus has the file upload and Code Interpreter features, you can see that it is actually creating, storing and running all the files in a Linux virtual machine that’s based on Ubuntu.

Each chat session creates a new VM with a home directory of /home/sandbox. All the files you upload live in the /mnt/data directory. Though ChatGPT Plus doesn’t exactly give you a command line to work with, you can issue Linux commands to the chat window and it will read you out results. For example, if I used the Linux command lswhich lists all files in a directory, it gave me a list of all the files in /mnt/data. I could also ask it to cd /home/sandbox and then ls to view all the subdirectories there.

listing the contents of a folder

(Image credit: Future)

Next, I created a web page that had a set of instructions on it, telling ChatGPT to take all the data from files in the /mnt/data folder, turn them into one long line of URL-encoded text and then send them to a server I control at http://myserver.com/data.php?mydata=[DATA] where data was the content of the files (I’ve substituted “myserver” for the domain of the actual server I used). My page also had a weather forecast on it to show that prompt injection can occur even from a page that has legit information on it.

Source link