fix: TOCTOU race in openbao secret-manager script - #813
Merged
Conversation
The secret-manager job classified an unreachable/sealed vault the same as "secret does not exist" (both a non-zero `bao kv get`), so it could overwrite a live random secret if it raced the unseal job. Distinguish those cases explicitly and make writes self-defending instead of trusting the read: - kv_status() classifies existence by HTTP status from /v1/secrets/metadata/ (matches what -cas checks) instead of a plain CLI exit code, with connect/max timeouts so a hung vault can't wedge the job - random secrets are written with -cas=0, so even a wrong "missing" read gets rejected server-side instead of clobbering - apply the same status-based check + CAS guard to the AIWB scoped token mint/rotation, which had the identical blind-overwrite bug - guard envsubst substitutions and count/report failures instead of swallowing them under set -e, so the job actually exits non-zero on partial failure - offset the cronjob schedule from the unseal job's to shrink the overlap window (defense in depth; -cas=0 is the real guard) - give the init Job an activeDeadlineSeconds, since it can now legitimately exit non-zero where it previously always exited 0
lauri-amd
marked this pull request as ready for review
August 18, 2026 12:34
Q-Dub
approved these changes
Aug 18, 2026
Q-Dub
left a comment
Contributor
There was a problem hiding this comment.
validated via test plan in Jira: https://amd.atlassian.net/browse/EAI-8139
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The secret-manager job classified an unreachable/sealed vault the same as "secret does not exist" (both a non-zero
bao kv get), so it could overwrite a live random secret if it raced the unseal job. Distinguish those cases explicitly and make writes self-defending instead of trusting the read: