fix(native): bind mm-oracle kill switch to State PDA - #2204
Conversation
The native [0xFF;4] path reads the feature enable bit from accounts[3] without checking it is the drift_state PDA. Owner-only checks still allow any large Drift-owned account to spoof that bit. Validate PDA + owner + length before the feature-bit read. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe native MM oracle update handler now validates required accounts, confirms the canonical program-owned ChangesNative MM Oracle Validation
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
handle_update_mm_oracle_native(reached via the[0xFF;4]native entry inlib.rs) reads the MM-oracle feature enable bit fromaccounts[3].data[982]without verifying that account is the canonicaldrift_statePDA.Owner-only hardening (see also open #2110) is necessary but not sufficient: any sufficiently large Drift-owned account could still spoof the enable bit. This PR binds
accounts[3]toPubkey::find_program_address(&[b"drift_state"], program_id)and requires program ownership + length before the feature-bit check.Complementary to #2110 (owner/len/clock) — this change is intentionally additive and focused on PDA identity.
Test plan
drift_stateDrift-owned account in slot 3 fails the new assertMade with Cursor
Summary by CodeRabbit