fix: synchronize DeclareIntent authorization commit per PID#106
Conversation
|
Could you do a quick pass to remove the redundant send_update_exec calls and duplicate lines from the lower half of the function? Once that is cleaned up, this is a definite merge! |
|
Thanks for the review!
From my review, each call appears to serve a distinct purpose in either an early-exit path or the PID-locked commit section, and all tests (including the new TOCTOU regression test) are passing. That said, I may be looking at a different section than the one you had in mind. Could you point me to the specific redundant |
|
I was reviewing the raw diff output and got completely tripped up by the text formatting. The "duplicate" lines I was looking at were actually just the diff's deletion markers that had lost their syntax highlighting in my terminal, making it look like the lines were duplicated. Your review is correct. You flawlessly migrated the send_update_exec calls into the atomic lock section and cleaned up the old paths. The implementation is rock solid. Sorry for the confusion, |
Description
Fixes #104
This PR fixes a TOCTOU race condition in
DeclareIntentwhere kernel taint state could change whileverifier.verify()was running, allowing stale authorization state to commit execution policy updates afterward.Root Cause
DeclareIntentpreviously followed this flow:Because the Cortex gRPC server is multi-threaded, taint state could escalate during the verification window. The final exec-policy commit was not synchronized with the taint re-check.
Fix
This PR introduces:
threading.Locksend_update_exec) under the same lockThe expensive
verify()phase intentionally remains outside the lock to avoid unnecessary contention and preserve concurrency.Type of Change
Testing
Verified locally with:
Added a regression test covering taint escalation during verification.
Checklist