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

Fix: memory corruption from nested internal function calls #2345

Merged
merged 5 commits into from
Apr 11, 2021

Conversation

iamdefinitelyahuman
Copy link
Contributor

What I did

Fix a runtime bug allowing for memory corruption when making an internal function call inside a literal array or another function call.

The issue is the same as the one outlined in GHSA-2r3x-4mrv-mcxf and fixed in #2186. In my previous fix I did not fully comprehend the scope of the issue, and so the bug was still present when making a private function call inside a literal array, or when accessing a single indexed value from a private function call returning a list or tuple.

How I did it

Expand the logic added in #2186, applying it also to Subscript and List nodes. I have refactored the check into it's own new function, parse_sequence, which is applied on all lists, tuples, and private function calls. There is some recursive logic to account for multidimensional arrays.

How to verify it

Run the tests. I've included some new cases - awful code that nobody should ever write, that would cause the bug to appear in very many varieties (if it were still around).

Cute Animal Picture

image

vyper/parser/self_call.py Show resolved Hide resolved
vyper/parser/expr.py Show resolved Hide resolved
@fubuloubu fubuloubu merged commit 11b7b5b into vyperlang:master Apr 11, 2021
@iamdefinitelyahuman iamdefinitelyahuman deleted the fix-parse-sequence branch April 11, 2021 15:41
@skellet0r skellet0r mentioned this pull request Apr 12, 2021
16 tasks
skellet0r added a commit to skellet0r/curve-contract that referenced this pull request Apr 19, 2021
Additional improvements to mitigate memory corruption bug in vyper.
Additional optimizations.

vyperlang/vyper#2345
vyperlang/vyper#2350
vyperlang/vyper#2352
skellet0r added a commit to skellet0r/curve-contract that referenced this pull request Apr 29, 2021
Additional improvements to mitigate memory corruption bug in vyper.
Additional optimizations.

vyperlang/vyper#2345
vyperlang/vyper#2350
vyperlang/vyper#2352
oddcommit pushed a commit to oddcommit/curve-contract that referenced this pull request Dec 30, 2023
Additional improvements to mitigate memory corruption bug in vyper.
Additional optimizations.

vyperlang/vyper#2345
vyperlang/vyper#2350
vyperlang/vyper#2352
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