-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
oidc: check for nil signing key on rotation #13716
Conversation
Logs
|
- bypass setting ExpireAt if signing key is nil in rotate - return err if singing key is nil in signPayload
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly minor nit, but otherwise looks good!
vault/identity_store_oidc_test.go
Outdated
@@ -985,15 +1097,33 @@ func TestOIDC_PeriodicFunc(t *testing.T) { | |||
} | |||
|
|||
// measure collected samples | |||
for i := range testSet.testCases { | |||
for i, cycle := range testSet.cycle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIt: cycle
could be an int since it's just used as a counter length reference. You could have something like:
for i := 0; i < cycle; i++ {
currentCycle := cycle + 1
...
}
The for loop above could be reworked to be something similar as well.
}, | ||
{ | ||
// don't set SigningKey to ensure its non-existence can be handled | ||
namedKey: &namedKey{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I wonder if it would be a bit more obvious that the cases are based on different toggles if we had a test helper that generated the named keys with setSigningKey and
setNextSigningKey` as params (which would also remove them from the testSet struct):
namedKey: testGenerateNamedKey("test-key-nil-signing-key", false, true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the namedKey would need to be removed from the testSet instead since we need to call generateAndSetKey with the storage for each test set. I can create an issue to track cleaning up these tests a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Description
Check for a nil signing key before performing a rotation and before signing payloads. This is to prevent panics in the event that a nil signing key was written to storage.
If the current signing key is nil during rotation, we will skip setting the ExpireAt and allow the next signing key to be rotated into the current. If the signing key is nil during sign payload, we will return an error.
Background
A panic can occur for any key which was created while being on a version < v1.9.0 but was rotated while being on v1.9.0.
Repro steps: