Skip to content

fix: eliminate TOCTOU race in RunState.load() - #3908

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/load-state-toctou-v2
Open

fix: eliminate TOCTOU race in RunState.load()#3908
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/load-state-toctou-v2

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Problem

RunState.load() checks exists() then calls open(). Between the two calls the file can be deleted, causing a raw FileNotFoundError instead of the intended custom message.

Fix

Remove the exists() pre-check and wrap open() in try/except FileNotFoundError.

Testing

  • Verified custom error message is raised when state.json is missing

Remove exists() pre-check and wrap open() in try/except FileNotFoundError
to provide a clear custom error message even under race conditions.
@Quratulain-bilal
Quratulain-bilal requested a review from mnriem as a code owner July 31, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant