Skip to content

fix key generation for dual auths sharing a single YubiHSM2#36899

Merged
nklaassen merged 1 commit intomasterfrom
nklaassen/fix-shared-yubihsm
Jan 23, 2024
Merged

fix key generation for dual auths sharing a single YubiHSM2#36899
nklaassen merged 1 commit intomasterfrom
nklaassen/fix-shared-yubihsm

Conversation

@nklaassen
Copy link
Copy Markdown
Contributor

Fixes #36838

The bug is caused by the way key IDs are selected for YubiHSM. It only supports 2 byte keys, so we iterate all keys sequentially until we find one that is unused. The problem is that when looking up the key to check if it is used we currently include a label filter that only returns keys labelled with the host UUID of the auth server making the request. This will not find keys created by a different auth server, and is very likely to select an ID already in use by a different auth server, so the ID will collide and the new key can't be created. The fix here is to simply remove the label filter to check if that ID is already used in the YubiHSM at all.

Changelog: fixes CA key generation when two auth servers share a single YubiHSM2

@nklaassen
Copy link
Copy Markdown
Contributor Author

friendly ping @fheinecke @hugoShaka

@nklaassen nklaassen enabled auto-merge January 23, 2024 01:42
@nklaassen nklaassen added this pull request to the merge queue Jan 23, 2024
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from fheinecke January 23, 2024 15:55
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 23, 2024
@nklaassen nklaassen added this pull request to the merge queue Jan 23, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 23, 2024
@nklaassen nklaassen added this pull request to the merge queue Jan 23, 2024
Merged via the queue into master with commit baeb269 Jan 23, 2024
@nklaassen nklaassen deleted the nklaassen/fix-shared-yubihsm branch January 23, 2024 18:49
@public-teleport-github-review-bot
Copy link
Copy Markdown

@nklaassen See the table below for backport results.

Branch Result
branch/v12 Failed
branch/v13 Failed
branch/v14 Failed
branch/v15 Create PR

nklaassen added a commit that referenced this pull request Jan 25, 2024
nklaassen added a commit that referenced this pull request Jan 25, 2024
Backport #36899 to branch/v13

The actual fix is a few characters in lib/auth/keystore/pkcs11.go.
I'm also backporting changes to test files from #36549 that this PR built on
top of, which make it easier to run all HSM unit and integration tests
with a connected YubiHSM2 (which I did when putting together this
backport).

Instead of merging all changes in the integration tests, I just checked
out the state of them from branch/v14 in
#37296
nklaassen added a commit that referenced this pull request Jan 26, 2024
Backport #36899 to branch/v12

The actual fix is a few characters in lib/auth/keystore/pkcs11.go.
I'm also backporting changes to test files from #36549 that this PR built on
top of, which make it easier to run all HSM unit and integration tests
with a connected YubiHSM2 (which I did when putting together this
backport).

Instead of merging all changes in the integration tests, I just checked
out the state of them from branch/v13 in
#37301

Changelog: fixes CA key generation when two auth servers share a single YubiHSM2
github-merge-queue Bot pushed a commit that referenced this pull request Jan 26, 2024
…7301)

Backport #36899 to branch/v13

The actual fix is a few characters in lib/auth/keystore/pkcs11.go.
I'm also backporting changes to test files from #36549 that this PR built on
top of, which make it easier to run all HSM unit and integration tests
with a connected YubiHSM2 (which I did when putting together this
backport).

Instead of merging all changes in the integration tests, I just checked
out the state of them from branch/v14 in
#37296
github-merge-queue Bot pushed a commit that referenced this pull request Jan 26, 2024
github-merge-queue Bot pushed a commit that referenced this pull request Jan 29, 2024
…7305)

Backport #36899 to branch/v12

The actual fix is a few characters in lib/auth/keystore/pkcs11.go.
I'm also backporting changes to test files from #36549 that this PR built on
top of, which make it easier to run all HSM unit and integration tests
with a connected YubiHSM2 (which I did when putting together this
backport).

Instead of merging all changes in the integration tests, I just checked
out the state of them from branch/v13 in
#37301

Changelog: fixes CA key generation when two auth servers share a single YubiHSM2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

second auth with same YubiHSM can't create new CA keys

3 participants