Stolen tokens: Secret stealer targets thousands of GitHub repositories | heise online

Stolen tokens: Secret stealer targets thousands of GitHub repositories

Attackers use hijacked GitHub accounts to install backdoors in AWS and Azure. Rotating secrets alone is not enough.

listen Print view
GitHub logo on a building wall

(Image: Sundry Photography / Shutterstock.com)

5 min. read
By
  • Robert Lippert

Since Tuesday, unidentified attackers have been using stolen GitHub account access tokens to inject malicious code into repositories and steal secrets from GitHub Actions and cloud credentials.

Security firm Aikido has counted 4,837 compromised accounts in the campaign it dubbed wfx-loot. The attackers have used them to target 61,764 repositories. In more than 1,800 cases, workflows have reportedly already executed the malicious code.

The attackers do not appear to be exploiting a vulnerability in GitHub Actions. Instead, they are abusing the write permissions of stolen tokens. The tokens’ origins are only partly clear. According to Fly.io, attackers abused tokens for its GitHub app that came from publicly accessible .git/config files; the hosting provider is revoking them. GitHub has not yet commented.

Security firm SafeDep has already found malicious-code commits in more than 8,000 public repositories. As of Thursday at noon, GitHub search still listed more than 66,000 of the characteristic test pull requests, about 4,300 of them from that same day.

As in the recent testmetest worm incident, attackers are also reaching repositories that do not belong to the compromised accounts themselves, Aikido says, using collaborator and organization permissions and more than 10,000 test pull requests. This can also affect organizations whose own credentials were not stolen. If a repository’s workflows can access AWS or Azure, the malicious code uses the stolen credentials to set up backdoors in those cloud accounts.

The attackers give their victims little time to react. First, they open a pull request to confirm their write permissions. Then comes the actual malicious code: a shell script that the attackers insert into an existing workflow, add as a new workflow, or configure to run with every installation in npm projects.

Often within a minute, the attackers undo the changes and delete the workflow run along with its logs. A missing run number is often the only sign of the attack. Branch protection requiring status checks can be bypassed by the script using forged success messages. Aikido says the script does, in fact, submit such fake status checks; that feature was not enabled in the samples SafeDep examined.

Attackers first use a stolen token to test their write permissions, then inject the stealer in one of three ways and undo the change.

(Image: SafeDep)

Along with tokens for AI services such as OpenAI, Anthropic and Cursor, the injected script primarily harvests secrets from GitHub Actions, as well as credentials for cloud services, container environments, package registries and SSH.

Once the threat actors gain access to sessions at AWS, Google Cloud and Azure, the attack continues. At AWS, the script opens an IAM role for each AWS account. In Azure, it adds extra authentication paths for workflows from the compromised repository. In this campaign, the script sent stolen data over HTTP to the attackers’ servers, according to Aikido. SafeDep also found exfiltration via Telegram in the payloads it examined.

Videos by heise

Developers who find a wfx-docs branch, the docs: dependency audit notes pull request, or commits such as ci: refresh build cache, chore: add ci helper and chore: add dependency audit workflow in their repositories since Tuesday should consider the associated account compromised, even if no malicious code followed. According to Aikido’s security researchers, short-lived branches that begin with chore/ and end with eight random characters are also suspicious. Those affected should revoke their account tokens, OAuth authorizations and SSH keys.

If malicious code has already run, victims must also remove the backdoors themselves in addition to rotating secrets — for example, AWS roles that trust any account, or Azure Federated Credentials with the prefix wfx-ci-. Anyone who ran npm install on an affected commit must also consider their own computer compromised.

The malicious code also made its way into package distributions. Aikido names the Packagist package digitalelvis/neuronai-studio 3.14.3, as well as Go module versions github.com/onuragtas/docker-env v1.0.278 and v1.0.280. SafeDep also lists github.com/onuragtas/redock, another docker-env version, and a pseudo-version of github.com/vkuznet/gocurl available through the Go module proxy. In the Go modules, the malicious code is in a GitHub Actions workflow file; a standard Go build does not run it. Anyone who includes such a module only as a Go dependency is probably not affected.

(mro)

Don't miss any news – follow us on Facebook, LinkedIn or Mastodon.

This article was originally published in German. It was translated with technical assistance and editorially reviewed before publication.