-
Notifications
You must be signed in to change notification settings - Fork 32
Harden VM against invalid inputs and add security checks #948
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
Conversation
This change introduces several security enhancements to the VM host to make it more robust against potentially malicious smart contract code. The following changes were made: - In `vmhooks/bigIntOps.go`, changed silent failures for out-of-range argument indexes to explicit execution failures. - In `vmhooks/manBufOps.go`, changed silent failures for out-of-bounds slice operations to explicit execution failures. - In `vmhooks/manBufOps.go`, added a `recover` block to `MBufferToBigFloat` to prevent panics in `GobDecode` from crashing the VM. - In `contexts/managedType.go`, improved the bounds checking in `GetSlice` to be safer against integer overflows. - In `hostCore/execution.go`, removed a redundant `defer` block to improve code clarity. - Updated several test scenarios to reflect the new, stricter error handling.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #948 +/- ##
=======================================
Coverage 36.22% 36.22%
=======================================
Files 87 87
Lines 20589 20600 +11
=======================================
+ Hits 7459 7463 +4
- Misses 12463 12467 +4
- Partials 667 670 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR hardens the VM against invalid inputs by replacing silent failures with explicit execution failures and adding security checks to prevent crashes from malicious smart contract code.
- Converts silent failures to explicit execution failures in
bigIntOps.goandmanBufOps.gofor out-of-range operations - Adds panic recovery to
MBufferToBigFloatto prevent VM crashes from malformed data - Improves bounds checking logic in
managedType.goto prevent integer overflow vulnerabilities
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vmhost/vmhooks/manBufOps.go | Converts silent bounds failures to explicit execution failures and adds panic recovery for GobDecode |
| vmhost/vmhooks/bigIntOps.go | Converts silent argument index failures to explicit execution failures |
| vmhost/contexts/managedType.go | Improves bounds checking to prevent integer overflow vulnerabilities |
| vmhost/hostCore/execution.go | Removes redundant defer block for code clarity |
| Multiple test files | Updates test expectations to reflect new error handling behavior |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
added to a new PR. |
This change introduces several security enhancements to the VM host to make it more robust against potentially malicious smart contract code.
The following changes were made:
vmhooks/bigIntOps.go, changed silent failures for out-of-range argument indexes to explicit execution failures.vmhooks/manBufOps.go, changed silent failures for out-of-bounds slice operations to explicit execution failures.vmhooks/manBufOps.go, added arecoverblock toMBufferToBigFloatto prevent panics inGobDecodefrom crashing the VM.contexts/managedType.go, improved the bounds checking inGetSliceto be safer against integer overflows.hostCore/execution.go, removed a redundantdeferblock to improve code clarity.