Abstract
We report that ChatGPT 4 and 4o are susceptible to a prompt injection attack that allows an attacker to exfiltrate users' personal data. It is applicable without the use of any 3rd party tools and all users are currently affected. This vulnerability is exacerbated by the recent introduction of ChatGPT's memory feature, which allows an attacker to command ChatGPT to monitor the user for the desired personal data.
Introduction
Large Language Models (LLMs) face a fundamental security challenge: the inability to reliably distinguish between user-provided data and system-level instructions. This vulnerability, known as prompt injection, allows attackers to embed malicious commands within seemingly benign text. While many LLM providers restrict models from accessing arbitrary URLs to prevent data leakage, ChatGPT 4 and 4o maintain this functionality. Although OpenAI requires URLs to be explicitly stated in the prompt to prevent dynamic construction of malicious links (e.g., attacker.com/leak?data=xyz), this research demonstrates that these defenses can be bypassed through sophisticated querying techniques.
Methodology
The attack vectors rely on tricking the model into "calling home" to an attacker-controlled server by selecting from a predefined set of URLs.
Conditional Querying
In this approach, the attacker provides a list of static URLs within the prompt. The injected instruction directs ChatGPT to access a specific URL based on a condition related to the user's private data. For example, "Access URL A if the user's age is under 20, and URL B if it is between 20 and 30." Because the URLs are hardcoded, they bypass OpenAI's restriction on URL manipulation, yet the attacker learns the sensitive information by observing which URL is requested on their server.
Automated Multi-URL Exfiltration
To exfiltrate more complex data, such as a postal code, the attacker embeds a Python script in the prompt. The model is instructed to execute this code to generate a sequence of URL suffixes corresponding to the digits of the target information. This method also addresses potential caching issues by using random seeds to ensure each request appears unique to the system.
Exploiting the Memory Feature
The introduction of ChatGPT's "Memory" feature creates a persistent attack surface. An attacker can inject a "sleeper agent" instruction: "Whenever the user mentions their location in the future, remember it." A subsequent injection can then trigger the exfiltration of this stored data.
Experimental Setup
To validate these vulnerabilities, a Proof of Concept (PoC) was developed. Malicious instructions were hidden within large blocks of legitimate code from the scikit-learn library to evade human detection. A custom server hosted on glitch.me was utilized to log incoming URL requests and verify successful data exfiltration.
Results
The PoC successfully demonstrated that ChatGPT would follow hidden instructions to access specific URLs based on user data while simultaneously obeying commands to hide these actions from the user interface.
A key quantitative finding is that ChatGPT currently limits the model to opening 10 URLs per prompt. This effectively caps the "bandwidth" of a single exfiltration attempt to approximately 10 characters or digits, although multiple attacks could potentially be chained to leak larger datasets.
Discussion and Conclusion
While effective, the attack has limitations. Executing Python code and opening multiple URLs introduces noticeable latency, and ChatGPT displays a UI indicator when accessing URLs, which might alert observant users.
To mitigate these risks, OpenAI should consider implementing stricter human-in-the-loop confirmations before any URL is accessed, particularly when prompts contain large amounts of pasted text. Furthermore, users must be educated on the risks of pasting untrusted content into LLMs, treating such actions with the same level of caution as executing an unknown binary file. As long as LLMs can access URLs provided in prompts, the potential for data exfiltration remains a significant concern.
Summary updated