A build-time token is baked into an image layer — who can read it once the image is published?
answer
- pull access is the audience
- it ships with the image
- layer bytes and build record both travel
- mirrors, caches and saved copies count
- assume disclosed from the push
basics
~20 sEveryone who can pull the image, and everyone already holding a copy of it. The value sits in a read-only layer and in the build record that travels with it, so pull access is credential access.
solid answer
~50 sA credential handed to a build ends up in one of two places that ship: the bytes a step wrote into its layer, or the build record the builder keeps describing how each layer was produced, which is where declared build arguments and environment values land. Both are part of the published image. So the audience is no longer the build team — it is everyone who can pull that image, everyone with read access to the registry holding it, every mirror or pull-through cache that fetched it, every host that already pulled it, anyone handed a saved copy as a file, and any later image built on top of it. Running the image and finding no such file proves nothing, because a later step can hide a path without removing the earlier layer. Treat the value as disclosed from the moment it was pushed.
go deeper
Recall the one-line rule: anything inside an image is published to everyone who can pull that image. A credential in a layer is a disclosed credential, not a build-hygiene nit.
Explain both routes into the published package — bytes a step wrote into its layer, and the build record that captures declared build arguments and environment values — and why an empty listing inside a running container proves nothing.
Show that you size the incident by what the credential can do and by the fact that holders of a published image cannot be enumerated, rather than by how obscure you think the image is.
The angle a lead owns is making the failure structurally impossible: what the build platform hands teams by default, and how images are checked before they can be published at all, rather than relying on reviewers to spot it.
## What "baked into a layer" means A build runs as an ordered sequence of steps. Each step produces a **layer** — the filesystem changes that step made — and the finished image is that ordered stack of layers plus a document describing them and the build that produced them. Nothing about that package is private to the team that built it; it is an artifact designed to be copied. A credential can enter the package by two routes, and both of them ship: - **In the layer bytes.** A step writes the value to a file — a configuration file, a credential file for a package fetch step, an appended line in a shell profile — and the file is still there when the step ends. That file is now part of the layer. - **In the build record.** A value supplied as a **build argument** or an **environment value** is an input the builder records alongside the step it fed, so the image carries a description of how it was made that contains the value. No file has to be written for this to happen. That second route is the one that surprises people, because nothing in the running container ever shows it. ## Who the audience actually is | Who | How they get the value | |---|---| | Anyone who can pull the image | Pull it, unpack the layers, read the file or the build record — no need to run it | | Anyone with read access to the registry | Same, without ever touching a host that runs containers | | A mirror or pull-through cache | It holds its own copy of the same layers, on its own retention rules | | A host that already pulled it | The local copy survives anything you do upstream afterwards | | Anyone handed a saved copy | An image exported to a file carries the layers and the build record with it | | A later image built on this one | It inherits these layers wholesale, so the value spreads into descendants | The list is not exhaustive and that is the point: **you cannot enumerate the holders of a published image.** The honest assessment is the credential's privileges, not a guess about how many people bothered to look. ## Why the running container misleads you The most common wrong check is to start the image, list the path, see nothing, and conclude the value never shipped. Layers stack: a later step that removes a file records that the path is hidden in the assembled view, while the earlier layer that wrote the file is unchanged and is still transferred on every pull. The readable check is on the layers and the build record, not inside a running container. ## What follows from this 1. **Assume disclosure at push time.** The clock starts when the image became pullable, not when someone noticed. 2. **Size the incident by the credential, not the image.** A read-scoped feed token and a token that can publish are very different incidents even though the leak mechanism is identical. 3. **A private registry narrows the audience; it does not remove it.** Everyone who can pull still reads the value, and internal pull access is usually far wider than the build team. 4. **Fixing the build does not fix what is already published.** A corrected build produces a clean new image; every earlier image stays exactly as it was. ## The rule worth carrying An image is a distribution format. Anything inside it is published to the whole audience that can obtain it, for as long as any copy exists. A credential therefore has no business being inside one — not compressed, not encoded, not written and then hidden, not tucked into the build record. The question to ask of any value a build touches is simply: *is this still present in what gets pushed?* If the answer is yes, the value is public to the pull audience, and the response is to stop the value being accepted rather than to tidy the registry.
- The image only ever went to an internal registry. Does that change the assessment?It narrows the audience to everyone with read access to that registry, plus every mirror, cache and host that already pulled — usually far more principals than the build team, and not a list you can enumerate. The value must still be treated as exposed; internal distribution changes the number, not the kind, of the problem.
- The workload needs that same feed token while it runs. Does baking it in become acceptable then?No. The image's audience is everyone who can pull it, which is wider than the set of principals allowed to run the workload, so shipping the value inside the image hands it to people who only ever needed the software. How a running workload is given a credential is a separate mechanism with its own delivery path.
- Does it help to encode or compress the value before writing it into the layer?No. Encoding is a transport convenience, not a protection: anyone reading the layer applies the same transform in reverse. The relevant property is whether the bytes are present in what was pushed, and an encoded credential is present.
saying these in an interview costs you the question
- Says only the build machine ever saw the token
- Assumes a private registry makes a baked credential safe
- Thinks the credential disappears when the build finishes
- Believes only people with the build files can find it
- Treats it as untidy rather than a disclosed credential