Signature is malleable
The signature verification library used does not check for signature malleability, allowing a creator to produce a different valid signature for the same message and bypass the one-time acknowledgment restriction. An attacker could acknowledge an edge multiple times.
0x73696d616f Follow with 1337, ComposableSecurity and 8 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-04-titles-judging/issues/279
The protocol has acknowledged this issue.
Found by
0x73696d616f, 1337, ComposableSecurity, T1MOH, Yu3H0, ZdravkoHr., cducrest-brainbot, fibonacci, juan, xiaoming90, zigtur
Summary
The signature is malleable. When a signature is malleable, it means that it is possible to produce another valid signature for the same message (which also means the same digest).
If the intention is only to allow the creator to acknowledge an edge once, the creator can bypass this restriction because the signature is malleable, and the creator can create another signature to acknowledge an edge again.
Vulnerability Detail
The protocol relies on Solady's SignatureCheckerLib to verify that the signature provided is valid. Once a signature has been successfully verified, it will be marked as used in Line 49 below to prevent users from re-using or replaying the same signature.
The Solady's SignatureCheckerLib warns that the library does not check if a signature is non-malleable.
/// WARNING! Do NOT use signatures as unique identifiers:
/// - Use a nonce in the digest to prevent replay attacks on the same contract.
/// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts.
/// EIP-712 also enables readable signing of typed data for better user safety.
/// This implementation does NOT check if a signature is non-malleable.
library SignatureCheckerLib {
Based on the following code, a creator can only acknowledge an edge once because the digest of the signature to acknowledge an edge will be the same (assuming that data is not in use) every time. After a creator acknowledges an edge, the signature (which also means its digest) will be marked as used in Line 49 below, thus preventing the creator from acknowledging the edge again later using the same signature.
File: TitlesGraph.sol
39: /// @notice Modified to check the signature for a proxied acknowledgment.
40: modifier checkSignature(bytes32 edgeId, bytes calldata data, bytes calldata signature) {
41: bytes32 digest = _hashTypedData(keccak256(abi.encode(ACK_TYPEHASH, edgeId, data)));
42: if (
43: !edges[edgeId].to.creator.target.isValidSignatureNowCalldata(digest, signature)
44: || _isUsed[keccak256(signature)]
45: ) {
46: revert Unauthorized();
47: }
48: _;
49: _isUsed[keccak256(signature)] = true;
50: }
Impact
When a signature is malleable, it means that it is possible to produce another valid signature for the same message (which also means the same digest).
If the intention is only to allow the creator to acknowledge an edge once, the creator can bypass this restriction because the signature is malleable, and the creator can create another signature to acknowledge an edge again.
Code Snippet
Tool used
Manual Review
Recommendation
Consider verifying the s of the signature is within valid bounds to avoid signature malleability.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
revert("ECDSA: invalid signature 's' value");
}
Discussion
pqseags
This seems to be a duplicate of #273 @Hash01011122
WangSecurity
Planning to make a new issue family with this report as the main one. Planning to add the following duplicated:
- #9
- #53
- #105
- #178
- #228
- #345
- #429
0xjuaan
@WangSecurity add https://github.com/sherlock-audit/2024-04-titles-judging/issues/130, #10 to that list, they are currently incorrectly dupes of #273 which is a dos/frontrunning issue
Evert0x
@WangSecurity add #130, #10 to that list, they are currently incorrectly dupes of #273 which is a dos/frontrunning issue
Thank you!
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 signature verification library does not enforce non-malleability, so the same message can have multiple valid signatures, and the contract uses the signature itself as a unique identifier.
Impact
A creator could acknowledge an edge more than once, bypassing the intended one-time restriction.
What the attacker needed
Creator role on an edge
The fix
The signature's s value should be checked to be within valid bounds to prevent malleability.
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 are meant to prove who sent a message, but some signature schemes allow a second, different-looking signature to be valid for the same message. This is called malleability. Here, the contract tries to stop someone from using the same approval twice by remembering the signature, but because a different signature can be made for the same approval, the check can be bypassed.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.