Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

program: safe deserialize instruction #42

Merged
merged 3 commits into from
Nov 8, 2024
Merged

Conversation

buffalojoec
Copy link
Contributor

Problem

Similar to solana-program/config#16, the Address Lookup Table program imposes a limit on the provided instruction buffer length. However, the ExtendLookupTable instruction uses a vector of pubkeys, resulting in a vector length stored in the first 8 bytes of the buffer after the discriminator.

If that vector length is very large, even if the rest of the buffer is invalid, the allocator in the BPF version will attempt to allocate a large vector and exhaust the heap.

Summary of Changes

Add a safe_deserialize_instruction helper to check the vector length before attempting deserialization.

@buffalojoec buffalojoec requested a review from joncinque November 7, 2024 16:28
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

This makes sense to me! Just a few little bits for maintenance

program/src/processor.rs Outdated Show resolved Hide resolved
program/src/processor.rs Show resolved Hide resolved
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@buffalojoec buffalojoec merged commit cf11c00 into main Nov 8, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants