bun
Techniques & procedures
40 distinct techniques documented for this family, organized by ATT&CK tactic.
Resource Development
1 technique
Resource Development
If not, it downloads the legitimate Bun runtime v1.3.13, and then executes the second-stage payload
Initial Access
2 techniques
Initial Access
StepSecurity reported a new coordinated npm supply chain attack targeting SAP development ecosystem packages. The attackers compromised multiple packages including mbt and @cap-js/sqlite.
The worm propagation logic mirrors Bitwarden attack with the same sequence: read npm tokens from .npmrc and the environment, validate each token, enumerate all packages the token can publish, inject the dropper into each package's preinstall hook, and republish as package-updated.tgz using Bun's native publish API.
Execution
12 techniques
Execution
Downloads the Bun JavaScript runtime v1.3.13 directly from its official GitHub release page. Launches the second-stage payload via Bun.
The implementation also follows HTTP redirects without validating the destination and uses PowerShell with -ExecutionPolicy Bypass on Windows, increasing the risk for affected developer and CI/CD environments.
Step 1 — init.py spawns a background subprocess on import... subprocess.Popen([sys.executable, _start], cwd=_runtime_dir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
Bun executed attacker-supplied JavaScript modules.
Native extension import trigger — Malicious code is embedded directly inside compiled .abi3.so extensions. The Python source appears clean, but the extension executes _index.js the moment Python loads the module via dlopen()
That '.bun' section is the actor’s payload container. This holds malicious JavaScriptCore bytecode for 'app.js'. When the assembled file runs, the Bun interpreter engine executes that embedded bytecode.
contains a hidden execution chain that silently downloads a JavaScript runtime (Bun) and executes an 11.4 MB heavily obfuscated JavaScript payload upon import lightning
Socket’s analysis revealed a hidden _runtime directory embedded inside the malicious packages containing a multi-stage execution chain that activates automatically when the module is imported, requiring no additional user interaction.
.pth startup-hook pattern — A malicious wheel bundles a *-setup.pth file alongside _index.js. The hook fires during Python startup, silently downloads the Bun JavaScript runtime, and executes the obfuscated stealer payload.
In the SAP wave, the compromised packages added a preinstall hook that ran setup.mjs... This wave uses a slightly different route... That Git dependency contains a prepare script: "scripts" : { "prepare" : "bun run tanstack_runner.js && exit 1" } This is the trick. npm runs lifecycle scripts for Git dependencies during installation.
MITRE ATT&CK Mapping Technique Description Campaign Application T1574.006 Hijack Execution Flow Bun runtime dynamically fetched from GitHub
The poisoned versions ship a preinstall hook: "scripts" : { "preinstall" : "node setup.mjs" }
Persistence
3 techniques
Persistence
The first branch is the .pth startup-hook pattern. A malicious wheel contains a *-setup.pth file and a bundled _index.js. The .pth hook runs during Python startup, downloads Bun if needed, and runs the JavaScript payload.
Identify Background Processes: Check for long-running processes (using the Bun runtime) that weren’t started by the user.
In the SAP wave, the compromised packages added a preinstall hook that ran setup.mjs... This wave uses a slightly different route... That Git dependency contains a prepare script: "scripts" : { "prepare" : "bun run tanstack_runner.js && exit 1" } | The compromised package also adds an optional dependency that points to a GitHub-hosted package... That Git dependency contains a prepare script: "scripts" : { "prepare" : "bun run tanstack_runner.js && exit 1" } This is the trick. npm runs lifecycle scripts for Git dependencies during installation.
Privilege Escalation
4 techniques
Privilege Escalation
The first branch is the .pth startup-hook pattern. A malicious wheel contains a *-setup.pth file and a bundled _index.js. The .pth hook runs during Python startup, downloads Bun if needed, and runs the JavaScript payload.
Identify Background Processes: Check for long-running processes (using the Bun runtime) that weren’t started by the user.
In the SAP wave, the compromised packages added a preinstall hook that ran setup.mjs... This wave uses a slightly different route... That Git dependency contains a prepare script: "scripts" : { "prepare" : "bun run tanstack_runner.js && exit 1" } | The compromised package also adds an optional dependency that points to a GitHub-hosted package... That Git dependency contains a prepare script: "scripts" : { "prepare" : "bun run tanstack_runner.js && exit 1" } This is the trick. npm runs lifecycle scripts for Git dependencies during installation.
From there, it pulls the GitHub authentication token and escalates privileges via sudo python3 before sending the collected credentials over an outbound HTTPS connection on port 443 to the attacker’s domain, t.m-kosche.com.
Stealth
11 techniques
Stealth
The malicious packages use preinstall hooks to download the Bun JavaScript runtime and execute an obfuscated payload.
The activity used update-themed staging and a renamed Bun executable.
The Bun binary is self-deleted after execution to reduce forensic traces.
At install time, the packages fetch a signed Bun runtime release from GitHub, execute an obfuscated JavaScript stealer under it, and delete the runtime.
Staged unpacking: The payload is unpacked through multiple decoding layers, including several ROT (rotate)-based obfuscation variants followed by AES-128-GCM decryption.
setup.mjs performs OS and architecture detection, then downloads Bun 1.3.13 from GitHub releases to execute the main payload.
.pth startup-hook pattern — A malicious wheel bundles a *-setup.pth file alongside _index.js. The hook fires during Python startup, silently downloads the Bun JavaScript runtime, and executes the obfuscated stealer payload.
In the SAP wave, the compromised packages added a preinstall hook that ran setup.mjs... This wave uses a slightly different route... That Git dependency contains a prepare script: "scripts" : { "prepare" : "bun run tanstack_runner.js && exit 1" } This is the trick. npm runs lifecycle scripts for Git dependencies during installation.
MITRE ATT&CK Mapping Technique Description Campaign Application T1574.006 Hijack Execution Flow Bun runtime dynamically fetched from GitHub
The poisoned versions ship a preinstall hook: "scripts" : { "preinstall" : "node setup.mjs" }
Instead, it delivers assembly instructions to the victim’s browser, retrieves a clean legitimate file from separate infrastructure, and directs the browser to build the final malware in memory on the victim’s machine.
Defense Impairment
1 technique
Defense Impairment
By running the payload outside of the standard node process, the attacker bypasses security tools and endpoint detection and response (EDRs) that specifically monitor Node.js child-process behavior.
Credential Access
3 techniques
Credential Access
Specifically, the program targets cloud infrastructure tokens across multiple developer environments. The payload queries the local Amazon Web Services metadata endpoints to steal container roles.
The staged Bun code ran gh auth token. It ran git credential-manager github list --no-ui.
Additionally, it extracts sensitive configuration secrets across 16 distinct AWS regions. In addition, the malware targets secrets stored inside HashiCorp Vault environments.
Discovery
5 techniques
Discovery
It checked for ssh and scp, enumerated running processes, and invoked a shell with a temporary updater.py path.
Platform detection — resolves a Bun binary name from a {platform}-{arch} matrix covering Linux, macOS, and Windows ARM and x64.
setup.mjs performs OS and architecture detection, then downloads Bun 1.3.13 from GitHub releases to execute the main payload.
Before downloading anything, it checks its cache for an existing TruffleHog binary; if none is found, it fetches the latest release info from GitHub, downloads the correct binary for the system, extracts it, and makes it executable.
...used the Bun JavaScript runtime, together with Microsoft Graph API, to enumerate users, SharePoint sites and mailboxes...
Collection
2 techniques
Collection
...used the Bun JavaScript runtime, together with Microsoft Graph API, to enumerate users, SharePoint sites and mailboxes before exfiltrating approximately 8.7 million files from 72 SharePoint subsites in about three days.
The compromised releases added a preinstall script that acts as a runtime bootstrapper, downloading a platform-specific Bun ZIP from GitHub Releases, extracting it, and immediately executing the extracted Bun binary.
Command and Control
3 techniques
Command and Control
All caused curl to contact GitHub and release-assets.githubusercontent.com during installation ... The payload spawned curl and downloaded Bun from GitHub release infrastructure.
The loader retrieves a legitimate Bun bundle directly from GitHub to execute a pre-bundled file hidden inside the tarball.
The dropper will detect the platform/architecture of the machine and download bun v1.3.13 directly from the official release page. It will extract bun, then use it to execute the payload.
Exfiltration
1 technique
Exfiltration
...before sending the collected credentials over an outbound HTTPS connection on port 443 to the attacker’s domain, t.m-kosche.com.
Recent activity
6 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.