A developer spots an AWS access key in a container image, moves its tag out of public view, and sees no downloads on the registry page.
That sounds like a close call, but the absence of a download count is a poor basis for deciding whether the key can stay active.

Overview
An experiment measured how soon an exposed key could be used
Stony Brook University researchers Billy Tsouvalas and Nick Nikiforakis placed instrumented images in public registries as part of their study of container credential exposure.
The authors report that one decoy AWS key was used in about eight seconds, with experiments involving 300 images across eight public container registries.
That is a measured result for their experiment, not a promise that every image attracts the same attention or that every provider counts downloads identically.
Removing the registry tag does not disable the credential
A container tag tells builders and users which image to retrieve, but the cloud provider decides whether an access key can still authorize a request.
Someone who has already copied the credential doesn’t need the image or tag again, so changing visibility cannot substitute for deactivation at the issuer.
The two actions still belong in the same response, because limiting access to the image helps avoid more copies while revoking credentials blocks future use.
A clean replacement image and a clean account are separate results
Docker’s documentation warns that build arguments and environment variables can persist in an image, so ordinary build conveniences aren’t a safe way to pass secrets.
- Identify the exposed credential by its key ID and owning account, without copying its secret value into a ticket or message.
- Check the issuing service for use, permissions, and charges, because the registry can’t show what happened after someone obtained the key.
- Build a replacement without embedded secrets, then verify every deployed workload uses that version and an approved credential source.
Why an Image Is Not the Same as the Folder You See
An image can consist of multiple layers, each capturing changes from part of the build, rather than a single snapshot of the final visible files.
Deleting a credentials file in a later build instruction can hide it from the final file view without removing it from a previously exported layer.
A secret can also be present in a bundled archive, copied configuration, generated cache, or metadata even when it isn’t beside the application executable.
That difference explains why starting a container and looking around its visible working directory is not enough to prove the published artifact contains no secrets.
An image built from a cleaned repository can still pick up a directory from the build context that never appeared in the source control change.
If you add a rule to exclude local configuration, make it part of the build review so a future pipeline change cannot silently undo it.
What the Eight-Second Result Should Change
If a secret was published, treat the exposure as something that already happened rather than waiting until a download counter starts moving.
The study’s fastest observation was not the timing of every experiment, but it demonstrates why a team cannot depend on pulling an image before anyone notices.
A registry’s number may also exclude ways an image is copied or may update after the work your team needs to do has already started.
Use the publication timestamp as the earliest possible exposure for that artifact, and check whether an earlier version carried the same secret.
Ask when the credential was created and where it has been used, because that information can explain activity before the first public image was released.
For a service with more than one credential, verify exactly which keys or tokens were present rather than rotating only the first one somebody saw.
The operational objective is to stop affected credentials being accepted, not to make a tag disappear or make the registry counter look reassuring again.
Make the First Decision Before Rebuilding Anything
Use a separate, trusted administrative session to open the cloud account rather than signing in with the exposed credential or using the published container.
An account owner should determine whether the key belonged to an IAM user, the account root user, or a temporary session with different containment steps.
When you see active abuse, disable the affected access under your incident plan immediately, even if a service that depends on the key may briefly fail.
If there is no sign of current abuse and the response lead approves a short overlap, move the necessary workload before deactivating the old key.
The overlap should have an owner and a deadline, not become an indefinite period when both a replacement and a publicly exposed key still work.
Most applications running on AWS can use temporary credentials from a role, which avoids storing a durable access key in the rebuilt artifact.

How to Contain an AWS Key Exposed in an Image
Step 1: Identify the affected key in the right account
Record the registry, repository, tag, image digest, and publication time so the build team can identify the exact artifact without sharing the secret value.
Sign into the owning AWS account using an authorized administrative identity, then open IAM and select Users if the key belongs to a user.
Choose the user, open Security credentials, and match the access key ID in Access keys to the identifier in your private incident record.
If you can’t match the key confidently or think it belongs to the root user, bring in the account owner instead of deactivating an unrelated credential.
Step 2: Deactivate the matching key and verify its status
In the Access keys section, select Actions beside the matching key and choose Deactivate when the incident lead has authorized that change.
Confirm the deactivation in the dialog and verify the status now shows that the key is inactive, using the current account and user details.
The AWS IAM key update guidance distinguishes deactivation from deletion, which is permanent and should follow your team’s response process.
If the key belongs to root, have the account owner open Security credentials, match the key ID, and use Actions to deactivate it.
Step 3: Review cloud activity instead of relying on the registry
Open CloudTrail, select Event history, use the access key ID filter, and compare the results with the expected jobs from the exposure window.
Check relevant AWS Regions and accounts, because CloudTrail Event history shows recent management events for the one Region and account being viewed.
Download the relevant event records into approved storage, and separately review trails, service logs, and cost reports where configured and relevant to the key’s permissions.
If data access logging was not enabled, record that limitation instead of interpreting the absence of relevant events as proof that no data was read.
Step 4: Remove the build path that placed the secret in the image
Stop new pulls where you can after preserving the evidence your responders need, and tell owners of caches, mirrors, or downstream builds which digest was affected.
Replace the image with a build that gets runtime access separately, ideally through a role rather than another durable key placed in configuration.
For build-time authentication, use Docker’s temporary secret mount mechanism and ensure the build does not copy its contents into published outputs or logs.
Test the rebuilt artifact and deploy by its approved digest, then verify that jobs no longer depend on the deactivated credential before deleting it permanently.
What to Do If You See Requests You Cannot Explain
- Notify your incident lead promptly with the key ID, affected account, first known image publication time, and the kinds of access the key could authorize.
- Preserve representative cloud actions, relevant source addresses, request times, resource identifiers, and any cost changes in a private location approved for incident records.
- Check for unexpected changes to users, permissions, jobs, storage, and other resources that the old key could reach without altering suspected evidence.
- Escalate unusual spend or actions to your cloud account team and AWS Support through a known route, not a link in an unexpected email.
- Check whether other secrets were packed into the same artifact or copied into related builds, and contact each issuer for the applicable revocation steps.
- Verify which artifacts are now deployed and which credentials are inactive before telling downstream teams they can resume normal use.
Why Billing Can Change After the Image Is Gone
An exposed key may grant access to paid services, so an incident can show up as charges even when the application keeps working normally.
Start with the services and Regions the credential could reach, then compare the unusual usage with known builds, test jobs, or scheduled business work.
Set the billing viewer to the right account or project before drawing conclusions, especially if several developers share a central bill for separate environments.
Monitor the account after containment, since new charges for previous requests can appear later and do not necessarily mean the disabled key is still working.
If an old key created a new identity or changed permissions, disabling the original key would not automatically remove those changes from the account.
For that reason the investigation should document unexpected resource and identity changes, not just confirm that the original credential has stopped working.
Make the Replacement Build Pass a Different Test
The replacement is ready when the team can explain where build-time and runtime access come from without pointing to secret values inside the image.
Inspect both the build recipe and the outputs it publishes, because a temporary secret mount cannot protect a value that the build deliberately writes into a file.
Treat logs, caches, and artifact exports as separate places to check, particularly if your pipeline shares results between builds or stores useful output for later debugging.
Scan an image you control with an approved tool before publication, and confirm the check covers its layers and configuration rather than only the app directory.
If runtime authentication uses a role, keep those permissions limited to the workload’s job so a later misconfiguration does not grant unnecessarily broad access.
Limit the Permissions of the New Workload Identity
Credential rotation is a good time to question whether a build that only reads packages needs write or administrative access to the same account.
Review the actions it legitimately used before exposure, then narrow the new role to the resources required by ordinary setup or deployment work.
Ask a different owner to verify that the application can still do its job without relying on broad permissions that were convenient during development.
Test a denial on a resource the workload shouldn’t be able to change, using a safe test target and avoiding production data.
Record when old build artifacts and local caches stop being needed, then dispose of them under the same evidence retention policy as the incident.
Finally, note what would trigger another investigation, such as a recurring request from an unexpected identity or a newly discovered image carrying the same value.
Frequently Asked Questions
Did every exposed key get used in eight seconds?
The fastest observed use was about eight seconds, but that timing is an example rather than a forecast for any specific published image.
Your response should not depend on getting a few quiet minutes, because tags and download counters cannot invalidate a credential at the cloud provider.
Is hiding or deleting the tag enough?
No registry change stops a credential that has already been copied from authorizing requests, so you need to address the credential with its issuer.
Restrict the vulnerable artifact too, but verify the old key’s inactive or revoked status from the owning account before considering containment complete.
Does removing a file near the end of a Docker build fix the original exposure?
A later deletion can hide the file from the final view without removing its data from an earlier layer that was already included.
Rebuild without copying the secret into any published layer, and address the exposed value separately even if the new artifact contains no copy.
Should I sign in with the exposed key to see whether it works?
Use an authorized administrative identity to check and change the credential’s status, rather than trying the disclosed key or running an untrusted build.
This makes it easier to preserve the investigation timeline and avoids accidentally spreading the secret to another machine, log, or terminal history.
Why does CloudTrail Event history show no suspicious activity?
Event history is limited to management events for the selected account and Region, and it won’t show all possible data access or cost changes.
Check whichever other trails and service logs your organization had enabled, and let responders record any gaps that prevent a firm conclusion.
Should I keep a permanent key for the rebuilt service?
Where your workload supports AWS roles, use temporary credentials and grant only the actions the workload actually needs to perform.
If an application still requires a key, manage it outside the image through an approved secret store and remove the previous key after containment.
The Bottom Line
Treat a credential inside a published image as exposed, even when the pull count is empty, and disable or revoke it in the issuing service.
Then inspect the account for unexpected access and rebuild without embedded secrets, because a clean image doesn’t undo whatever happened before the key was stopped.
Join the discussion
0 commentsShare your experience or ask a question about this article.
Discussion
Start the conversation
Have a question or something useful to share? Add the first comment.