-
Notifications
You must be signed in to change notification settings - Fork 171
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
Security risk: No compute meter checks for straight line programs #187
Comments
As a separate but related question, is JIT currently enabled on mainnet? Edit: my understanding - no, as
|
We are aware that linear programs can dramatically overrun before they are stopped by an exit branch. However, it was not deemed much of a threat yet, because the cost function and compute-meter economics are still very simple. This will become more of a problem when programs can chose to pay for less and use less / only what they actually need, then they could run disproportionally longer than what they payed for.
We have a standalone CLI tool that you can play around with.
It is optional but enabled by default. ConclusionWe can address this in a general overhaul of the instruction meter which would:
Thanks for all your hints and contributions. I just wanted to add that you should read and follow our security policy & guideline, that way you would also be eligible for the bounty program. |
Problem
A program can be a maximum of 10MB, or roughly
1_250_000
opcodes (8 bytes per opcode). Since there are no compute meter checks for straight line programs, a program can exceed their compute budget willfully.Solution
Either:
emit_validate_and_profile_instruction_count
emit_validate_and_profile_instruction_count
, reset counter. If counter exceedsSTRAIGHT_LINE_VALIDATE_THRESHOLD: u64 = 1000
, doemit_validate_and_profile_instruction_count
. This ensures that at most, a program will exceed the given budget by 1000.Misc
This also suggests that 10MB programs may be a little too large to do JIT for on-demand - suggesting that programs of a certain size (> 100_000 opcodes) should be JITed asynchronously and interpreted on-demand until JIT is ready.
Will be interested to see JIT timings for programs of varying length.
The text was updated successfully, but these errors were encountered: