A published wheel on PyPI contained an internal API token and you deleted the file — is the credential contained?
answer
- the wrong object is being fixed
- rotate before you tidy up
- assume it was scraped within minutes
- your own proxy still has a copy
- the filename is burned forever
basics
~20 sNo. Treat the token as public from the moment it was published and revoke it first. Deletion never reaches mirrors, caching proxies, local caches or anyone who already downloaded the file, and the filename can never be reused.
solid answer
~50 sDeletion is tidying, not containment. The moment the file was served publicly it was mirrored, cached and very likely indexed by automated scrapers, so the only control that ends the exposure is revoking and rotating the credential — that comes first, before any registry action. Then audit what the token could reach and what it did reach while it was live, on the assumption it was used. Only after that do you clean up the publication: PyPI will never accept the deleted filename again, so the replacement ships under a new version number rather than a re-upload. Expect a copy to still be sitting in your own organisation's caching proxy, which does not purge because upstream deleted. Finally, fix the cause — the token got in because the release was built from a tree that contained it, so a secret scan on the release artifact before publish is the durable control.
go deeper
Know the reflex: a secret that was ever published is public, so the first action is revoking it, not deleting the file that carried it.
Explain why removal does not propagate — mirrors, caching proxies and local caches keep their own copies — and that a deleted filename can never be reused, so the fix needs a new version.
Show the ordered response: revoke, then check the credential's access logs for use, scope what it authorised, clean up the publication, purge internal caches, and add a secret scan on the built artifact.
Own the framing that withdrawal acts on artifact availability while a leak is about secret validity, and set the release policy that follows — short-lived publishing credentials, clean-room release builds, and a rehearsed rotation path.
## The question behind the question An interviewer asking this wants to see whether you rank your response steps by what actually reduces risk, or by what feels like undoing the mistake. Deleting the file feels like undoing it. It is not. ## Why deletion contains nothing A public registry is a globally distributed, aggressively cached, continuously scraped surface. Between publication and deletion the artifact will have been copied into: - **public and regional mirrors**, which sync on their own schedule and may not propagate a deletion at all; - **organisational caching proxies**, which exist precisely so that upstream availability stops mattering — they hold their own bytes and do not purge because upstream removed something; - **CI and developer machine caches**, thousands of them, holding the file for as long as their eviction policy says; - **automated scrapers**, including the ones specifically watching new package publications for exactly this kind of leaked credential, which is not a hypothetical activity; - **anyone who simply downloaded it.** None of these has any obligation to notice your delete. So the correct assumption is the strict one: **a secret that was public for one minute is public forever.** ## The response order that matters 1. **Revoke and rotate the credential.** This is the only step that changes what an attacker can do. Do it before you touch the registry, because time-to-revoke is the metric that decides how much of this becomes an incident. If the token cannot be revoked without breaking something, that is an argument for fixing the dependency on it under pressure, not for delaying. 2. **Investigate use.** Assume it was used. Check the authentication and access logs of whatever the token reached, over the window from publication to revocation, and look for access from unfamiliar sources. What you find determines whether this stays an internal cleanup or becomes a customer-affecting incident with its own disclosure obligations. 3. **Scope the blast radius.** What did that credential authorise — read of an internal service, write to a registry, an ability to publish? A publishing credential is the worst case, because it converts your own leak into a mechanism for someone else to ship a malicious version under your name, and that turns a housekeeping problem into a downstream one. 4. **Clean up the publication.** Now delete or withdraw the file. It is still worth doing: it removes the easiest copy to find and stops new consumers pulling the artifact. Just do not book it as containment. 5. **Publish a clean replacement.** Under a new version number. PyPI does not allow a deleted filename to be uploaded again — the rule exists so a filename that a mirror or a lockfile recorded can never later resolve to different bytes. That immutability is a property you want; it just means "delete and re-upload the fixed file as the same version" is not an available move anywhere that takes integrity seriously. 6. **Purge your own caches.** The copy inside your organisation's caching proxy is the one you can actually do something about, and it is the one most likely to be pulled by an internal build tomorrow. 7. **Fix the cause.** The token was in the artifact because the artifact was built from a tree that contained it, or because the packaging configuration swept in a file it should not have. The durable controls are scanning the built artifact for secrets before it is published, building releases from a clean checkout rather than a developer's working tree, and being explicit about what goes into the distribution rather than relying on exclusion rules. ## Why deletion can even be counterproductive Two effects worth naming. First, deleting the file breaks any build that pinned it, so a leak in a widely adopted version turns into an availability event for consumers who had nothing to do with it — you have traded their uptime for containment you did not actually get. Second, a sudden deletion is itself a signal: it draws attention to the version and invites someone to go look at the copy their proxy still holds. Neither is a reason to leave a live secret published; both are reasons to have already revoked it before the deletion draws eyes. ## The distinction to state out loud Withdrawal controls act on **availability of the artifact**. A leaked credential is a problem of **validity of the secret**. They operate on different objects, so no amount of the first fixes the second. The same logic generalises: if the published artifact contained malicious code, withdrawal likewise does not remove it from anyone who has it, and the response is an advisory that reaches consumers plus whatever server-side revocation the code's capabilities imply. ## What a weak answer sounds like "We deleted the file and re-uploaded a fixed one, so we were fine." That answer gets two things wrong at once — the secret was never contained, and the re-upload under the same filename is not permitted precisely because identifiers must stay immutable.
- Why can't you simply re-upload the corrected file under the same filename and version?PyPI permanently refuses a deleted filename, and immutability of a published identifier is the reason. A mirror, a lockfile or an SBOM may already record that name and its hash, and allowing the same name to later mean different bytes would break every integrity check built on it. The fix ships as a new version.
- The token has been revoked. Does deleting the file still have any value?Some, but modest. It removes the most discoverable copy and stops new consumers fetching an artifact you would rather not distribute. Weigh it against the cost: deleting breaks any build that pinned that version, so for a widely adopted release, withdrawing from future selection while leaving the file resolvable is often the better trade once the secret is dead.
- What would have caught this before publication?A secret scan run against the built distribution rather than only the source tree, since the packaging step is what pulled the file in. Backing that up: building releases from a clean checkout instead of a developer working directory, an explicit allowlist of what goes into the distribution, and short-lived credentials so an exposed one is worth little by the time it surfaces.
Deleting the file is shredding the copy of the key you left on your own desk. It does nothing about the copies already cut, so you change the lock first.
saying these in an interview costs you the question
- Deletes the file and considers the incident closed
- Rotates the credential only after publishing the clean release
- Assumes an internal caching proxy purges when upstream deletes
- Plans to re-upload the fix under the same filename
- Skips checking whether the credential was actually used