StepSecurity Details Malware in Red Hat Cloud Services npm Packages

· Original article ↗

Summary

StepSecurity reports malicious npm releases that execute at install time, harvest credentials, and can republish backdoored packages. Its analysis describes the malware’s techniques, affected versions, and remediation advice.

Key points

  • StepSecurity says multiple @redhat-cloud-services npm packages contained malicious versions with a preinstall script that runs before application code.
  • The analysis describes a four-layer obfuscation chain and a 4.2 MB install script; the payload targets secrets in GitHub Actions runner memory and credentials across cloud, developer, and package-registry environments.
  • Using stolen npm tokens, the malware attempts to publish trojanized packages and uses npm’s bypass_2fa parameter to evade two-factor requirements.
  • The malware uses api[.]github[.]com for C2 and can place encoded stolen data in victim-controlled GitHub repositories.
  • The payload also installs Claude Code SessionStart and VS Code folderOpen hooks for persistence; StepSecurity advises affected users to assume compromise and rotate exposed credentials.
  • StepSecurity says Harden-Runner detected and stopped a runner-memory access attempt in its test workflow; it also published affected package versions and disclosure issues for upstream repositories.

Article Details

Attack Vectors
  • Compromised @redhat-cloud-services npm packages execute a preinstall script (`node index.js`) automatically during `npm install`, before application code runs.
  • The article says the affected packages were published through GitHub Actions OIDC from the RedHatInsights/javascript-clients repository, indicating a compromised upstream CI/CD pipeline.
  • The payload reads Runner.Worker process memory and queries the GitHub Actions runtime API to locate masked secrets, then sweeps credentials and key files from developer and CI environments.
  • Using harvested npm tokens, the malware attempts to publish trojanized package versions with npm's `bypass_2fa` parameter, enabling self-propagation.
  • The malware uses GitHub API traffic for C2 and creates refs and commits containing base64-encoded stolen data in victim-controlled repositories for exfiltration.
  • The payload adds a Claude Code SessionStart hook and a VS Code folderOpen task to trigger attacker-controlled code during normal developer workflows.
  • The JavaScript payload uses multiple obfuscation layers, including ROT-21 encoding, AES-128-GCM encrypted blobs, a rotated custom-base64 string table, and a custom B5 cipher. The article says C2 domain recovery is still in progress.
Defensive Notes
  • If an affected package version was installed, treat the CI/CD environment or developer machine as compromised and rotate exposed credentials immediately.
  • Review environments that installed the listed malicious package versions, including CI/CD pipelines and developer machines, for credential exposure and persistence.
  • StepSecurity reports that Harden-Runner can monitor process, network, and file activity in GitHub Actions and initiate lockdown when it detects the malicious process reading runner memory.
  • The article recommends using an npm package cooldown window and compromised-package checks to delay or block newly published malicious versions.

MITRE ATT&CK

T1003.007 · Proc FilesystemThe payload reads `/proc/<pid>/mem` to extract secrets from the Runner.Worker process memory.T1005 · Data from Local SystemThe payload collects credentials and other sensitive files from the local filesystem, including cloud, registry, SSH, Docker, and GPG data.T1027 · Obfuscated Files or InformationThe payload uses multiple layers of encoding, encryption, string-table rotation, and a custom cipher to conceal its code and strings.T1059.007 · JavaScriptEach package's preinstall script runs `node index.js` to execute the JavaScript payload during npm installation.T1071.001 · Web ProtocolsThe article reports that C2 traffic uses HTTPS requests to the GitHub API.T1102.002 · Bidirectional CommunicationThe payload uses GitHub as a covert C2 and dead-drop channel, including API-based communication and data placement in repositories.T1119 · Automated CollectionThe payload automates a broad sweep for credentials across CI, cloud, package registry, developer-tool, and local-file sources.T1195.002 · Compromise Software Supply ChainMalicious versions were distributed through compromised npm packages; the article says they were published via GitHub Actions OIDC from the affected upstream repository.T1546 · Event Triggered ExecutionThe malware establishes event-triggered execution by injecting a Claude Code SessionStart hook and a VS Code folderOpen task.T1552.001 · Credentials In FilesThe malware searches credential-bearing files including `.npmrc`, `.aws/credentials`, `.kube/config`, `.pypirc`, and `.env` files.T1552.004 · Private KeysThe credential sweep targets SSH private keys, including `~/.ssh/id_rsa` and `~/.ssh/id_ed25519`.T1567.001 · Exfiltration to Code RepositoryThe malware exfiltrates base64-encoded stolen data by creating refs and commits through the GitHub Contents API in victim-controlled repositories.

Vendors

Products

Tools

Related Articles