-
Notifications
You must be signed in to change notification settings - Fork 617
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
specs: Add minimum raw security profiles needed by plugins to ContainerSpec and PluginSpec #1964
Conversation
c8d3cff
to
6aa749c
Compare
Codecov Report
@@ Coverage Diff @@
## master #1964 +/- ##
==========================================
+ Coverage 53.47% 53.62% +0.15%
==========================================
Files 109 109
Lines 18919 18919
==========================================
+ Hits 10116 10146 +30
+ Misses 7570 7535 -35
- Partials 1233 1238 +5 Continue to review full report at Codecov.
|
api/types.proto
Outdated
} | ||
} | ||
|
||
// WindowsRawSecurityProfile provides any low level privileges a windows container needs |
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/any/all ?
api/types.proto
Outdated
repeated string capabilities = 1; | ||
|
||
// Devices needed by the service | ||
repeated Device devices = 2; |
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.
does it make sense to have Devices if the only thing that it contains is a path string?
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.
Good point - I left it in because I wasn't sure if we'd need anything else. https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#devices has a bunch of other options, but https://docs.docker.com/engine/extend/config/ only has the name, description, and path. (I figured the name and description are probably not necessary, but wasn't sure)
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.
Do any plugins require bind mounts?
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.
Yes, mounts is an option - ContainerSpec
already has the Mounts
field, though, so I thought that could be used instead?
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.
Or are you suggesting that devices could also use the Mounts field?
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.
I would think we would need at least the type
, path
and major,minor
for device support. /cc @justincormack
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.
Docker (as opposed to runc
) reads the device information off the host device (so you cannot create a device in the container which does not exist on the host, which is normally ok). It does need the rwm
options for the device cgroups as well though, so another string.
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.
Added, thanks @justincormack
Is this supposed to cover the minimum essential to unlock swarm plugins? |
@diogomonica Yes, that is the goal. Let me update the description and title. |
6ab5d00
to
5607598
Compare
api/specs.proto
Outdated
@@ -264,6 +264,9 @@ message ContainerSpec { | |||
// task will exit and a new task will be rescheduled elsewhere. A container | |||
// is considered unhealthy after `Retries` number of consecutive failures. | |||
HealthConfig healthcheck = 16; | |||
|
|||
// SecurityProfiles specifies per-architecture security options required by the container | |||
SecurityProfiles security_profiles = 21; |
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.
Is this the right wording? My understanding was that security profiles would be high-level privilege grants, but ServiceSpecs
would contain low level capabilities.
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.
I'm not sure what the right wording should be. My understanding is similar, in that was that these would be low level, and security profiles would be high level grants that would map to low level capabilities.
I believe the current plan is to mapped on the CLI side, but possibly we'd need support for the mapping later in swarm (@aluzzardi brought up the point that it's easier to change types and versions of things in swarm than it is to change CLI option behavior).
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.
The major problem w/ it being in swarm is the expectation between service creation across multiple versions of the mapping.
if a service worked by doing docker service create --grant=networking my-service
, and we change swarm's mapping server-side, that same cmd-line might not work in a future version of swarm.
Or are you suggesting that devices could also use the Mounts field?
Just wondering if we should centralize the declarations of what elevated privileges a service requires, including bind mounts.
|
@aaronlehmann @cyli yeah, I think aggregating this into a |
5607598
to
24b72b5
Compare
I've deprecated the mounts in
Renamed everything |
I'm not sure we want to deprecate |
@aaronlehmann having privileges in one place, and actual mount requests in a different place, is a recipe for authZ problems. The most obvious example being the creation of a service spec that doesn't request privileges, but includes mounts, and the authz code merely checks if privileges for mount were requested, allowing it to pass by unchecked. |
api/types.proto
Outdated
repeated Mount mounts = 1 [(gogoproto.nullable) = false]; | ||
|
||
// Linux capabilities required by the container | ||
repeated string capabilities = 2; |
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.
Rather than string, should we just enumerate the caps listed here: https://github.com/opencontainers/runc/blob/master/libcontainer/SPEC.md#security ?
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.
Are you proposing it actually being an enum? What would be the path for dealing with changes in capabilities?
Slightly concerned that inspecting profiles directly becomes a bit harder, but it will definitely be a lot more compressed on the wire this way.
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.
If more capabilities were added, then we could add them to the enum? Are capabilities in linux every deprecated/removed?
I don't feel strongly that it should be an enum - just thought it'd be easier to check if there were invalid capabilities, etc. I'm fine with leaving it a string.
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.
nothing in Linux is ever removed. They might become useless eventually. If you are going to use an enum you should probably use the real values http://lxr.free-electrons.com/source/include/uapi/linux/capability.h#L96 onwards
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.
I'm down w/ enum
Sorry what "mount privileges" are being discussed? |
24b72b5
to
654985c
Compare
@justincormack @diogomonica Added the caps as an enum on the profile. PTAL So do the mount instructions in the privileges section make sense, or should I move them back to container spec? |
2f11893
to
0ad78b5
Compare
api/types.proto
Outdated
@@ -883,4 +883,4 @@ message MaybeEncryptedRecord { | |||
Algorithm algorithm = 1; | |||
bytes data = 2; | |||
bytes nonce = 3; | |||
} | |||
} |
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.
Final newline got removed here
I don't think they make sense in the privileges section, because they include a lot that's not related at all to privileges, such as target path inside the container, and driver options. My thought here was to keep the mount instructions where they are now, but require a corresponding privilege grant in @diogomonica didn't seem positive about this:
My thinking about this case is that the agent must refuse to act on any mount instructions that aren't accompanied by a privilege grant. |
8e9adc2
to
3cdbd23
Compare
If you feel strongly about it, I'm ok w/ that tradeoff @aaronlehmann |
Since both have to come through the specs, one in the container spec, one in the privilege profiles which are also in the container spec, would that be just copying the same stuff in 2 places? Since both have to come from the user? |
No, I don't feel strongly about it. Just trying to find the best tradeoff. The privilege profiles don't seem like the right place to place detailed mount instructions with driver options and so on. And it doesn't seem right either to have authZ code look into the
It would be slightly redundant but the |
// Devices needed by the service | ||
repeated Device devices = 3; | ||
|
||
// Rather than provide a list of all devices, just mount every device on the node |
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.
If this is the equivalent of allow-all-devices
, then the comment should read allow read write and modify access to all devices on the node
.
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.
Also better to rename the boolean to allow-all-devices
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.
Will do, thanks!
PR takes care of adding the profiles to |
So I have an important bikeshedding problem #oxymoron. First, I also wonder if we shouldn't just not have a name at all and simply have I can't seem to find a satisfying solution :S |
|
||
|
||
// PrivilegeProfiles specifies per-architecture security configuration/permissions | ||
message PrivilegeProfiles { |
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.
If we decide to go with this name, shouldn't this be singular?
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.
It's plural because it has profiles for both windows and linux.
@tiborvass where will you put the sec comp profile? Inside |
@diogomonica a field named |
/shrug |
@diogomonica basically I'm wondering if it's fine to not "bundle" the various fields like Capabilities, Devices, Seccomp into one object that we have trouble finding a name for because it wouldn't be complete. |
@aluzzardi has opinions |
@tiborvass: just to summarize, is your proposal:
And similarly for plugin spec? (I have no strong opinions - happy to change if folks feel this works better) |
@cyli yes. Not saying that's the best thing. Just that, we did something similar for plugins. If we are happy with a name for |
Considering this is flat in docker/docker (the platform part), should we do the same here? e.g. have Capabilities at the top level which would be ignored by windows. |
My preference, without any additional context, is have it in sub objects, mainly because there'd be a lot of duplication otherwise between the plugin spec and the container spec. Within the context of translatation from swarm to docker, it seems like some translation already needs to happen for a full list of capabilities -> Alternately, do we want just want to copy and paste |
@aluzzardi shouldn't this be in TaskSpec instead of PluginSpec? Particularly if this will be shared by ContainerSpec later for services. |
@diogomonica Oh that's true - it could go in the So are we ok with just going with |
@cyli is the goal to allow some kind of default? I'm worried that by going w/ cap add and cap drop we don't get to a world where the AuthZ plugin has all the information needed to do it's job, and has to rely on some external knowledge of what the current "default" is, and if current denied capability Y is enabled by not dropping it. |
@diogomonica Yes, to allow the docker default, and also to make translation easier with the docker. Agree that it's not ideal that the authz plugin would have to know about what the current docker default is, and also this means that upgrading a docker version could potentially what capabilities a service is configured with (although that's currently the case already I think). Although possibly #1744 could help with that (if the interpolated specs interpolated the defaults (and I guess had an extra field that was the full list of capabilities?) |
Why are we trying not o have the full list of caps in the first place? |
The problem is that the docker client does not know what the full cap set
is, as it is a daemon side decision (at present a constant one but this
really needs to change).
For plugins they need to specify the full set so it is ok but this does not
match up with normal containers
…On 26 Feb 2017 14:46, "Diogo Mónica" ***@***.***> wrote:
Why are we trying not o have the full list of caps in the first place?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1964 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAdcPJfrKThiqy8E5fkRXvEU_6yRtePUks5rggCygaJpZM4MD2ma>
.
|
@justincormack shouldn't we have a mechanism to provide the recommended full profile an image has to run with? Ideally this would come inside of the image itself, when pulling from the hub, but adding it to the API and having the remote AuthZ plugin do the intersection between both might not be a bad way to go forward. |
Just double-checking - should this be closed? Are we going to go with opaque plugin blobs and maybe Docker's |
Isn't this related to profiles, in a way? We'll probably have to have something similar somewhere |
@aluzzardi Profiles/high level grants I think are going to be mainly a CLI mapping for now. Possibly we want to update the |
I sort of lost track of how this fits in with everything else. It seems to overlap with #2075, but #2075 did not add the capabilities. If I understood correctly, capabilities are a hard requirement for 17.06. It sounds like we should either resurrect this to add the capabilities or open something separate, perhaps drawing on the work that took place here. cc @aluzzardi |
I think this is no longer needed as plugins will be an opaque |
This adds per-architecture security profiles to the
ContainerSpec
(it would also have to be added thePluginSpec
). These are currently the minimum options needed in security profiles to unblock plugins. This does not cover all the security options thatdocker run
supports.The linux raw security profile came from the documented plugin config file, under the "Linux" section. Networks, mounts, env vars, and args I assume can also already be mapped to existing
ContainerSpec
orServiceSpec
fields.I have not managed to find out what else should go into a raw windows security profile.
This continues the work done in #1944, but is currently only the specs, and not any kind of implementation.
cc @diogomonica @ehazlett @aluzzardi @tiborvass