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

WIP: ssh-agent: Implement destination constraints #10252

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

kgraefe
Copy link
Contributor

@kgraefe kgraefe commented Feb 1, 2024

This change implements loading ssh-agent destination constraints from KeeAgent.settings into the ssh-agent. For now there is no UI so configuration must be done in KeePass2/KeeAgent.

The ssh-agent constrain extension is described at 1. However, I found it partly misleading:

  • in the constaint array each constraint is enveloped where in the keyspec arrays the keyspec are just appended to the constraint.
  • each constraint and host has an additional string field reserved for future use. The actual structure has been obtained from openssh ssh-add source code 2.

TODO:

  • GUI
  • Test against a SSH host with host key signed by a CA
  • Update this PR message

Fixes #9801

Screenshots

Testing strategy

Type of change

  • ✅ New feature (change that adds functionality)

@droidmonkey
Copy link
Member

droidmonkey commented Feb 1, 2024

What does this actually do / why does this matter?

@kgraefe
Copy link
Contributor Author

kgraefe commented Feb 1, 2024

What does this actually do / why does this matter?

It allows restricting access to the SSH agent when forwarded another host.

Let's say I ssh into a development machine on a client side client-dev and I need to forward the agent to access client's Git server client-git. Without the restriction an admin on the dev machine could use my forwarded agent to ssh into my Github account. With the restriction I can configure the SSH agent forwarded to client-dev to only sign requests from client-git and to disallow signing request from everything else.

Currently I'm using multiple SSH agents with different keys per client. But that's cumbersome and of course it's not supported by KeepassXC so it prevents me from keeping my SSH keys in KeepassXC.

see also the specification

@kgraefe kgraefe force-pushed the feature/ssh-agent-destination-contraints branch from 5ec70c3 to 34d0a9b Compare February 8, 2024 22:30
@droidmonkey
Copy link
Member

Does does the ca in "is_ca" refer to Certificate Authority?

@kgraefe
Copy link
Contributor Author

kgraefe commented Feb 9, 2024

Does does the ca in "is_ca" refer to Certificate Authority?

yes. I have not done this myself but apparently instead of relying on long-living host keys that are manually confirmed on first contact, you can use short-living host keys that are signed by a CA. In order to verify the host key you need the CA's public key. So if is_ca == true the keyblob does not contain the host key but the CA key.

@kgraefe kgraefe force-pushed the feature/ssh-agent-destination-contraints branch 2 times, most recently from 0497ce7 to 4edabff Compare February 9, 2024 13:41
Command: ./release-tool i18n lupdate

Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
This change adds testing all KeeAgentSettings fields including their XML
conversions by separately:
- verifying the default value,
- change the current to something else,
- convert the KeeAgentSettings object to XML,
- convert it back to a second KeeAgentSettings object,
- compare both objects to be equal and
- verify that the new value landed in the field of the second
  KeeAgentSettings object.

Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
@kgraefe kgraefe force-pushed the feature/ssh-agent-destination-contraints branch from 4edabff to 58bf74c Compare February 9, 2024 14:11
@kgraefe
Copy link
Contributor Author

kgraefe commented Feb 12, 2024

CI fails because openssh-client in Ubuntu 18.04 is too old and does not support destination constraints (requires OpenSSH 8.9, has 8.2). :-\ In general it is the desired behavior to fail instead of loading the key without the constraints in place.

However, how should I proceed with this? I can think of either

  • omitting the tests or somehow guard them against the SSH client version,
  • updating the Docker container to Ubuntu 22.04 LTS or
  • manually install newer openssh-client into the Docker container.

@kgraefe kgraefe force-pushed the feature/ssh-agent-destination-contraints branch 2 times, most recently from e6ff96b to 95f9e59 Compare February 19, 2024 15:53
This change implements loading ssh-agent destination constraints from
KeeAgent.settings into the ssh-agent. For now there is no UI so
configuration must be done in KeePass2/KeeAgent.

The ssh-agent constrain extension is described at [1]. However, I found
it partly misleading:
- in the constaint array each constraint is enveloped where in the
  keyspec arrays the keyspec are just appended to the constraint.
- each constraint and host has an additional string field reserved for
  future use.
The actual structure has been obtained from openssh ssh-add source code [2].

[1]: https://www.openssh.com/agent-restrict.html
[2]: https://github.com/openssh/openssh-portable/blob/3ad669f81aabbd2ba9fbd472903f680f598e1e99/authfd.c#L538

Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
@kgraefe kgraefe force-pushed the feature/ssh-agent-destination-contraints branch from 95f9e59 to 55c6cd2 Compare February 20, 2024 09:24
Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
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.

Allow setting destination constraints for each ssh key
2 participants