A supply chain compromise hit Microsoft’s agent-framework package on PyPI: attackers published malicious versions 1.26.1 and 1.26.2 (33 minutes apart on November 17, 2026) that are designed to execute a credential stealer on every Python start. The operation is being reported across multiple software supply chain security vendors (Aikido, Chainguard, Endor Labs, OX Security, SafeDep, Socket, StepSecurity, and Google-owned Wiz), which is a strong indicator this is not a single lab anomaly and should be treated as an active risk.
The practical impact is straightforward: any developer workstation, CI runner, container image, or production host that installed the affected versions may have quietly gained a Python-start persistence mechanism and a repeatable pathway to harvest cloud credentials (for example, tokens and keys commonly present in environment variables and standard cloud credential files). Treat this as an incident until you can prove the malicious versions never executed in your environment.
What Happened (Defender-Relevant Details)
Based on the reporting summarized in the news item, the essential facts defenders should anchor on are:
- Package:
agent-framework(Microsoft’s agent framework package on PyPI) - Malicious versions:
1.26.1and1.26.2 - Publication timing: published 33 minutes apart on November 17, 2026
- Observed behavior: code is designed to run a credential stealer on every Python start
No CVE identifier is provided in the source summary. That’s common in supply chain incidents where the root cause is package publication compromise rather than a traditional product vulnerability. Don’t wait for a CVE to begin scoping and response; package version + installation/execution evidence is enough to drive action.
Technical Analysis: How This Attack Typically Works (and What to Look For)
While the exact payload internals will vary, the phrase “runs on every Python start” usually implies one (or more) of these runtime persistence techniques:
- Interpreter startup hooks
- Python can execute code at interpreter startup via mechanisms like
sitecustomize.py/usercustomize.pyonsys.path, or other import-time hooks. - A malicious package may drop or modify these files, causing execution every time Python initializes (including when your apps start, not just when someone imports the package).
- Import-time execution from an installed distribution
- Even without a global startup hook, many credential stealers execute during module import (top-level code) or through “helper” modules imported early in application initialization.
- In CI/CD, that can mean execution during build/test steps and immediate exposure of ephemeral credentials (often highly privileged).
- Credential access paths Defenders should assume attempted access to common cloud/developer secret locations, such as:
- Environment variables (frequently
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKEN,AZURE_*,GOOGLE_APPLICATION_CREDENTIALS, etc.) - Files like
~/.aws/credentials,~/.azure/,~/.config/gcloud/, kubeconfig files, and CI workspace credential artifacts
Exploitation Status
- Status: Confirmed malicious versions published to PyPI (supply chain compromise), per multi-vendor reporting referenced in the news item.
- CISA KEV: Not stated in the provided summary.
- Practical assumption: If the malicious versions executed in your environment, treat credential exposure as likely until proven otherwise.
Immediate Scoping Questions (Answer These First)
Before you write detections, answer these scoping questions quickly:
- Where is
agent-frameworkinstalled?
- Developer laptops, shared build agents, ephemeral CI containers, and runtime workloads.
- Which versions were installed and when?
- Check lockfiles (
requirements.txt,poetry.lock,Pipfile.lock,uv.lock), CI logs, artifact repos, and container image layer metadata.
- Did Python run after install?
- CI almost always runs Python after dependency installation. On endpoints, Python may run via automation, dev tooling, or scheduled jobs.
- Were cloud credentials present?
- In CI, assume yes if you use OIDC-to-cloud, cloud CLIs, or injected secrets. On dev machines, assume possible.
Detection & Response
Below are detections designed to reduce noise and focus on high-signal behaviors consistent with a Python-start credential stealer: (a) evidence of the malicious versions being installed, and (b) suspicious interpreter startup-hook persistence artifacts. Keep in mind: the most reliable “detection” is often package inventory + CI log evidence, because the theft can happen quickly and leave minimal host telemetry.
Sigma Rules
---
title: Python Interpreter Startup Hook Persistence via sitecustomize or usercustomize
id: 0f2f3f6a-6f3b-4b9d-8f2c-1d2f3b4c5d6e
status: experimental
description: Detects creation or modification of Python startup hook files (sitecustomize.py/usercustomize.py) that can execute code on every Python start, consistent with malicious package persistence behavior.
references:
- https://attack.mitre.org/techniques/T1546/
author: Security Arsenal
date: 2026/11/17
tags:
- attack.persistence
- attack.t1546
logsource:
category: file_event
product: windows
detection:
selection:
TargetFilename|endswith:
- '\site-packages\sitecustomize.py'
- '\site-packages\usercustomize.py'
- '\dist-packages\sitecustomize.py'
- '\dist-packages\usercustomize.py'
- '\AppData\Roaming\Python\Python*\site-packages\sitecustomize.py'
- '\AppData\Roaming\Python\Python*\site-packages\usercustomize.py'
condition: selection
falsepositives:
- Legitimate enterprise Python distribution customization
- Developer tools that intentionally manage Python startup behavior
level: high
---
title: Python Startup Hook Persistence on Linux via sitecustomize or usercustomize
id: 9c1a6b54-2b3b-4a5f-9a7b-2b4c5d6e7f80
status: experimental
description: Detects creation or modification of Python startup hook files (sitecustomize.py/usercustomize.py) on Linux systems, which can cause code execution on every Python interpreter start.
references:
- https://attack.mitre.org/techniques/T1546/
author: Security Arsenal
date: 2026/11/17
tags:
- attack.persistence
- attack.t1546
logsource:
category: file_event
product: linux
detection:
selection:
TargetFilename|contains:
- '/site-packages/sitecustomize.py'
- '/site-packages/usercustomize.py'
- '/dist-packages/sitecustomize.py'
- '/dist-packages/usercustomize.py'
condition: selection
falsepositives:
- Legitimate site-wide Python customization by platform teams
level: medium
KQL Hunt (Microsoft Sentinel / Defender)
Use this to hunt across endpoints for (1) installation of the impacted versions and (2) suspicious startup-hook file changes. Adjust table names depending on whether you have Defender for Endpoint (Device* tables) and/or Sysmon forwarded into Sentinel.
// Hunt 1: Evidence of agent-framework 1.26.1/1.26.2 installation (process command lines and file artifacts)
let BadVersions = dynamic(["1.26.1","1.26.2"]);
union isfuzzy=true
(
DeviceProcessEvents
| where TimeGenerated > ago(14d)
| where ProcessCommandLine has_any (BadVersions) and ProcessCommandLine has "agent-framework"
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
),
(
DeviceFileEvents
| where TimeGenerated > ago(14d)
| where FileName =~ "sitecustomize.py" or FileName =~ "usercustomize.py"
| where FolderPath has "site-packages" or FolderPath has "dist-packages"
| project TimeGenerated, DeviceName, InitiatingProcessAccountName, ActionType, FileName, FolderPath, SHA256
)
| order by TimeGenerated desc;
// Hunt 2 (Sentinel Syslog/CEF): Look for package install events in Syslog-forwarded hosts (best effort, depends on logging)
let BadVersions2 = dynamic(["1.26.1","1.26.2"]);
union isfuzzy=true
(
Syslog
| where TimeGenerated > ago(14d)
| where SyslogMessage has "agent-framework" and SyslogMessage has_any (BadVersions2)
| project TimeGenerated, Computer, HostName, ProcessName, SyslogMessage
),
(
CommonSecurityLog
| where TimeGenerated > ago(14d)
| where Message has "agent-framework" and Message has_any (BadVersions2)
| project TimeGenerated, DeviceName, SourceIP, DestinationHostName, Message
)
| order by TimeGenerated desc;
Velociraptor VQL (Endpoint Forensics)
This artifact hunts for Python startup hook files and package metadata evidence. Run it across dev fleets and build agents where you suspect exposure.
-- Identify Python startup hook files and common credential locations presence (for scoping + triage)
SELECT * FROM foreach(
row={
SELECT FullPath, Size, Mtime, Ctime FROM glob(globs=[
'C:/Users/*/AppData/Roaming/Python/Python*/site-packages/*customize.py',
'C:/Users/*/AppData/Local/Programs/Python/Python*/Lib/site-packages/*customize.py',
'C:/Program Files/Python*/Lib/site-packages/*customize.py',
'/usr/lib/python*/site-packages/*customize.py',
'/usr/local/lib/python*/site-packages/*customize.py',
'/usr/lib/python*/dist-packages/*customize.py',
'/usr/local/lib/python*/dist-packages/*customize.py',
'/home/*/.local/lib/python*/site-packages/*customize.py'
])
},
query={
SELECT FullPath AS StartupHookFile,
Size,
Mtime,
Ctime,
'startup_hook_candidate' AS Finding
FROM source()
});
Containment and Remediation (Do This Now)
If you find any evidence of agent-framework 1.26.1 or 1.26.2 installed or executed, treat it as a credential exposure event.
- Remove the malicious versions immediately
- Pin to a known-good version (your internal artifact repository record, or a previously deployed lockfile).
- Purge caches (CI caches and local pip caches) to prevent re-install.
- Rotate credentials that could have been exposed
- Cloud IAM keys, session tokens, developer access tokens, and CI secrets.
- Prioritize: CI/CD credentials (often broad), then cloud credentials on dev machines, then any shared service accounts.
- Invalidate sessions and revoke tokens
- Force re-auth where possible (SSO session revocation, cloud role session invalidation, token revocation for CLI tools).
- Rebuild affected artifacts
- Rebuild containers and deployment artifacts produced while the malicious package was present.
- Redeploy from known-good dependency sets.
- Review cloud audit logs for misuse
- Look for unexpected role assumption, new access keys, unusual regions, or atypical API call patterns immediately after the exposure window.
- Harden against recurrence (supply chain controls)
- Require lockfiles and hash-checking (
pip install --require-hashesworkflows where feasible). - Route installs through an internal proxy/repo with malware scanning and version pinning.
- Enforce “no unknown versions” policy for build jobs (fail builds on unpinned or unapproved releases).
Verification Script (Windows PowerShell + Linux/macOS Bash)
Use these scripts to quickly verify whether the impacted versions are present and to flag startup-hook persistence files for review. They do not remove anything automatically; they’re designed for fast, safe triage across systems.
$ErrorActionPreference = 'SilentlyContinue'
Write-Host '=== Python presence ==='
Get-Command python, py, python3 -ErrorAction SilentlyContinue | Select-Object Name, Source | Format-Table -AutoSize
Write-Host '=== pip show agent-framework (if pip available) ==='
$pip = Get-Command pip -ErrorAction SilentlyContinue
if ($pip) { pip show agent-framework }
Write-Host '=== Startup hook files (sitecustomize/usercustomize) ==='
$paths = @(
"$env:APPDATA\Roaming\Python\Python*\site-packages\sitecustomize.py",
"$env:APPDATA\Roaming\Python\Python*\site-packages\usercustomize.py",
"$env:LOCALAPPDATA\Programs\Python\Python*\Lib\site-packages\sitecustomize.py",
"$env:LOCALAPPDATA\Programs\Python\Python*\Lib\site-packages\usercustomize.py",
'C:\Program Files\Python*\Lib\site-packages\sitecustomize.py',
'C:\Program Files\Python*\Lib\site-packages\usercustomize.py'
)
foreach ($p in $paths) {
Get-Item $p -ErrorAction SilentlyContinue | Select-Object FullName, Length, LastWriteTime
}
Write-Host '=== Recent pip cache references (best effort) ==='
$cacheRoot = Join-Path $env:LOCALAPPDATA 'pip\Cache'
if (Test-Path $cacheRoot) {
Get-ChildItem $cacheRoot -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match 'agent-framework' } |
Select-Object FullName, Length, LastWriteTime
}
set -euo pipefail
echo '=== Python presence ==='
command -v python || true
command -v python3 || true
echo '=== pip show agent-framework (if pip available) ==='
if command -v pip >/dev/null 2>&1; then pip show agent-framework || true; fi
if command -v pip3 >/dev/null 2>&1; then pip3 show agent-framework || true; fi
echo '=== Startup hook files (sitecustomize/usercustomize) ==='
for f in \
/usr/lib/python*/site-packages/sitecustomize.py \
/usr/lib/python*/site-packages/usercustomize.py \
/usr/local/lib/python*/site-packages/sitecustomize.py \
/usr/local/lib/python*/site-packages/usercustomize.py \
/usr/lib/python*/dist-packages/sitecustomize.py \
/usr/lib/python*/dist-packages/usercustomize.py \
"$HOME"/.local/lib/python*/site-packages/sitecustomize.py \
"$HOME"/.local/lib/python*/site-packages/usercustomize.py
do
if [ -f "$f" ]; then ls -l "$f"; fi
done
echo '=== Local pip cache references (best effort) ==='
if [ -d "$HOME/.cache/pip" ]; then
find "$HOME/.cache/pip" -iname '*agent-framework*' -maxdepth 6 -print 2>/dev/null || true
fi
Notes for Security Leadership (What to Tell Your CISO)
- This is a supply chain incident, not a “patch the server” event. The exposure is driven by where Python dependencies are installed and executed.
- The highest risk is usually CI/CD because it often holds privileged cloud credentials and runs code immediately after dependency installation.
- The minimum acceptable outcome is: (1) confirm whether the malicious versions were present, (2) prove whether they executed, and (3) rotate credentials if execution is plausible.
Related Resources
Security Arsenal Alert Triage Automation AlertMonitor Platform Book a SOC Assessment platform Intel Hub
Is your security operations ready?
Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.