Latest / Decrypted: The UK Cyber Briefing / A GitHub comment was all it took to hijack a trusted npm release
Transcript
- 0:03This is Decrypted. Tuesday, the first of September.
- 0:06A GitHub comment was all it took to hijack a trusted npm release.
- 0:11A package called @7nohe/openapi-react-query-codegen is pulled into roughly 671,000 builds a month.
- 0:22This week, it spent four days shipping malware to anyone who installed it.
- 0:27And nobody stole a password to make that happen.
- 0:30They found a release workflow that would publish a new version whenever someone commented the words "npm publ
- 0:37ish" on a pull request. It never checked who was doing the commenting.
- 0:42Next. The workflow that trusted the wrong thing.
- 0:46Modern npm publishing is supposed to be safer than it used to be.
- 0:50Instead of a long-lived secret token sitting in a repository's settings, waiting to be leaked, many projects
- 0:57now use what's called trusted publishing.
- 1:00GitHub issues a short-lived credential to a workflow.
- 1:04npm checks it came from the right repository.
- 1:07And the package gets a cryptographic provenance record saying so.
- 1:11It's a genuine improvement on the old model.
- 1:14But that only holds if the workflow receiving the credential is itself trustworthy.
- 1:19This one listened for comments on pull requests.
- 1:22The moment it saw the phrase "npm publish", it checked out the pull request's code, built it and published it
- 1:30, all under the repository's verified identity.
- 1:33It never asked whether the commenter had any right to trigger a release.
- 1:38According to Socket's research team and a separate technical writeup from StepSecurity, an outside account o
- 1:45pened two pull requests and added obfuscated code.
- 1:49Then it simply commented the trigger phrase.
- 1:52Ten malicious versions went out on 28 August.
- 1:56Each carried a valid, cryptographically signed provenance attestation.
- 2:00The signature was true, even though the authorisation behind it was fiction.
- 2:05The payload harvested GitHub tokens, cloud credentials and S S H keys from anyone who ran npm install.
- 2:14And finally. The lesson isn't that npm is broken.
- 2:18It's that a security control aimed at one failure mode, leaked long-lived tokens, can leave a different door
- 2:25wide open. Who gets to ask for a fresh token in the first place?
- 2:29Provenance and signed attestations tell you a release came from the workflow it claims to.
- 2:35They tell you nothing about whether that workflow's own logic was sound.
- 2:39So if you run C I and C D in a UK team, here's the practical question.
- 2:45It's not "do we use trusted publishing?
- 2:48" It's "can anything an outsider types, in a comment, an issue title or a pull request, cause a privileged job
- 2:56to run?"
- 2:59Restricting release triggers to accounts with write access.
- 3:03And never checking out untrusted pull request code inside a job holding a publishing credential.
- 3:09That was Decrypted. The written version and every source are linked in the show notes.
- 3:14Thanks for listening.