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

keyring: Fix a panic when decrypting aead with empty RSA block. #24383

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

jrasell
Copy link
Member

@jrasell jrasell commented Nov 7, 2024

Closes: #24379

The code path exists in 1.9 and 1.8, so backporting to both even though reports suggest this is only occurring on 1.9.0+.

Clusters that have gone through several upgrades have be found to
include keyring material which has an empty RSA block.

In more recent versions of Nomad, an empty RSA block is omitted
from being written to disk. This results in the panic not being
present. Older versions, however, did not have this struct tag
meaning we wrote an empty JSON block which is not accounted for
in the current version.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

Assuming the file itself hasn't been corrupted on-disk, this case is supposed to be protected against by the block above where you've made a change. Older KEK wrapper versions with AEAD-only have the DEK ciphertext in a different field, and we're supposed to be restoring them here.

My hunch would be that there's an issue with those older keys. But unfortunately I tested this out with Nomad 1.4 and did a single-node upgrade to tip and didn't run into any problems.

For the time being, let's get this merged in because it'll prevent a panic.

Clusters that have gone through several upgrades have be found to
include keyring material which has an empty RSA block.

In more recent versions of Nomad, an empty RSA block is omitted
from being written to disk. This results in the panic not being
present. Older versions, however, did not have this struct tag
meaning we wrote an empty JSON block which is not accounted for
in the current version.
@jrasell jrasell changed the title keyring: Fix a panic when decrypting aead with missing ciphertext. keyring: Fix a panic when decrypting aead with empty RSA block. Nov 7, 2024
@jrasell jrasell added the backport/1.9.x backport to 1.9.x release line label Nov 7, 2024
@jrasell jrasell added backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/ent/1.9.x+ent Changes are backported to 1.9.x+ent labels Nov 7, 2024
@jrasell jrasell requested review from shoenig and tgross November 7, 2024 15:41
@jrasell jrasell marked this pull request as ready for review November 7, 2024 15:41
Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM!

Older versions, however, did not have this struct tag
🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/ent/1.9.x+ent Changes are backported to 1.9.x+ent backport/1.9.x backport to 1.9.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nomad 1.9.1: panic: runtime error: slice bounds out of range [:12] with capacity 0
2 participants