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

Revisit handling of wrapped keys/master passwords #87

Closed
woodruffw opened this issue Sep 26, 2020 · 4 comments
Closed

Revisit handling of wrapped keys/master passwords #87

woodruffw opened this issue Sep 26, 2020 · 4 comments

Comments

@woodruffw
Copy link
Owner

This needs more thought before I or someone else goes and does it, but:

  • The current master password approach is slightly ugly: it uses a not-very-well-specified POSIX API (named SHM objects) and requires additional hacks for different OSes.

  • Most modern desktop environments already provide an integrated keychain, and some (like macOS) integrate that keychain tightly into hardened hardware. This makes it an ideal place to store a master password.

  • There are a few Rust crates for managing system keychains/keyrings:

  • We should still fall back on the current approach when we fail to detect a suitable keychain to interact with, or if the user specifically requests the current approach.

@woodruffw
Copy link
Owner Author

woodruffw commented Nov 21, 2020

Alternative idea: use an agent-style architecture:

  • kbs2 --agent asks for the master password and runs in the background with the unwrapped key in memory
  • Subsequent kbs2 invocations check for a Unix domain socket based in part on the keyfile name, and use that to temporarily grab the unwrapped key

Pros:

  • Lots of decent reference material (ssh-agent)
  • Same threat model as the current approach (an attacker with the same or greater permissions as the current user can steal the wrapped key, but an offline attacker can't)
  • Probably simpler than the current SHM mess
  • Actually ends the "session" on user logout, which is more intuitive than the current behavior

Cons:

  • Requires a background process
  • Requires messing with Unix domain sockets in Rust

@woodruffw woodruffw changed the title Consider defaulting to the system keychain for the master password Revisit handling of wrapped keys Nov 21, 2020
@woodruffw woodruffw changed the title Revisit handling of wrapped keys Revisit handling of wrapped keys/master passwords Nov 21, 2020
@woodruffw
Copy link
Owner Author

woodruffw commented Nov 21, 2020

Ratcheting down the security of an agent-style approach: kbs2 --agent would be run from the same underlying executable as any subsequent kbs2 calls, so the executable path could be a some authenticity check for the client. That doesn't stop someone from replacing the kbs2 executable with something malicious, though.

Braindump:

  • Linux supports SO_PEERCRED for getting the PID of a Unix socket client
  • macOS appears to support getpeereid(3) and LOCAL_PEERCRED for the same purpose
    • Edit: getpeerid/LOCAL_PEERCRED only does uid and gid for some reason. Annoying. Apparently LOCAL_PEERPID works, but is undocumented.

Then, from the client PID:

@woodruffw
Copy link
Owner Author

woodruffw commented Nov 21, 2020

More braindump:

  • kbs2 --agent does a checksum of its own executable on startup
  • After resolving the executable path of the client requesting the unwrapped key, do a checksum of that path's contents
  • If the checksums match, allow the connection

Downside:

  • Different versions of kbs2 running on the same host won't be able to talk to the same agent.

@woodruffw woodruffw mentioned this issue Nov 24, 2020
5 tasks
@woodruffw woodruffw added this to the 0.2.0 milestone Nov 26, 2020
@woodruffw
Copy link
Owner Author

#103.

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

No branches or pull requests

1 participant