Skip to content
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

[docker-1.12] Signature verification on pull #200

Merged
merged 1 commit into from
Oct 24, 2016

Conversation

runcom
Copy link
Collaborator

@runcom runcom commented Sep 30, 2016

This patch implements signature verification through containers/image directly into the daemon.

Depends on containers/image#99 (you can workaround that by following containers/image#99 (comment))

/cc @mtrmac @rhatdan @ddarrah

@rhatdan
Copy link
Member

rhatdan commented Sep 30, 2016

What happens if the policy file does not exist? Do we default succeed?

@runcom
Copy link
Collaborator Author

runcom commented Sep 30, 2016

What happens if the policy file does not exist? Do we default succeed?

we default fail

since this is going to be part of the docker package we'll ship a default policy.json and if it doesn't exists in /etc/containers/policy.json we badly bail out

"type": "insecureAcceptAnything"
}
]
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I‘d rather not have two RPMs owning policy.json in the distribution at the same time… but I don’t have a strong opinion on which one should own it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I don't think docker should own it. Probably best if owned by skopeo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsm5, Miloslav suggested to have a "skopeo-container-policy" package which just ships the policy.json file under /etc/containers/. This package will be Required by both skopeo and docker.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@@ -85,9 +92,51 @@ func (p *v2Puller) Pull(ctx context.Context, ref reference.Named) (err error) {
return err
}

func (p *v2Puller) checkTrusted(ref reference.Named) (reference.Named, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK on this function; didn’t look at the rest in too much detail.

@@ -94,12 +95,24 @@ func (p *v2Puller) Pull(ctx context.Context, ref reference.Named) (err error) {

func (p *v2Puller) checkTrusted(ref reference.Named) (reference.Named, error) {
p.originalRef = ref
imgRef, err := docker.NewReference(ref)
dockerRef, err := containersImageRef.ParseNamed(ref.String())
Copy link
Collaborator Author

@runcom runcom Oct 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtrmac PTAL at this since in projectatomic/docker it's the only way to have a consistent reference parsing for signatures. It's working like this, pinging you to understand if I'm missing something. (this is related to containers/image#123).
Without this change, ref is parsed using projectatomic/docker's reference and contains the hostname and makes the signatures check fails.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. It is a bit horrible, but that’s what we get with Golang’s interface-as-collection-of-method-signatures type system instead of an interface-as-a-name-and-explicitly-committed-to-protocol.

Please make sure to add a comment explaining why we can't use docker.NewReference without the ParseNamed(ref.String()) roundtrip so that this isn’t “cleaned up” later when we forget or a new maintainer comes.

@runcom
Copy link
Collaborator Author

runcom commented Oct 12, 2016

@rhatdan @mtrmac alright, integration tests are green locally (finally), I need only containers/image#126 merged and a revendor here and this seems really in a good shape. The last blocker I have is containers/image#99 which I'm working on right now but I feel we can start building rpms (in Fedora at least) so people can start testing this out.

@rhatdan
Copy link
Member

rhatdan commented Oct 12, 2016

OK I see checks are still failing?

@runcom
Copy link
Collaborator Author

runcom commented Oct 12, 2016

@rhatdan nah, those are related to the RH CI which has been always broken for various reasons like the current one:

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory

which is unrelated to this PR

@runcom
Copy link
Collaborator Author

runcom commented Oct 12, 2016

alright, containers/image#126 got merged, now we're only missing containers/image#99 which I'm working on but it's not a total blocker so I'd say we can start testing this out /cc @lsm5 @ddarrah @rhatdan

@runcom runcom force-pushed the verify-sigs-on-pull-1.12 branch 5 times, most recently from 407a421 to 967b10c Compare October 21, 2016 14:48
@runcom
Copy link
Collaborator Author

runcom commented Oct 24, 2016

@mtrmac PTAL - This is based on containers/image master code so, in order to pull-by-digest AND verify with GPG one must use https://github.com/containers/image/blob/master/docs/policy.json.md#a-temporary-work-around-to-allow-accessing-any-image-by-digest. Please ack on this.

@jwhonce @rhatdan @imcleod I'm running integration tests locally, after that, ready to merge!

Copy link

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A possible improvement, but LGTM.

DockerAuthConfig: &dockerAuthConfig,
DockerRegistryUserAgent: dockerversion.DockerUserAgent(c),
}
img, err := imgRef.NewImage(ctx)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could now be more secure with a imgRef.NewImageSourceimage.UnparsedFromSource, the way copy.Image does it; it would skip all of the risky manifest parsing image.FromUnparsedImage is doing which nothing here seems to need. (AFAICT this change wouldn’t affect the behavior with manifest lists, but that would be worth checking).

Copy link
Collaborator Author

@runcom runcom Oct 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, will fix it if it's not totally breaking manifest lists.

ref, err = p.checkTrusted(ctx, ref)
if err != nil {
return allowV1Fallback(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what happens on the v1 fallback? Do we just accept any unsigned image on that path? So all the attacker needs to do is to DoS the signature fetch/verification so that we fall back?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about this but meant to ping you, what do we do here? I'm ok not falling back.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can even add a flag on the daemon which explicitly allow v1 fallback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, v1 fallback is now disabled if there's any error checking the image's signature

@runcom
Copy link
Collaborator Author

runcom commented Oct 24, 2016

@rhatdan @jwhonce @imcleod this is good to be merged now

Last thing I've added is a flag to completely opt-out of image's sigs verification (just in case anyone is having troubles! as discussed on IRC with @mtrmac)

@runcom runcom force-pushed the verify-sigs-on-pull-1.12 branch 3 times, most recently from 1519241 to 8fc3c69 Compare October 24, 2016 20:46
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
@rhatdan rhatdan merged commit f97f83e into projectatomic:docker-1.12 Oct 24, 2016
@runcom runcom deleted the verify-sigs-on-pull-1.12 branch October 24, 2016 20:52
@runcom
Copy link
Collaborator Author

runcom commented Oct 24, 2016

"finger crossed" lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants