-
Notifications
You must be signed in to change notification settings - Fork 790
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
Fix the vulnerability found in issue #3861 #3863
Fix the vulnerability found in issue #3861 #3863
Conversation
Co-authored-by: Lexterl33t <bryton@fuzzinglabs.com>
Co-authored-by: mhoste51 <mathieu@fuzzinglabs.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments! 😄 👍
Co-authored-by: mhoste51 <mathieu@fuzzinglabs.com>
…eumjs-monorepo into patch-pushn-fuzzinglabs
LGTM, thanks, will leave this open for one more review. Have changed the code to run minimal extra logic per PUSH (only a length check) and in the edge case of the PUSH being at the end of the code, then |
Wait, never mind, this does not fix the case if jump analysis has been done:
if (!runState.shouldDoJumpAnalysis) {
runState.stack.push(runState.cachedPushes[runState.programCounter])
runState.programCounter += numToPush
// This case is still wrong
} else {
let loadedBytes = runState.code.subarray(
runState.programCounter,
runState.programCounter + numToPush,
)
if (loadedBytes.length < numToPush) {
loadedBytes = setLengthRight(loadedBytes, numToPush)
}
runState.programCounter += numToPush
runState.stack.push(bytesToBigInt(loadedBytes))
}
Ok, interesting, I just realized that the original code only fixes in the case if there is no JUMPDEST analysis being done. In practice / live networks, this is always done: it is necessary to find if the target we are JUMPing to is a valid JUMPDEST (and not a byte which looks like JUMPDEST but which is actually part of a PUSH opcode). So once a contract hits their first (succesful) JUMP we have to do the analysis. This is a more complex test case than the simple test case of "just" the code of truncated PUSH opcodes, but it would be interesting to see if the fuzzer would also find this, more complex case :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix the vulnerability found in issue #3861
Description
This PR addresses the non-compliance issue with the
PUSHN
opcodes in EthereumJS, as described in issue #3861.Previously, when a
PUSH
instruction had fewer bytes available than required, the missing bytes were not properly zero-padded to align with the Ethereum Yellow Paper specification.This led to inconsistencies between EthereumJS and other EVM implementations like REVM and SputnikVM, which correctly apply right-aligned zero-padding.
Fix Implemented
PUSHN
opcodes always zero-pad missing bytes, right-aligning the values as per the Yellow Paper.