Skip to content

Conversation

@0xIchigo
Copy link
Contributor

This PR aims to introduce an ownership check on Anchor's account reload method, resolving #3830

@vercel
Copy link

vercel bot commented Aug 12, 2025

@0xIchigo is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@jacobcreech jacobcreech requested a review from Aursen August 12, 2025 15:13
@jacobcreech jacobcreech moved this to In Progress in Anchor 1.0 Aug 15, 2025
@0xIchigo 0xIchigo requested a review from jamie-osec August 21, 2025 15:40
@swaroop-osec
Copy link
Collaborator

@0xIchigo Can you please fix the failed tests?

@swaroop-osec swaroop-osec added the enhancement New feature or request label Oct 23, 2025
@jamie-osec
Copy link
Collaborator

See #3819, which removed the solana-program dep from lang

@0xIchigo
Copy link
Contributor Author

@swaroop-osec @jamie-osec all good now 🫡

@vercel
Copy link

vercel bot commented Oct 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
anchor-docs Ignored Ignored Preview Oct 27, 2025 9:49pm

@nutafrost nutafrost moved this from In Progress to Security Review Required in Anchor 1.0 Oct 28, 2025
Copy link
Collaborator

@0x4ka5h 0x4ka5h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm aswell

@nutafrost nutafrost moved this from Security Review Required to Security Review Done in Anchor 1.0 Nov 5, 2025
@nutafrost nutafrost assigned jacobcreech and unassigned swaroop-osec Nov 5, 2025
@nutafrost nutafrost added the Merge label Nov 5, 2025
@jacobcreech jacobcreech merged commit 3a799e2 into solana-foundation:master Nov 19, 2025
56 checks passed
@github-project-automation github-project-automation bot moved this from Security Review Done to Done in Anchor 1.0 Nov 19, 2025
Comment on lines -220 to +251
if info.owner == &system_program::ID && info.lamports() == 0 {
return Err(ErrorCode::AccountNotInitialized.into());
}
T::check_owner(info.owner)?;
let mut data: &[u8] = &info.try_borrow_data()?;
Ok(Self::new(info, T::try_deserialize(&mut data)?))
// `InterfaceAccount` targets foreign program accounts (e.g., SPL Token
// accounts) that do not have Anchor discriminators. Because of that, we
// intentionally skip the Anchor discriminator check here and instead:
//
// 1) Validate program ownership via `T::check_owner(info.owner)?`
// 2) Deserialize without a discriminator by delegating to
// `T::try_deserialize_unchecked`
Self::try_from_unchecked(info)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect because InterfaceAccount does not make any assumptions about discriminators. anchor-spl just provides some types that can be used with InterfaceAccount and Interface, similar to how it provides types that can be used with Account and Program. The InterfaceAccount implementation itself has no idea about those types.

This change introduces a critical vulnerability by allowing unexpected account substitution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Merge

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants