How Researchers Got Root in Copilot Enterprise’s Python Sandbox
In 2025, researchers at Eye Security showed they could gain root privileges inside the Python sandbox that Microsoft Copilot Enterprise uses to run code. A script running as root called the pgrep command without its full path, and a directory the researchers could write to came earlier in the search path, so uploading a file named pgrep made root run their code.
Topic: Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Explainer
Also covers: Generative AI & LLMs
Quick answer: In 2025, researchers at Eye Security showed they could gain root privileges inside the Python sandbox that Microsoft Copilot Enterprise uses to run code. A script running as root called the pgrep command without its full path, and a directory the researchers could write to came earlier in the search path, so uploading a file named pgrep made root run their code. They reported it to Microsoft on 18 April 2025; Microsoft rated it moderate severity and fixed it by 25 July 2025. The researchers said they found nothing useful in the container and did not access customer data or escape the sandbox. It was not a breach of Copilot users.
Key takeaways
- The flaw was an untrusted search path (CWE-426), a classic Linux privilege escalation.
- Root was gained inside an isolated container, not on Microsoft's wider infrastructure.
- No customer data exposure was reported; Microsoft fixed it and gave no bounty.
- AI code-execution sandboxes are ordinary Linux environments and need ordinary hardening.
- Defence in depth (container isolation) limited the impact.
Table of Contents
- What Is the Copilot Python Sandbox?
- How Did the Root Escalation Work?
- What Was the Real Impact?
- What Was the Timeline?
- What Is the Coding Lesson?
- How Should AI Code Sandboxes Be Designed?
- Do Copilot Users Need to Do Anything?
- References
What Is the Copilot Python Sandbox?
Copilot Enterprise can write and run Python to analyse uploaded files or produce charts. That code runs in a Jupyter-based environment inside a Linux container. Users can upload files, which land in a working directory such as /mnt/data. By design, user code runs as an unprivileged user, while some management scripts run as root.
How Did the Root Escalation Work?
According to Eye Security's write-up:
- A keep-alive script running as root called
pgrepin a loop every few seconds, without the absolute path/usr/bin/pgrep. - The root process's
PATHincluded a directory that the unprivileged sandbox user could write to, ahead of/usr/bin. - The researchers used Copilot to place a script named
pgrepin that directory. - On the next loop, root executed their script instead of the real
pgrep, giving them code execution as root inside the container.
This pattern is CWE-426, Untrusted Search Path.
What Was the Real Impact?
Root inside a container is not the same as control of the host. The researchers reported no container escape, no access to other customers' sessions and no customer data. Microsoft classified the issue as moderate. Headlines such as "Copilot hacked" overstated it; the accurate summary is a privilege escalation inside an isolated sandbox that should not have been possible.
What Was the Timeline?
| Date (2025) | Event |
|---|---|
| 18 April | Eye Security reports the issue to the Microsoft Security Response Center |
| By 25 July | Microsoft fixes the issue, rated moderate |
| Late July | Eye Security publishes its research; no bounty awarded |
What Is the Coding Lesson?
Any script that runs with privileges should not trust PATH:
# vulnerable: depends on PATH
while true; do
if ! pgrep -f jupyter >/dev/null; then restart_jupyter; fi
sleep 2
done
# safer: fixed PATH and absolute paths
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
while true; do
if ! /usr/bin/pgrep -f jupyter >/dev/null; then /usr/local/bin/restart_jupyter; fi
sleep 2
done
To audit a Linux system for the same mistake, look for writable directories in root's path:
sudo sh -c 'echo $PATH' | tr ':' '\n' | while read d; do
[ -d "$d" ] && find "$d" -maxdepth 0 \( -perm -o+w -o ! -user root \) -print
done
Any output is a directory root searches that someone else can write to.
How Should AI Code Sandboxes Be Designed?
- Run user code and management processes in separate containers, or at least separate users with no shared writable paths.
- Avoid root inside the container; use user namespaces or rootless containers.
- Apply seccomp and AppArmor or SELinux profiles, and drop Linux capabilities.
- Restrict outbound network access from the sandbox.
- Destroy sandboxes after each session.
- Treat model-generated code as untrusted input, as the OWASP Top 10 for LLM Applications recommends for excessive agency and output handling.
Do Copilot Users Need to Do Anything?
No action is needed; Microsoft fixed the service. Organisations should still review what data Copilot can reach through Microsoft 365 permissions, because over-shared files are a larger practical risk than sandbox flaws. Researchers can report AI issues through Microsoft's AI bounty programme. Related: the Amazon Q Developer extension compromise. For Linux privilege escalation training, contact WebAsha.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0