-
Notifications
You must be signed in to change notification settings - Fork 304
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
test: add test to showcase kernel exploit #7190
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @LHerskind and the rest of your teammates on Graphite |
Benchmark resultsMetrics with a significant change:
Detailed resultsAll benchmarks are run on txs on the This benchmark source data is available in JSON format on S3 here. Proof generationEach column represents the number of threads used in proof generation.
L2 block published to L1Each column represents the number of txs on an L2 block published to L1.
L2 chain processingEach column represents the number of blocks on the L2 chain where each block has 8 txs.
Circuits statsStats on running time and I/O sizes collected for every kernel circuit run across all benchmarks.
Stats on running time collected for app circuits
AVM SimulationTime to simulate various public functions in the AVM.
Public DB AccessTime to access various public DBs.
Tree insertion statsThe duration to insert a fixed batch of leaves into each tree type.
MiscellaneousTransaction sizes based on how many contract classes are registered in the tx.
Transaction size based on fee payment method | Metric | | |
A fix is fairly easy, simply need to assert that the However, some of the tests gets kinda rekt with it, because many of the private_execution tests are calling functions directly and abusing the msg_sender in there. |
@sirasistant or @LeilaWang, might make sense for one of you to look at this? Not fully sure what you guys think is the best way to do it and update all of the tests that it will break. |
Fixes exploit as first written here #7190. Essentially, a user calling a contract directly (bypassing the account contract) could impersonate any chosen address. This PR adds a check in the private init kernel to prevent setting the `msg_sender`. Commits are: - [7c08eab](7c08eab) -> [35ed54b](35ed54b) - shows exploit working in `token_contract` test - apologies for the format fails (taken exactly from Lasse's PR #7190, slight change to allow for direct call) - [4072ae3](4072ae3) -> [b7f5987](b7f5987) - shows fix to exploit and edits above test to expect a fail (=> a pass on `token_contract` means exploit is fixed) - [85da5a9](85da5a9) - removes test code from `token_contract`
This should be fixed in #7404 so closing this. |
Figured that the
msg_sender
that can be passed in during simulation is actually not constrained and blindly used. So if you bypass the account contract (where it does not really matter in most cases) and instead call private functions directly, you can use them as an entry point, but at the same time convince them that you called from some other contract.This essentially allow you to set
msg_sender
at will, and is extremely dangerous, since you can use to to impersonate whoever you want.In my case, I use it to impersonate a minter and mint some nice tokens for the attacker. In there, I'm minting 10K tokens to him, but he could really do whatever he want.
I don't think we are able to impersonate on public calls right now, but might just be because it is a little impractical to do atm. Nevertheless, this have to be fixed.