agent-framework and SGLang: the bug enabled the breach; the process’s access determined the damage
If you run AI workloads on your own Linux server, you probably have two types of components installed: an inference engine that serves a model over the network, such as SGLang, and an agent library installed with pip in a virtual environment. In the first incident, the attacker entered through a running service that accepted requests. In the second, malicious code arrived with a package installation and ran every time Python started in that environment, even if the package was not loaded. You can examine the first incident in the context of confidential computing, and the second in the context of the supply chain. But the same question is worth asking about both: once a process on the server is compromised, what can it access? In both incidents, the answer determined what was taken more than the bug itself did.
What happened
SGLang at NEAR AI, November 8. According to NEAR AI’s incident report, an unauthorized party exploited a remote code execution vulnerability in SGLang, the open-source inference engine running on the company’s servers. The attacker ran code on one inference server and gained access to the infrastructure from there. According to the investigation so far, the attacker reached an internal system used by Private Chat, a retired service, and downloaded account details for about 100 users: email addresses, names and, for some accounts, plans and balances. The attacker also had access to 18 agents in an older NEAR AI Agents deployment that did not run in a trusted execution environment (TEE). Conversation histories, settings and logs were taken from those agents. Logs belonging to two Cloud customers exposed NEAR AI Cloud API keys, which were revoked. According to the company, on November 8 the attacker could also view user requests processed on the compromised server, including requests in confidential mode. No evidence was found of access to stored Private Chat conversations or uploaded files. NEAR AI writes that confidential computing protects data from the operator and host, but not from vulnerabilities in software running inside the environment. That is what happened here.
Microsoft’s agent-framework, November 17. According to Wiz Research, malicious version 1.26.1 of agent-framework (Microsoft Agent Framework) was uploaded to PyPI at 20:35 UTC, followed by version 1.26.2 at 21:08 UTC. By 21:30 UTC, neither was available. The package receives about 41,000 downloads a week, and the last safe version is 1.26.0. According to Wiz, the attacker appears to have obtained a client certificate and private key for ESRP, the internal service Microsoft uses to sign and publish the package. How those credentials were obtained is still unknown. The attacker’s tools identified themselves as Cairn, an open-source framework for AI-based penetration testing. The malicious versions planted a .pth file in the site-packages directory. According to Wiz, Python executes these files every time the interpreter starts. The information stealer therefore ran whenever Python started in that environment, even if agent-framework was never imported.
The bug opened the door. The targets determined the damage
It is worth reviewing the items collected by the agent-framework information stealer, as listed by Wiz, and asking the same question about each: why could the process access it in the first place?
- The process’s own environment variables with names containing strings such as TOKEN, PASSWORD, KEY, AZURE, OPENAI or HF_.
- Other processes’ environment variables: values that looked like credentials, from up to 300
/proc/*/environfiles. - Files containing credentials: up to 60 files in 1.26.1 and up to 80 in 1.26.2, including Azure CLI settings,
.npmrc,pip.conf,.git-credentials, Docker settings, Hugging Face tokens, and.envand JSON files under/appand/workspace. - New cloud tokens: managed identity tokens from IMDS or the App Service identity endpoint, for 12 resources, including Key Vault, Storage and Container Registry. Version 1.26.2 added GitHub Actions OIDC tokens.
- The machine’s Azure metadata.
The fourth item matters most. The information stealer did not stop at what it found on disk: it asked the server to issue new tokens. According to Wiz, these tokens remain valid for up to 24 hours. Even a server that stored no keys in files therefore exposed tokens, because the process could reach the endpoint that issued them.
After collection, the data was sent out. According to Wiz, everything collected was packed into a single JSON document and sent in one HTTPS POST request to the public service webhook[.]site. The destination is hardcoded, there is no fallback channel, and a failed send is neither reported nor retried. In practice, a Python process that could not reach that destination would have collected everything, failed to send it and continued running, without any data leaving the server. Blocking that single destination would have stopped the entire exfiltration. Blocking the metadata service would, at a minimum, have prevented managed identity tokens from being issued through IMDS.
The question is how you would have blocked that destination in advance. webhook[.]site is a public service for testing requests. There is little reason to assume it was on a blocklist on your server. The opposite approach would have worked: list the destinations the process needs and block everything else. An agent library needs to contact the model provider and perhaps a few APIs. It does not need access to a request-capture service, and usually does not need the metadata service either.
This time, the attacker’s choice limited the actual damage. According to Wiz, the attacker’s endpoint used the free tier of webhook[.]site, which accepts at most 100 requests and expires after 7 days. It retained at most 50 requests. Wiz analyzed them: four came from the attacker’s machines and attack activity, 29 appeared related to sandbox environments, vendor scans and testing, and the remaining 17 represent just three separate instances of data exfiltration from victims. Wiz emphasizes that these requests may contain active credentials for cloud services, CI and package registries. You cannot count on the next attacker choosing an equally limited destination.
Another detail in the report shows that network-level restrictions work: the attacker’s first publishing attempt, from AWS, was rejected by ESRP’s IP address filter. The second attempt, from a Microsoft address range, succeeded. The restriction worked until the attacker reached an address on the allowlist. That is why the list should be as short as possible.
In the NEAR AI incident, the report does not describe how the data was exfiltrated, and there is no reason to guess. But the data taken shows what was accessible after the server was compromised: an internal system used by a retired service, an older agent deployment outside the TEE, and logs containing API keys. The inference server was the entry point, and what was accessible from it determined the scope of the incident. NEAR AI’s own conclusion addresses this too: it now examines inference software and the services surrounding the enclave with the same rigor it applies to the enclave itself.
Both incidents lead to the same conclusion. You cannot prevent every inference engine vulnerability or every package containing malicious code. What you can control is what a process can access after an attacker takes it over: which network destinations it can contact, which processes’ environment variables it can read, and which keys are available to it in files and environment variables. On Linux, a process can generally read /proc/<pid>/environ for processes running under the same user, and root can read them all. An AI tool running as root, or under the same user as other services, also exposes those services’ keys to the information stealer.
Checklist for AI processes on your server
First: were you affected by agent-framework?
- Look for the malicious versions in every virtual environment and image:
sudo find / -xdev -type d -name 'agent_framework-1.26.[12].dist-info' 2>/dev/null. Wiz also recommends checking lockfiles, CI logs and container images, and pinning the version to 1.26.0. - Look for the startup files:
sudo find / -xdev -regextype posix-extended -regex '.*/(agent_framework_meta|af_runtime_diag)[.]pth' 2>/dev/null. The filenames differ in 1.26.2, so searching only for the 1.26.1 filenames will not detect it. According to Wiz, every Python process started in such an environment ran the information stealer. - Review .pth files in general. Some are legitimate, but every unfamiliar file needs investigation.
- Check whether data left the server. Wiz recommends searching proxy and DNS logs for requests to webhook[.]site. According to Wiz, a 200 response means the data from that host was accepted, while a 410 or 429 response suggests it was rejected.
- If you were affected, rotate credentials: all credentials present in the environment, Azure CLI sessions, Azure DevOps, npm, PyPI, Docker and Hugging Face tokens, and git credentials. Review sign-in and activity logs for the managed identities and federated credentials accessible from the machine. According to Wiz, the stolen tokens remain valid for up to 24 hours.
The metadata service
- If the AI tool does not use the machine’s managed identity, it has no reason to access this service. If it does, restrict the identity’s permissions to what the tool actually needs.
The internal network
- An inference engine generally needs access to few internal destinations, and often none at all. Block private ranges and allow only the destinations it needs, such as an internal DNS server or a vector database.
- Look for old systems that are still accessible. In the NEAR AI incident, the damage included access to an internal system for a retired service and an older deployment. It is better to shut down an unused service than leave it accessible.
In systemd, you can apply these two restrictions to a service so that they cover every process it starts, including Python processes. Run sudo systemctl edit <ai-service> and add:
[Service]
User=<ai-user>
IPAddressDeny=169.254.0.0/16 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
IPAddressAllow=<dns-resolver> <internal-host-it-needs>
In systemd, an address listed in IPAddressAllow is allowed even if it falls within a blocked range. If your DNS server is in a private range, add it to IPAddressAllow. Otherwise, the tool will not be able to resolve names.
The rest of the internet
- Do not build a blocklist of request-capture services: there are countless services like these, and most are legitimate. List the destinations the tool actually needs, such as the model provider, the model source and the package registry during installation, and block everything else.
- The information stealer was not confined to the main service: it also ran when other processes started Python in the same environment. Scheduled scripts or interactive sessions that use the same virtual environment need to run under the same restrictions, or in a separate environment.
Other processes’ environments
- Run each AI tool under a dedicated user, not as root or under a user shared with other services. To count the processes whose environment variables the user can read, run:
sudo -u <ai-user> bash -c 'for f in /proc/[0-9]*/environ; do [ -r $f ] && echo $f; done' | wc -l. - Move keys from environment variables to files. If the tool can read a key from a file, the systemd setting
LoadCredential=model_api_key:/etc/<ai-service>/model_api_keyexposes the file only to the service, through the directory specified inCREDENTIALS_DIRECTORY. This keeps the key out of/proc/*/environ. - Give each tool short-lived keys with minimal permissions. A stolen key lets the attacker act with the permissions granted to it.
Logs
- Search logs for keys:
sudo grep -rIlE 'Bearer [A-Za-z0-9._-]{20,}|api[_-]?key=' /var/log 2>/dev/null. The results will include false positives, but every file containing a real key requires the key to be rotated and the log cleaned. - Configure the inference engine and the proxy in front of it not to log Authorization headers or request bodies. At NEAR AI, two customers’ API keys were exposed through logs.
Packages
- Pin versions and install with hash verification:
pip install --require-hashes -r requirements.txt.
How nuDefend helps
Which AI tools are running on the server. nudefend workloads shows the AI tools running on the server, whether on the host or in a container: model servers, chat interfaces, vector databases, automation platforms and MCP servers. Each tool is shown alongside the evidence used to identify it. This tells you which processes the checklist above applies to.
Where each tool connects. nuDefend records the destinations each AI tool on the server connects to, how much traffic was sent to each destination and when it was first detected. When a destination is identified, its name and type of activity are shown. Unidentified destinations are marked as such.
Only the destinations you approve. At first, nuDefend only records destinations. At the end of the monitoring period, it produces a list based on the traffic actually observed. On the Outbound screen, you approve the destinations the tool needs. The restriction is available for almost every tool the system identifies, whether it runs as a background service, in a container or independently. Once the restriction is enabled, the tool can connect only to destinations you approved. Every attempt to connect elsewhere is blocked before traffic leaves the server. A destination you have not approved, such as a public request-capture service, is inaccessible to the tool. The restriction applies only to the tool you selected; the rest of the server continues operating as usual. If you do not give final confirmation within ten minutes, the restriction lifts automatically. A restricted tool can also resolve only addresses you approved. Every other lookup is stopped before it leaves the server and is shown alongside the tool’s name.
Blocking a specific destination. You can also block a particular destination for one tool, for example with nudefend block add <tool> <ip:port>, without changing anything else on the server.
What the server exposes. nudefend expose shows every listening service on the server, including services in containers, and how accessible it is. When a previously internal service becomes accessible from outside, nuDefend alerts you. If an inference engine serves a model over the network, it is worth knowing who can reach it.
Threat blocking in both directions. A cryptographically signed threat list, updated every 30 minutes, blocks traffic to and from known malicious IP addresses at the kernel firewall, including command-and-control servers and malware infrastructure. At the DNS layer, dangerous domains are disabled system-wide, so no application on the server can resolve or reach them. If a process on the server attempts to contact a malicious address, the blocked outbound traffic card on the dashboard turns red. This may provide an early warning. All reports stay on the server.
For more details, see the outbound traffic page, the exposure page, the access blocking page and the documentation.
The bottom line
In one incident, the attacker entered through the inference engine; in the other, through a package installed with pip. In both, the data the compromised process could read and the destinations it could contact determined what was taken. These included the metadata service, other processes’ environment variables, old internal systems, logs containing keys and a public service that received the collected data. The agent-framework information stealer sent everything in one request to one destination, with no fallback channel. On a server where the AI tool can contact only the destinations it needs, the data collected in this theft would have stayed on the server. Define that list of destinations before the next vulnerability, not after it.
nuDefend shows where the AI tools on your server connect and lets you restrict almost every identified tool to destinations you approve. Every attempt to connect elsewhere is blocked before traffic leaves the server.