Fix - Direct mapping CPI caller privilege escalation after ownership transfer#6709
Merged
Lichtso merged 3 commits intoanza-xyz:masterfrom Jun 28, 2025
Conversation
|
The Firedancer team maintains a line-for-line reimplementation of the |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #6709 +/- ##
=========================================
- Coverage 83.3% 83.3% -0.1%
=========================================
Files 852 852
Lines 377899 377901 +2
=========================================
- Hits 315097 315089 -8
- Misses 62802 62812 +10 🚀 New features to boost your workflow:
|
LucasSte
reviewed
Jun 24, 2025
LucasSte
previously approved these changes
Jun 25, 2025
… account instead of a writable one.
…ged the owner at the CPI call edge.
87574cf to
8fe4954
Compare
LucasSte
approved these changes
Jun 27, 2025
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.
Problem
In the original direct mapping implementation a CPI caller can transfer the ownership of an account to a callee before CPI, pass it as a read-only instruction account to a callee during CPI, and then after CPI returns, it is still possible for the caller to write to the account it no longer owns.
Credit for finding this goes to Felix Wilhelm and for testing it goes to Troy Sargent.
Summary of Changes
First demonstrates the issue by slightly adjusting
TEST_FORBID_WRITE_AFTER_OWNERSHIP_CHANGE_IN_CALLER. Then fixes the issue inupdate_callee_account()by settingmust_update_callerif the owner changes on the CPI call edge.