Skip to content

fix(lang): guard AccountLoader against buffer truncation#4633

Open
swaroop-osec wants to merge 12 commits into
otter-sec:masterfrom
swaroop-osec:fix/accountloader-realloc
Open

fix(lang): guard AccountLoader against buffer truncation#4633
swaroop-osec wants to merge 12 commits into
otter-sec:masterfrom
swaroop-osec:fix/accountloader-realloc

Conversation

@swaroop-osec

@swaroop-osec swaroop-osec commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds buffer-size checks in AccountLoader::try_from and AccountLoader::exit. If the buffer is undersized:

  • try_from returns AccountDidNotDeserialize (3003) up front instead of constructing a loader over a buffer that any subsequent load/load_mut/exit call would reject.
  • exit returns AccountDidNotDeserialize (3003) instead of rewriting the discriminator over a truncated body and aborting the tx.

@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

@swaroop-osec is attempting to deploy a commit to the OtterSec Team on Vercel.

A member of the Team first needs to authorize it.

@socket-security

socket-security Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​types/​node@​14.17.33 ⏵ 17.0.2110010081 +296100
Addednpm/​prettier@​2.8.0851009893100

View full report

Comment thread lang/src/accounts/account_loader.rs
@swaroop-osec swaroop-osec requested a review from 0x4ka5h June 8, 2026 12:39
@swaroop-osec swaroop-osec added lang fix Bug fix PR labels Jun 8, 2026
0x4ka5h
0x4ka5h previously approved these changes Jun 8, 2026

@0x4ka5h 0x4ka5h left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm now

@socket-security

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm prettier is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ts/packages/anchor-errors/package.jsonnpm/prettier@2.8.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/prettier@2.8.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@swaroop-osec

Copy link
Copy Markdown
Collaborator Author

@0x4ka5h Dropped the try_from check since it rejects valid-but-smaller legacy accounts before realloc can grow them (breaking zero-copy migrations), and load* already have size-check anyway. Kept the exit guard, which is the actual fix intended and added test covering the migration flow.

Please re-review

@swaroop-osec swaroop-osec requested a review from 0x4ka5h June 10, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix PR lang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants