Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Pre-Charge max size when contracts access storage #10508

Closed
athei opened this issue Dec 17, 2021 · 0 comments · Fixed by #10691
Closed

Pre-Charge max size when contracts access storage #10508

athei opened this issue Dec 17, 2021 · 0 comments · Fixed by #10691
Labels
I2-security The client fails to follow expected, security-sensitive, behaviour.

Comments

@athei
Copy link
Member

athei commented Dec 17, 2021

Previously, we assumed that the size of a storage item can be accessed in constant time (not dependent on the item's size). However, this turns out to be untrue.

What we need to do every time we access a variable sized storage item:

  • Pre charge the maximum size this item can have from the gas meter before accessing it
  • Refund after reading the value and the real size of the item is known

This applies to:

  • Loading code for execution
  • Loading pristine code for re instrumentation
  • Reading contract values
  • Writing contract values (the previous size needs to be known for storage deposits)
  • Clearing contract values

This is also needed for #10301 because when reading the length of a storage value this requires the whole item to be included into the PoV.

@athei athei added the I2-security The client fails to follow expected, security-sensitive, behaviour. label Dec 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I2-security The client fails to follow expected, security-sensitive, behaviour.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant