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.

Jul 26, 2025 - 09:46
Updated: 
104.8k

Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Explainer

Generative AI & LLMs

How Researchers Got Root in Copilot Enterprise’s Python Sandbox

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?

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:

  1. A keep-alive script running as root called pgrep in a loop every few seconds, without the absolute path /usr/bin/pgrep.
  2. The root process's PATH included a directory that the unprivileged sandbox user could write to, ahead of /usr/bin.
  3. The researchers used Copilot to place a script named pgrep in that directory.
  4. 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 AprilEye Security reports the issue to the Microsoft Security Response Center
By 25 JulyMicrosoft fixes the issue, rated moderate
Late JulyEye 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

Researchers gained root inside Copilot Enterprise’s isolated Python sandbox container. No customer data access or escape was reported.

Researchers at Eye Security, who reported it to Microsoft on 18 April 2025.

A root script called pgrep without a full path, so a fake pgrep in a writable directory earlier in PATH ran as root.

Yes. Microsoft fixed it by 25 July 2025 and rated it moderate severity.

The researchers said they did not access customer data and found nothing useful inside the container.

Untrusted Search Path: a program finds and runs a command from a location an attacker can control.

Use absolute paths in privileged scripts, set a fixed PATH and keep writable directories out of root’s PATH.

No. The fix was applied to the service. Reviewing Microsoft 365 sharing permissions is still good practice.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.