HelpnetSecurity

Bots exploited leaked AWS key from Docker image in under 8 seconds


A cloud access key left inside a newly published Docker image can be found and used by bots in less than eight seconds, Billy Tsouvalas and Nick Nikiforakis of Stony Brook University discovered after planting 300 decoy images on public container registries.

Docker images are packaged copies of software, bundled with everything needed to run it, and developers publish them to public registries such as Docker Hub, which hosts over 14 million of them, so others can download and use them.

Passwords and API keys left in these images have been studied before, and an earlier analysis of over 300,000 images, cited in the paper, found some type of secret in 8.5% of them. Tsouvalas and Nikiforakis wanted to know who goes looking for those secrets and what they do with them.

Over four months, they published 300 copies of the official nginx image on eight registries, including Docker Hub, Amazon ECR and Red Hat Quay. Each copy held decoy AWS, OpenAI and Anthropic API keys.

The images were not advertised anywhere, but the AWS keys still received over 140,000 API calls from more than 5,000 IP addresses, and the OpenAI and Claude keys were drained of their entire balances. The researchers call the scanners behind this activity “ContainerBots.”

“In effect, publication and compromise are, for practical purposes, the same event,” they wrote.

Keys used within minutes

In the first round, all 100 images went to Docker Hub. More than half of the AWS keys were used within a minute of publication, 93% within five minutes and all of them within 15 minutes. The median time to a first call was 51 seconds, and the fastest call came 7.86 seconds after the image was pushed.

Docker Hub’s pull counter lags behind actual downloads by about 5 to 6 minutes. “This means that even a vigilant image owner monitoring their own pull count cannot react before a leaked credential has already been used,” the authors noted.

Bots skip running the images

Each image also had hidden callbacks that would alert the team if someone built a container from it, ran it or opened a shell inside it. None fired in the first round, and only three fired in the second round of 200 images.

The researchers used their observations to reconstruct the likely workflow. A bot queries a Docker Hub catalog endpoint that lists recently published or updated images and fetches each image’s manifest.

The manifest includes the build history, so the bot can tell which layers, the stacked pieces an image is built from, probably hold credentials. It downloads just those layers, unpacks them and searches the files for strings that look like keys or login details, and the whole thing takes a few seconds.

Keys tested first

Almost every bot started by asking AWS a simple “who am I” question to see whether a key worked, and about half of the IP addresses stopped there.

The OpenAI and Claude keys followed what the researchers call a validate-wait-exploit pattern. OpenAI keys saw small bursts of use after each image push, then went quiet for several weeks.

About a month after the last push, a single key received 143 requests in under 24 hours, burning through over 18 million input tokens and emptying the account. The Claude keys were drained in a single day after the image update on day 8.

“We speculate that the wait phase reflects validated keys being resold and held idle until a buyer eventually uses them,” the paper reads.

In the second round, some OpenAI and Anthropic keys had locked-down permissions, and none of them were used to consume tokens. “Not a single Restricted key received any token-consuming call, indicating that scanners are able to discriminate between Open and Restricted permissions,” the researchers wrote.

Sensitive names draw more pulls

The second round spread 200 images over eight registries and varied their names. Some had bland names like “silverporgy/bait-tin-stack,” and others hinted at sensitive infrastructure, such as “policyengine/classified-rule-store.”

On Docker Hub, the second group drew more than double the pulls per image, and the difference grew after every update. The paper suggests that a share of the bots favor “images whose namespaces and names evoke high-value, sensitive infrastructure.”

Proposed fixes

The researchers propose two changes that registry operators could make on their own. The first is to scan images for known key formats when they are pushed and warn the uploader. “This would not solve the problem, but it would close the overwhelmingly common case of accidental disclosure,” they wrote.

The second targets the Docker Hub catalog endpoint that lists the newest images. Legitimate users of that feed, such as CI/CD pipelines and registry mirrors, usually have authenticated access already, so the authors suggest requiring authentication, adding per-account rate limits or limiting what the endpoint shows publicly.

“The design question is whether a publicly unauthenticated list of ‘newest image’ metadata is actually necessary,” they wrote.

When the paper was written, Docker had acknowledged the disclosure and its security team was reviewing the findings.

The experiment cost about $60 in OpenAI and Anthropic credits, all of it spent by attackers. “While we recognize that making funds available to underground ecosystems is less than ideal, we could not have learned about the behavior of attackers without these keys,” the researchers concluded.



Source link