Skip to content

Encryption at rest of manager keys and raft data#27967

Merged
vieux merged 8 commits intomoby:masterfrom
aaronlehmann:encryption
Nov 10, 2016
Merged

Encryption at rest of manager keys and raft data#27967
vieux merged 8 commits intomoby:masterfrom
aaronlehmann:encryption

Conversation

@aaronlehmann
Copy link

This implements the Docker side of moby/swarmkit#1598. Builds on earlier work by @tonistiigi.

It's feature-complete but needs docs and some more testing.

cc @cyli @diogomonica @NathanMcCauley

@thaJeztah
Copy link
Member

needs a rebase @aaronlehmann

@aaronlehmann
Copy link
Author

Gah! It's not ready to merge. Super annoying how CI forces a merge against master and then falls over with compilation errors when there are conflicts.

@aaronlehmann
Copy link
Author

ping @dnephin @thaJeztah @aluzzardi - it would be great to get some early design review

@thaJeztah thaJeztah added the status/needs-attention Calls for a collective discussion during a review session label Nov 4, 2016
@aaronlehmann aaronlehmann force-pushed the encryption branch 4 times, most recently from a787543 to 99b647e Compare November 5, 2016 01:16
Copy link
Member

@aluzzardi aluzzardi Nov 7, 2016

Choose a reason for hiding this comment

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

Is this route supposed to return the unlock key or to rotate it?

Copy link
Author

Choose a reason for hiding this comment

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

Is this route supposed to return the unlock key or to rotate it?

Return the unlock key

hack/vendor.sh Outdated
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Author

Choose a reason for hiding this comment

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

Fixing

@aluzzardi
Copy link
Member

What's the overall workflow UX-wise?

What happens while the swarm in locked?

@aaronlehmann
Copy link
Author

What's the overall workflow UX-wise?

docker swarm init --autolock or docker swarm update --autolock to turn on manager locking. This prints out a key.

Then on restart docker swarm unlock is necessary to start the manager. This takes the key on stdin.

You can retrieve the current key with docker swarm unlock-key, or rotate it with docker swarm unlock-key --rotate.

What happens while the swarm in locked?

The swarm components do not operate until you run docker swarm unlock.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is left here on purpose ?

@aaronlehmann aaronlehmann force-pushed the encryption branch 2 times, most recently from f93d83a to d9916ee Compare November 8, 2016 18:52
@aluzzardi
Copy link
Member

This needs help reviewing, specifically the UX workflow (see @aaronlehmann comment above).

Some comments:

  • autolock seems weird - there is no lock command, so it's not obvious what we're automating. autounlock would maybe make more sense? It's symmetric with docker swarm unlock. /cc @dnephin
  • Exposing the CA service and having the Engine talk to it seems weird. We should not talk to anything else but the Control API IMHO. Perhaps we should just return the unlock key in inspect and remove the unlockkey endpoint altogether?
  • Consistency: We redact sensitive data from the API (such as secret data), yet we allow retrieving the unlockkey. Does this constitute a security issue? /cc @diogomonica

/cc @icecrime @thaJeztah @vieux @tiborvass

@tonistiigi
Copy link
Member

tonistiigi commented Nov 8, 2016

Tested and reviewed this and design LGTM. Previous version had a way to specify lock key and never returned it from remote api. I think it was changed for ease of use and I don't really have a preference about which is better. Current behavior is consistent with join-tokens.

The behavior of the down nodes after rotation/autolock change needs to be clearly documented as it isn't obvious.

@aaronlehmann Maybe in follow-up we could run all swarm tests with encryption enabled. Even if it requires an env switch it would give much more coverage.

@aluzzardi
Copy link
Member

@icecrime @thaJeztah @vieux @tiborvass @diogomonica: Any thoughts regarding the comments above?

This is getting merged today, feedback much appreciated.

@vieux
Copy link
Contributor

vieux commented Nov 9, 2016

@aluzzardi --autolock seems ok to me, I don't have a better name

@aaronlehmann could you add API and CLI reference doc ?

tonistiigi and others added 7 commits November 9, 2016 16:08
- Neither swarm init or swarm update should take an unlock key
- Add an autolock flag to turn on autolock
- Make the necessary docker api changes
- Add SwarmGetUnlockKey API call and use it when turning on autolock
- Add swarm unlock-key subcommand

Signed-off-by: Aaron Lehmann <[email protected]>
Signed-off-by: Aaron Lehmann <[email protected]>
Signed-off-by: Aaron Lehmann <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

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

for a follow up; remove the trailing comma, and add a comma after "CAConfig": {}

Copy link
Author

Choose a reason for hiding this comment

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

@thaJeztah: done

Copy link
Member

@thaJeztah thaJeztah Nov 10, 2016

Choose a reason for hiding this comment

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

for follow-up: add bool here

edit: realized that Cobra won't output booleans, so we probably need to include it in the description)

Copy link
Author

Choose a reason for hiding this comment

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

@thaJeztah: bool doesn't appear in the --help output. Should I add it anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Just realized that, hm probably in the comment I guess

Copy link
Member

Choose a reason for hiding this comment

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

same here (bool)

Copy link
Member

@thaJeztah thaJeztah Nov 10, 2016

Choose a reason for hiding this comment

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

also needs to mention the default if omitted (actually, if default is "disabled", we can change this description to just "Enable manager auto locking ..."

Copy link
Author

Choose a reason for hiding this comment

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

@thaJeztah: Can you suggest a phrasing for this? --autolock or --autolock=true will enable it, and --autolock=false will disable it (in cases where it was previously enabled).

Copy link
Member

Choose a reason for hiding this comment

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

This one is for init, so it can only "enable" it, so this can be simply;

Enable manager autolocking (requiring an unlock key to start a stopped manager)

@vieux vieux merged commit 18a07f5 into moby:master Nov 10, 2016
@aaronlehmann aaronlehmann deleted the encryption branch November 10, 2016 01:49
@aaronlehmann
Copy link
Author

Options:
--advertise-addr value Advertised address (format: <ip|interface>[:port])

  •  --autolock                        Enable or disable manager autolocking (requiring an unlock key to start a stopped manager)
    
    This one is for init, so it can only "enable" it, so this can be simply;

Enable manager autolocking (requiring an unlock key to start a stopped manager)

The flag is shared between init and update right now. Do you think the phrasing of the description should be different for these connands?

@aaronlehmann
Copy link
Author

Saw this failure in CI running on an unrelated PR:

02:44:57 ----------------------------------------------------------------------
02:44:57 FAIL: docker_cli_swarm_test.go:952: DockerSwarmSuite.TestSwarmRotateUnlockKey
02:44:57 
02:44:57 [d761dbbbf650b] waiting for daemon to start
02:44:57 [d761dbbbf650b] daemon started
02:44:57 [d761dbbbf650b] exiting daemon
02:44:57 [d761dbbbf650b] waiting for daemon to start
02:44:57 [d761dbbbf650b] daemon started
02:44:57 [d761dbbbf650b] exiting daemon
02:44:57 [d761dbbbf650b] waiting for daemon to start
02:44:57 [d761dbbbf650b] daemon started
02:44:57 docker_cli_swarm_test.go:1020:
02:44:57     c.Assert(err, checker.IsNil, check.Commentf("out: %v", string(out)))
02:44:57 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc421b583c0), Stderr:[]uint8(nil)} ("exit status 1")
02:44:57 ... out: Error response from daemon: swarm could not be unlocked: invalid key provided
02:44:57 
02:44:57 
02:44:57 [d761dbbbf650b] exiting daemon

I'll investigate this and provide a fix.

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.

7 participants