sherlock-audit / 2024-06-makerdao-endgame-judging

1 stars 1 forks source link

JuggerNaut63 - Replay Attack in VoteDelegateFactory Contract Creation Mechanism #69

Closed sherlock-admin4 closed 1 month ago

sherlock-admin4 commented 1 month ago

JuggerNaut63

Medium

Replay Attack in VoteDelegateFactory Contract Creation Mechanism

Summary

create function uses a deterministic salt derived from msg.sender for the create2 opcode. This approach can lead to replay attacks, where the same user can only create one VoteDelegate contract, and any subsequent attempts will fail due to address collision.

Vulnerability Detail

Issue: The create function uses create2 with a salt derived from msg.sender:

voteDelegate = address(new VoteDelegate{salt: bytes32(uint256(uint160(msg.sender)))}(chief, polling, msg.sender));

Problem: If the same user (msg.sender) calls create more than once, the salt remains the same, leading to the same contract address being generated. Since the address is already occupied by the first contract creation, subsequent calls will fail.

Impact

Code Snippet

https://github.com/sherlock-audit/2024-06-makerdao-endgame/blob/main/vote-delegate/src/VoteDelegateFactory.sol#L61-L66

Tool used

Manual Review

Recommendation

function create() external returns (address voteDelegate) {

sunbreak1211 commented 1 month ago

First of all the usage of "Replay Attack" here is pretty weird as it doesn't seem it is understood what it means. Secondly this is not a bug, if the contract was already created, it is ok to revert when trying to do it again. There is not a denial of service at all, the msg.sender already has a voteDelegate created.