A malicious validator can front-run a deposit transaction for its public key by depositing a small amount with different withdrawal credentials, causing the later large deposit to retain the attacker's withdrawal credentials. This could allow the attacker to control the withdrawal of the larger deposit.
Frontrunning by malicious validator changing withdrawal credentials.
Proof of Concept
A malicious validator can frontrun depositEther transaction for its pubKey and deposit 1 ether for different withdrawal credential, thereby setting withdrawal credit before deposit of 32 ether by contract and thereby when 32 deposit ether are deposited, the withdrawal credential is also what was set before rather than the one being sent in depositEther transaction.
Recommended Mitigation Steps
Set withdrawal credentials for validator by depositing 1 ether with desired withdrawal credentials, before adding it in Operator Registry.
How exactly multiple deposits two the same validator using different withdrawal keys would work. While it would make sense that they would allow a one to many mapping, I am unable to confirm or deny this and therefore will leave the risk currently as High on the side of caution.
Strong find. Indeed in ETH specs we can see that in process_deposit(), if the pubkey is already registered, we just increase its balance, not touching the withdrawal_credentials. However the recommended mitigation does not really address the issue IMO, and the detail is quite lacking.
I think it is technically a non-issue because we will be controlling the addition/removal of validators. Should that eventually become open, we will have to look at the entire code from a different perspective to close security holes.
I think it is relevant, because the idea is to make the protocol controlled validators work for the attacker, because they inserted their own withdrawal credentials directly on the deposit contract.
From @denett
“The signature would be valid. The validator would still sign the message containing the credentials that they are front running with.” Only the validator can create a valid signature and we own the key to the validator.
Yea, so this is the root of it, the contest does not specify that Frax is the owner of all validators that are meant to be used with this protocol. Without stating that ahead of time for the Wardens to understand, I believe this to be a valid finding and the warden should be awarded.
:) I cannot guarantee anything in DeFi is safe. My understanding of this particular vulnerability is that it would require a validator to act maliciously by using a smaller than 32 ETH deposit to front run your deposit and enable them to control the withdrawal in the future. If the validator is owned by your team and the keys are never exploited, then I don’t see how the front ran signature could be generated.
Ya, I hear you lol. At least for this particular scenario we are ok then, according to the known bug. We can pay out for the bug because none of our team were aware of it and it is good to know for the future.
The original report as published on Code4rena, by parashar. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the deposit contract does not prevent multiple deposits for the same public key with different withdrawal credentials, and the beacon chain only uses the withdrawal credentials from the first deposit.
Impact
The attacker could control the withdrawal credentials of the validator, potentially stealing the 32 ether deposit; however, the report notes that if the validator is controlled by the protocol team, the attack may not be feasible.
What the attacker needed
Attacker controls a validator key; attacker can front-run transactions
The fix
Set withdrawal credentials for a validator by depositing 1 ether with the desired withdrawal credentials before adding it to the Operator Registry.
How it was found
Attacker observes a pending depositEther transaction for a validator public key.
Attacker submits a deposit of 1 ether for the same public key with their own withdrawal credentials, front-running the original transaction.
The original deposit of 32 ether is processed, but the withdrawal credentials remain those set by the attacker.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
When you deposit money for a validator, you also set who can withdraw it later. If someone else deposits a tiny amount for the same validator first with their own withdrawal address, the system may keep that address even after your larger deposit. This means the attacker could later withdraw the funds you deposited.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.