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

Check lastPreimage != nil before accessing the cached preimage #114

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

mininny
Copy link
Collaborator

@mininny mininny commented Jan 7, 2025

Description

The Fast VM implementation assumes the last preimage read has been cached, even if this is the first read. Moreover, the preimage key is always initialized to zeroes ([32]byte{}) while the cached preimage value is initialized to a null pointer.

That means if either there's an attempt to read the preimage value before writing a key, or if the key written is zero, an attempt to access the null pointer will cause a panic.

Neither scenario should happen in a correct Kona implementation -- reads should always be preceded by writing the corresponding key, and a key with zero value isn't valid. However this is the oracle's concern and should be delegated to it.

@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.89%. Comparing base (8ff9318) to head (1203fc4).
Report is 25 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #114   +/-   ##
=======================================
  Coverage   61.89%   61.89%           
=======================================
  Files          27       27           
  Lines        4091     4091           
=======================================
  Hits         2532     2532           
  Misses       1427     1427           
  Partials      132      132           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mininny mininny added the Audit finding grouping for our audit findings label Jan 7, 2025
@mininny mininny requested a review from refcell January 7, 2025 05:02
@mininny mininny requested a review from refcell January 9, 2025 02:11
@BlocksOnAChain
Copy link

@refcell We can merge this one if you are happy with it.
Auditors gave us the green light to merge it, but wanted to your view on it, before we merge?

@BlocksOnAChain
Copy link

@mininny we can merge it once you are ready to do it.

@mininny mininny added this pull request to the merge queue Jan 15, 2025
Merged via the queue into master with commit f75a5bc Jan 15, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audit finding grouping for our audit findings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants