New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When a registry returns a blob or manifest, verify its contents by default #22558
When a registry returns a blob or manifest, verify its contents by default #22558
Conversation
bbdd62b
to
bc6d302
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits on godoc.
Per slack @dmage also thinks we should remove https://github.com/openshift/origin/blame/e004e6513ec755a7a106dc97516703847e470d0b/pkg/image/importer/image.go#L61-L62
pkg/image/registryclient/client.go
Outdated
| distribution.ManifestService | ||
| } | ||
|
|
||
| // Get retrieves the manifest identifievwd by the digest and guaranteezvs it matches the content it is retrieved by. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/s/identifievwd/identified/
/s/guaranteezvs/guarantees/
bc6d302
to
583a71a
Compare
I need to look into this |
|
Ok, so the registry on pullthrough of a schema1 tag is continually recreating the manifest. Hit this testing against quay. That happens because we generate a unique key each time on each different registry. |
|
I'm not sure there's any value in us not having a stable key. since schema1 signatures are going away, if we have to generate them it'd be better to do it with a hardcoded key checked into our code. it's not like we can trust the key, nor does it have any verifying power. |
|
So we have a couple of options
|
|
I'm concerned that we can't strictly parse manifests from schema1 without regressing customers. So we can't verify it on import from v1, only warn, and we don't have a channel for that. |
|
Re static key openshift/image-registry#174 is at least what it would look like. No one can use the keys we generate today and they are dead and deprecated. Anyone trusting our signature is no worse off today (since we don't publish those keys). |
583a71a
to
3dbc97a
Compare
|
Ok, I had a mistake in the verification process for schema1 manifests (I need to generate digest from the canonical manifest). On top of the verification changes in the manifest, do the following:
|
3dbc97a
to
de1152e
Compare
|
Removed the static private key changes, they aren't necessary |
|
once this merges we'll need to copy the registry client changes to image-registry. |
de1152e
to
c360c8b
Compare
c360c8b
to
6699d96
Compare
| options.DryRun = o.DryRun | ||
| options.From = toImageBase | ||
| options.ConfigurationCallback = func(dgst digest.Digest, config *docker10.DockerImageConfig) error { | ||
| options.ConfigurationCallback = func(dgst, contentDigest digest.Digest, config *docker10.DockerImageConfig) error { | ||
| verifier.Verify(dgst, contentDigest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need Verifier? Can we just return the error?
if dgst != contentDigest {
err := fmt.Errorf("the base image failed content verification and may have been tampered with")
if !o.SecurityOptions.SkipVerification {
return err
}
fmt.Fprintf(o.ErrOut, "warning: %v\n", err) // klog?
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For many of these they can run in parallel, I'd rather use common code. I think over time I might move the logic and message into verifier but it's not clear today it cleans up the code enough. I don't want to have different checks everywhere.
We don't use klog for human facing messages in cli commands (since it prints output not geared for humans)
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adambkaplan, dmage, smarterclayton, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…fault This guarantees integrity in scenarios where the registry is untrusted. We provide a helper that client libraries can use, and then ensure that tools properly verify its use. Add a flag to context that allows disabling this behavior.
There are specific cases where users may need to bypass verification of old content, possibly when dealing with broken registries. Allow client code to bypass this logic with --skip-verification. Also unify other flags (--registry-config, --insecure, --max-per-registry) so they are consistent across tools.
The underlying registry client should protect against invalid content, but the client tools should perform an additional set of checks to display warnings even if verification is overriden. Double check all content accessed during release tooling and print better messages when the image is displayed directly.
6699d96
to
56e7736
Compare
|
New changes are detected. LGTM label has been removed. |
|
rebased |
This guarantees integrity in scenarios where the registry is untrusted.
While not strictly necessary in all cases, it's better to verify rather than
allow someone to assume the server is trusted. Add a flag to Context to
allow disabling this behavior.
Tested before and after performance and didn't notice anything specific.