President Elector

First Flight #24
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Missing Nonce in Signatures Leading to Replay Attack

Summary

The rankCandidatesBySig function lacks the inclusion of the nonce in signed messages, creating a vulnerability to potential signature replay attacks.

Vulnerability Details

Signatures provide a means of cryptographic authentication in blockchain technology, serving as a unique “fingerprint”, forming the backbone of blockchain transactions. Signatures for previous or pending transactions can be replayed by attackers, if not handled correctly, meaning that attackers pass the validation checks and the malicious transactions are executed.

function rankCandidatesBySig(
address[] memory orderedCandidates,
bytes memory signature
) external {
bytes32 structHash = keccak256(abi.encode(TYPEHASH, orderedCandidates));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, signature);
_rankCandidates(orderedCandidates, signer);
}

The absence of the nonce can allow attackers to repeatedly exploit captured signatures for fraudulent transactions.

Impact

Essentially a unique identifier or a 'number used once' for each transaction, a nonce is integral to security. Its absence can allow someone like Bob to repeatedly exploit Alice's captured signature for fraudulent transactions.

Tools Used

Recommendations

To mitigate this, include a mapping to keep track of each signer’s last used nonce:

mapping (address => uint256) public nonces;
.......
function rankCandidatesBySig( address[] memory orderedCandidates, bytes memory signature
) external {
.......
// @audit - nonce needs to be encoded here to prevent replay
bytes32 hash = _hashTypedDataV4(structHash);
};
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Replay Attack - The same signature can be used over and over

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.