having -1 as offset in proxy storage slots #3232
Replies: 2 comments 1 reply
-
I haven't personally made any findings on this. @PatrickAlphaC, we could use some help here, sir. |
Beta Was this translation helpful? Give feedback.
-
The key concern revolves around how storage slots are allocated in proxy contracts. Here's the step by step explanation: In the ERC-1967 specification, important proxy data (like the implementation address) is stored at specific slots calculated as: bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) Without the -1 offset, an attacker could potentially:
This becomes dangerous because: By subtracting 1 from the hash: When Solidity allocates storage slots for state variables, it can only allocate slots based on the direct hash of values/strings, not a hash minus 1 Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
As i have seen we have -1 offset for the proxy storage slots
Implementation storage slot -
bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1))
Admin storage slot. -
bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1))
https://eips.ethereum.org/EIPS/eip-1967
i have googled for it and i have seen that those -1 have added because of a preimage attack , after going through some articles also still i didn't get it
preimage attack in the sense finding the input of the hash as we all know the input for the above storage slots and how can an attacker can able to change the Implementation slot address of a contract even if he know the preimage
Beta Was this translation helpful? Give feedback.
All reactions