What happened
Replaying the npm April 2022 intrusion
- 1
Tokens taken from the integrators
Apr 7, 2022; the rest not datedA compromised Heroku machine-account token opens Heroku's databases and the GitHub OAuth tokens stored in them; Travis CI's app tokens are stolen too, by a route no source reconciles.
- 2
Private repositories on GitHub
From Apr 8, 2022The GitHub API accepts the stolen OAuth user tokens; the actor lists organizations and private repositories and clones some of them, Heroku's on April 9 and npm's on a date no source gives.
- 3
An AWS key from the source code
Not dated; detected Apr 12, 2022An AWS access key found in npm's private repositories is presented to the AWS API and accepted; which principal it belonged to and from which network it was used are not stated.
- 4
npm's data in AWS
Not datedWith the key the actor exfiltrates a skimdb.npmjs.com backup with a 2015 archive of about 100k npm users, the S3 inventory files and private packages of two organizations; GitHub is confident that no published package is modified.
- 5
Detection and revocation
Apr 12 – Jun 2, 2022GitHub detects the AWS access on April 12, GitHub, Heroku and Travis CI revoke the apps' tokens, and GitHub notifies the affected organizations and npm users.
In npm's AWS infrastructure the actor exfiltrated a backup of package metadata as of April 7, 2021 that held a 2015 archive of about 100k npm usernames, password hashes and email addresses, the S3 inventory files that list private package names and versions, and a small subset of the private packages of two organizations. GitHub is confident that no published package was modified. At Heroku the actor also took hashed and salted customer passwords and pipeline config vars, some of which held Heroku tokens.
Where cloud-provider controls fit
The OAuth tokens, the integrators' databases and the cloned repositories sat in Heroku, Travis CI and GitHub, outside every cloud provider. The chain met AWS only when an access key copied from npm's source code was presented to the AWS API. On your clouds you can refuse new long-lived keys, so a repository gets none to leak after the policy stands: a service control policy on AWS, an Organization Policy constraint on Google Cloud, an application management policy on Microsoft Entra. You can bind a key to your own networks, with a service control policy on AWS and an IAM policy network source on Oracle Cloud, and cap what a stolen key reads in storage with a resource control policy, a permissions boundary and a KMS key policy. GitHub said on April 15, 2022 that it believed no npm user data was accessed, and on May 26, 2022 reported the 2015 archive of about 100k users. No source says when the key was first used or whether it was rotated.
Could this have been prevented?
In hindsight, not as a whole. 1 control would have refused a step outright, and 8 controls would have limited one. 7 steps have no cloud-provider control. The counts below are control assessments, not attack stages: several can address the same step. The same replay with the controls in place before the incident shows where each phase would have been refused or bounded.
- 1
- Prevented
- 8
- Contained
- 7
- Not covered
How it could have been prevented
The same replay with the controls in place. Green marks where a step is refused, blue where it is bounded, and red where no control reaches it. Open a row to read the control, why it acts, and its caveat.
Replaying the npm April 2022 intrusion
1 · Tokens taken from the integrators
3 Not covered2 · Private repositories on GitHub
2 Contained2 Not covered3 · An AWS key from the source code
1 Prevented3 Contained1 Not covered5 on other clouds4 · npm's data in AWS
3 Contained3 on other clouds5 · Detection and revocation
1 Not coveredKey facts
- On April 7, 2022 the actor used a compromised Heroku machine-account token to download the GitHub integration OAuth tokens that Heroku stored for its customers; Heroku believes the token came from an archived private repository, by an integration it could not confirm
- GitHub listed five abused OAuth apps, four Heroku Dashboard apps and Travis CI, whose user tokens were used to download private repositories of dozens of organizations, npm's among them; GitHub gave no count
- One AWS access key found in npm's private repositories opened npm's AWS infrastructure; GitHub Security detected the access on April 12, 2022, and no source says when the key was first used or whether it was rotated
- On April 15, 2022 GitHub said it believed the actor had not accessed npm user account data or credentials
- On May 26, 2022 GitHub reported that the actor had exfiltrated a backup holding a 2015 archive of about 100k npm usernames, password hashes and email addresses, the S3 inventory files and private packages of two organizations
- Heroku dated its revocation of all Heroku Dashboard GitHub integration tokens April 15, 2022 in its incident review, and its status page reported it complete at 00:00 UTC on April 17, 2022
Sources
Every fact in this breakdown comes from the public reporting below. The replay is a model of that reporting, not a reconstruction of the environment it describes.
- 1.Security alert: Attack campaign involving stolen OAuth user tokens issued to two third-party integratorsGitHub · Apr 27, 2022 · Vendor reportDetection on April 12, 2022, the AWS API key pivot into npm, the five affected OAuth apps, token revocation, the attacker's API sequence, the April 15 statement on npm user data, notifications
- 2.npm security update: Attack campaign using stolen OAuth tokensGitHub · Jun 2, 2022 · Vendor reportThe AWS access key in npm's repositories, data exfiltrated from npm's AWS infrastructure and S3, the 2015 archive of about 100k users, package integrity, password resets and notifications
- 3.Heroku Security Notification (incident 2413)Heroku (Salesforce) · Jun 14, 2022 · Status pageThe machine-account token and the token database download on April 7, 2022, enumeration from April 8, Heroku's repositories on April 9, revocation complete on April 17, password resets, config vars
- 4.April 2022 Incident ReviewHeroku (Salesforce) · Jun 14, 2022 · Vendor reportHow Heroku believes the machine-account token was obtained, its dated timeline, revocation on April 15, 2022, remediation
- 5.SECURITY BULLETIN; Customer repositories have NOT been accessedTravis CI · Apr 18, 2022 · Vendor reportTravis CI's account of the theft and its key revocation
- 6.GitHub saved plaintext passwords of npm users in log files, post mortem revealsThe Register · May 27, 2022 · NewsGitHub's ownership of npm and corroboration of the data accessed
The estate in the replay is illustrative and drawn at the level of attack stages; the victim's real environment is not public. Verdicts describe what a control does when it is in place before the incident. They are not an assessment of the victim's security program.