Skip to content

Commit 752bb08

Browse files
Transit: fix race in the key update api (#28839)
- The key update API would release the lock a little too early after it persisted the update so the reference could be updated when it was preparing the response to the caller across updates and/or key rotations - The storage updates were okay, just the response back to the caller of the update might see a mixture of different updates
1 parent c855f6e commit 752bb08

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

builtin/logical/transit/path_keys.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,10 @@ func (b *backend) pathPolicyWrite(ctx context.Context, req *logical.Request, d *
260260
if p == nil {
261261
return nil, fmt.Errorf("error generating key: returned policy was nil")
262262
}
263-
if b.System().CachingDisabled() {
264-
p.Unlock()
263+
if !b.System().CachingDisabled() {
264+
p.Lock(true)
265265
}
266+
defer p.Unlock()
266267

267268
resp, err := b.formatKeyPolicy(p, nil)
268269
if err != nil {

changelog/28839.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
secrets/transit: Fix a race in which responses from the key update api could contain results from another subsequent update
3+
```

0 commit comments

Comments
 (0)