Signature malleability not protected against
The project used a vulnerable version of OpenZeppelin's ECDSA library that allowed signature malleability, enabling an attacker to replay a previously signed change-recipient request. This could let an attacker revert a user's corrected recipient address back to a compromised one, potentially causing loss of funds.
Source: https://github.com/sherlock-audit/2022-09-harpie-judging/tree/main/010-M
Found by
0xNazgul, pashov, IllIllI, ladboy233, defsec, sirhashalot
Summary
OpenZeppelin has a vulnerability in versions lower than 4.7.3, which can be exploited by an attacker. The project uses a vulnerable version
Vulnerability Detail
All of the conditions from the advisory are satisfied: the signature comes in a single bytes argument, ECDSA.recover() is used, and the signatures themselves are used for replay protection checks
https://github.com/OpenZeppelin/openzeppelin-contracts/security/advisories/GHSA-4h98-2769-gh6h
If a user calls changeRecipientAddress(), notices a mistake, then calls changeRecipientAddress() again, an attacker can use signature malleability to re-submit the first change request, as long as the old request has not expired yet.
Impact
The wrong, potentially now-malicious, address will be the valid change recipient, which could lead to the loss of funds (e.g. the attacker attacked, the user changed to another compromised address, noticed the issue, then changed to a whole new account address, but the attacker was able to change it back and withdraw the funds to the unprotected address).
Code Snippet
https://github.com/Harpieio/contracts/blob/97083d7ce8ae9d85e29a139b1e981464ff92b89e/package.json#L23
Tool used
Manual Review
Recommendation
Change to version 4.7.3
Lead Senior Watson
Good find and the fix seems straightforward. Upgrade OZ.
Harpie Team
Updated openzeppelin NPM package to do ECDSA 4.7.3. Fix here.
Lead Senior Watson
Confirmed fix.
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
The project used an OpenZeppelin version below 4.7.3, which did not protect against ECDSA signature malleability, and the contract relied on the signature for replay protection.
Impact
The wrong, potentially malicious, address becomes the valid change recipient, which could lead to loss of funds.
What the attacker needed
User calls changeRecipientAddress twice; old request not expired; attacker can submit transactions
The fix
The project upgraded the OpenZeppelin NPM package to version 4.7.3, which includes the ECDSA fix.
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.
Digital signatures normally prove that a message came from you and hasn't been changed. Signature malleability means someone can take your signature and tweak it slightly so it still looks valid but is technically a different signature. If a system uses the signature itself to prevent replay (reusing the same signed message), an attacker can bypass that check and resubmit an old request.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.