Skip to content

disallow implicit docker builds if user can't run normal docker builds#8664

Closed
bparees wants to merge 1 commit intoopenshift:masterfrom
bparees:implicit_build
Closed

disallow implicit docker builds if user can't run normal docker builds#8664
bparees wants to merge 1 commit intoopenshift:masterfrom
bparees:implicit_build

Conversation

@bparees
Copy link
Copy Markdown
Contributor

@bparees bparees commented Apr 28, 2016

this is probably going away in deference to #8679

@bparees bparees force-pushed the implicit_build branch 5 times, most recently from 5d33c3f to 4251157 Compare April 28, 2016 17:18
@bparees
Copy link
Copy Markdown
Contributor Author

bparees commented Apr 28, 2016

@liggitt @csrwng @smarterclayton ok tests are still coming but i think this is ready for an implementation review.

Note that as discussed with @liggitt there is still an exploit path here:

  1. user starts w/ docker permissions
  2. user creates an s2i BC, BC will have disableImplicit=false
  3. admin removes user's docker perms
  4. user causes BC to be triggered via webhook/imagechange/etc
  5. the build that's created will have disableImplicit=false (because the build is created by the controller, not the user, and the controller has docker permissions)

@bparees
Copy link
Copy Markdown
Contributor Author

bparees commented Apr 28, 2016

(and actually the way this is currently implemented, "oc start-build" would also work on step (4), because i'm not auditing the buildrequest object itself.

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty"`

// disableImplicitBuild prevents source-to-image from performing a Docker build operation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/disableImplicitBuild/DisableImplicitBuild/

Copy link
Copy Markdown
Contributor Author

@bparees bparees Apr 28, 2016

Choose a reason for hiding this comment

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

my understanding from @smarterclayton is that this is how we're supposed to do it now so it matches the json field name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ic ... good to know... then the other fields are wrong :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't think of a single reason, other than security, that a user would
ever select DisableImplicitBuild themselves.

On Thu, Apr 28, 2016 at 2:14 PM, Ben Parees notifications@github.com
wrote:

In pkg/build/api/v1/types.go
#8664 (comment):

@@ -402,6 +402,11 @@ type SourceBuildStrategy struct {

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty"`
  • // disableImplicitBuild prevents source-to-image from performing a Docker build operation

yeah, @gabemontero https://github.com/gabemontero already has a pull
open that's updating them all though:

https://github.com/openshift/origin/pull/8477/files#diff-43dd40b4c2b85b388a3d9116729032e4L14


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/8664/files/4251157e4e6c6d4b865d530bb0de37eb6fd75b3a#r61476003

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@csrwng suggested moving it to an annotation. I can do that, but i'd like to talk through this a little more before I do..I kinda hate the number of magic annotations we are accumulating and it makes the implementation code uglier. Our APIs serve two customers: our users, and ourselves. Making our code more complex (and less performant) impacts those users too, and per above, there is a(weak) case for why this is useful to an end user anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do you need to do it on a per user basis? Adding something to the API
is burdensome, it doesn't match cleanly to actual security requirements,
and it's just adding the wrong sorts of complexity. If we had proper
network support then this would not be an issue.

I'm not in favor of opening it up as an API field.

On Thu, Apr 28, 2016 at 2:21 PM, Ben Parees notifications@github.com
wrote:

In pkg/build/api/v1/types.go
#8664 (comment):

@@ -402,6 +402,11 @@ type SourceBuildStrategy struct {

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty"`
  • // disableImplicitBuild prevents source-to-image from performing a Docker build operation

@smarterclayton https://github.com/smarterclayton fair enough, but I
want to be able to control this behavior on a per user basis so we need
some way to convey to s2i what is/isn't allowed. I'm open to suggestions,
but I started by putting it on the build pod directly until I realized the
build pods are managed by the controller which means they can't check
permissions in a useful way.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/8664/files/4251157e4e6c6d4b865d530bb0de37eb6fd75b3a#r61477153

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Basically - you need to make a stronger case for why an end user wants this.

On Thu, Apr 28, 2016 at 4:04 PM, Clayton Coleman ccoleman@redhat.com
wrote:

Why do you need to do it on a per user basis? Adding something to the API
is burdensome, it doesn't match cleanly to actual security requirements,
and it's just adding the wrong sorts of complexity. If we had proper
network support then this would not be an issue.

I'm not in favor of opening it up as an API field.

On Thu, Apr 28, 2016 at 2:21 PM, Ben Parees notifications@github.com
wrote:

In pkg/build/api/v1/types.go
#8664 (comment):

@@ -402,6 +402,11 @@ type SourceBuildStrategy struct {

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool json:"forcePull,omitempty"
+

  • // disableImplicitBuild prevents source-to-image from performing a Docker build operation

@smarterclayton https://github.com/smarterclayton fair enough, but I
want to be able to control this behavior on a per user basis so we need
some way to convey to s2i what is/isn't allowed. I'm open to suggestions,
but I started by putting it on the build pod directly until I realized the
build pods are managed by the controller which means they can't check
permissions in a useful way.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/8664/files/4251157e4e6c6d4b865d530bb0de37eb6fd75b3a#r61477153

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

An end user wants this so they are not blocked from doing this if their admin trusts them but is not willing to open it up to the entire cluster.

And an end user wants this if they want to protect themselves from having to inspect every s2i builder image to see if it contains rogue ONBUILD commands that amount to trojan horse exploits.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in other words, being able to disable the implicit build behavior of s2i is absolutely an end user concern.

// prevent s2i from doing an implicit docker build during the s2i build process.
// Mutates strategy argument.
func (a *buildByStrategy) setImplicitBuildPermission(strategy *buildapi.BuildStrategy, attr admission.Attributes) error {
if strategy.SourceStrategy != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you may want to avoid the check if DisableImplicitBuild is already true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good call

@bparees
Copy link
Copy Markdown
Contributor Author

bparees commented Apr 28, 2016

@csrwng comments addressed, test cases added, ptal
[test]

@openshift-bot
Copy link
Copy Markdown
Contributor

Evaluated for origin test up to af3ff6f

@openshift-bot
Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/3420/)

@smarterclayton
Copy link
Copy Markdown
Contributor

End users only select s2i images, they are not responsible for creating
them. A user responsible for creating an s2i image is violating the
implicit security that s2i brings.

On Thu, Apr 28, 2016 at 4:20 PM, OpenShift Bot notifications@github.com
wrote:

continuous-integration/openshift-jenkins/test FAILURE (
https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/3420/)


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8664 (comment)

@smarterclayton
Copy link
Copy Markdown
Contributor

I'm pretty sure that disabling implicit build behavior is going to break
any s2i image that has it. So a user would just... make a different s2i
image.

On Thu, Apr 28, 2016 at 4:27 PM, Clayton Coleman ccoleman@redhat.com
wrote:

End users only select s2i images, they are not responsible for creating
them. A user responsible for creating an s2i image is violating the
implicit security that s2i brings.

On Thu, Apr 28, 2016 at 4:20 PM, OpenShift Bot notifications@github.com
wrote:

continuous-integration/openshift-jenkins/test FAILURE (
https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/3420/)


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8664 (comment)

@bparees bparees closed this Apr 29, 2016
@bparees bparees deleted the implicit_build branch August 5, 2016 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants