Nonces not used in signed data
The signature verification in a smart contract vault did not include a nonce, so two signed transactions could be reordered by a malicious miner. This could cause an insecure recipient address to take effect instead of a later secure one, allowing the attacker to transfer funds.
Source: https://github.com/sherlock-audit/2022-09-harpie-judging/tree/main/160-M
Found by
IllIllI
Summary
Nonces are not used in the signature checks
Vulnerability Detail
A nonce can prevent an old value from being used when a new value exists. Without one, two transactions submitted in one order, can appear in a block in a different order
Impact
If a user is attacked, then tries to change the recipient address to a more secure address, initially chooses an insecure compromised one, but immediately notices the problem, then re-submits as a different, uncompromised address, a malicious miner can change the order of the transactions, so the insecure one is the one that ends up taking effect, letting the attacker transfer the funds
Code Snippet
Tool used
Manual Review
Recommendation
Include a nonce in what is signed
Harpie Team
Fixed by changing nonce system to an incremental system. Fix here.
Lead Senior Watson
Not an issue AFAIK, miners can't reorder txs unless they are signed with the same nonce. There would have to be some serious mis-use of this function by the recipient address, i.e. they would have to ask the server to sign for two different addresses and then broadcast the txs with the same nonce for this call. The proposed fix could probably be safely removed but doesn't hurt to keep it there.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the signed data lacked a nonce, so signatures were not bound to a specific transaction order or uniqueness.
Impact
A malicious miner could reorder transactions so an insecure recipient address takes effect, letting the attacker transfer funds; however, the lead reviewer notes miners cannot reorder transactions unless they share the same nonce, so the issue may require misuse by the recipient.
What the attacker needed
Attacker can reorder transactions; recipient requests signatures for two addresses
The fix
The team fixed it by changing to an incremental nonce system, though the lead reviewer suggested the fix could probably be safely removed.
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.
A nonce is a number used once to make each signed message unique. Without it, two signed messages can be swapped in order by whoever orders transactions, like a miner. Here, that could let an attacker's chosen address win over a safer one.
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.