You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add mint and owner validation in the idempotent ATA early return path so that an existing account for a different mint/owner is not silently accepted.
Summary by CodeRabbit
Bug Fixes
Implemented validation checks during token account creation to verify that stored mint and owner values align with requested values. Detects and prevents mismatches, reporting failures clearly to maintain data integrity and ensure correct token account configurations.
Audit issue #4 (LOW): The idempotent ATA path returned Ok() when the
account was already owned by the program without verifying the stored
mint and owner matched the requested values. Add Token deserialization
and field checks before the early return.
This change adds runtime verification to the idempotent ATA creation path by validating that stored mint and owner match requested values. If either field mismatches, a specific error is emitted; if both match, execution continues as before.
Changes
Cohort / File(s)
Summary
ATA Creation Validation programs/compressed-token/program/src/ctoken/create_ata.rs
Added pubkey_eq import and runtime verification logic in the idempotent path to compare stored mint and owner against requested values, emitting "MintMismatch" or "OwnerMismatch" errors on failure.
Estimated code review effort
🎯 1 (Trivial) | ⏱️ ~5 minutes
Suggested labels
ai-review
Suggested reviewers
sergeytimoshin
SwenSchaeferjohann
Poem
🔐 A token's identity now stands guard,
Idempotent paths less scarred,
Mint and owner locked in place—
No silent mismatches win this race! ✨
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title accurately describes the main change: adding verification of mint and owner values in the idempotent ATA early return path, which is the core security fix addressed in the changeset.
Docstring Coverage
✅ Passed
Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch fix/audit-issue-4-idempotent-ata-checks
No actionable comments were generated in the recent review. 🎉
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.
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
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.
Summary
Summary by CodeRabbit
Bug Fixes