In the above withdraw function in the Shelter contract, the claimed mapping is never checked to see if the msg.sender has already claimed their tokens already. As a result, the user can keep on claiming and claiming until all of the tokens are stolen. Furthermore, the _to parameter is used in the claimed[_token][_to] = true; definition. This allows the attacker to claim their own token amount under another EOA's address. An attacker with money locked in the shelter can generate an infinite amount of EOAs and call the withdraw function with those addresses in the _to field from the attacker's address and steal all the tokens since the _to is changing every time and the msg.sender is kept consistent.
Tools Used
Manual analysis
Recommended Mitigation Steps
I'd recommend removing the _to variable and using msg.sender instead. Additionally, the claimed mapping should be checked to see if the user has already claimed their tokens.
Lines of code
https://github.com/code-423n4/2022-02-concur/blob/main/contracts/Shelter.sol#L52-L58
Vulnerability details
Impact
https://github.com/code-423n4/2022-02-concur/blob/main/contracts/Shelter.sol#L52-L58
In the above
withdraw
function in the Shelter contract, theclaimed
mapping is never checked to see if themsg.sender
has already claimed their tokens already. As a result, the user can keep on claiming and claiming until all of the tokens are stolen. Furthermore, the_to
parameter is used in theclaimed[_token][_to] = true;
definition. This allows the attacker to claim their own token amount under another EOA's address. An attacker with money locked in the shelter can generate an infinite amount of EOAs and call the withdraw function with those addresses in the_to
field from the attacker's address and steal all the tokens since the_to
is changing every time and themsg.sender
is kept consistent.Tools Used
Manual analysis
Recommended Mitigation Steps
I'd recommend removing the
_to
variable and usingmsg.sender
instead. Additionally, theclaimed
mapping should be checked to see if the user has already claimed their tokens.