FIAT DAO veFDT contest - rvierdiiev's results

Unlock liquidity for your DeFi fixed income assets.

General Information

Platform: Code4rena

Start Date: 12/08/2022

Pot Size: $35,000 USDC

Total HM: 10

Participants: 126

Period: 3 days

Judge: Justin Goro

Total Solo HM: 3

Id: 154

League: ETH

FIAT DAO

Findings Distribution

Researcher Performance

Rank: 27/126

Findings: 3

Award: $186.99

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Findings Information

Labels

bug
duplicate
2 (Med Risk)
downgraded by judge

Awards

142.1501 USDC - $142.15

External Links

Lines of code

https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L403 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L635 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L418

Vulnerability details

Impact

If value provided to _value param in createLock function is bigger then MAX int128 then downcasting it to int128 will silently overflow. Lock amount will be negative and all operations will be locked, but all user tokens will be transferred to contract. User will lost tokens.

Description.

  1. Suppose that we have ERC20 token called BAD with total supply bigger then MAX int128 value.
  2. User use createLock function with _value param set to Y that bigger then MAX int128 . Because of downcasting locked_.amount value is negative now. Tokens are transferred to VotingEscrow.
  3. User wants to use quitLock function. As locked_.amount value is negative then lock can't be used. User has lost his tokens.

Proof of Concept

https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L403 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L418 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L635

Tools Used

Just created simple test where set value bigger then MAX int128 and was able to create lock.

Use a safe downcast function.

#0 - lacoop6tu

2022-08-16T10:40:44Z

Duplicate of #228

#1 - gititGoro

2022-09-02T00:11:43Z

Duplicate upheld

  1. Use external instead of public. https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/features/Blocklist.sol#L33
  2. Not safe downcasting: value that bigger then MAX int128 value will become negative https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L418 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L420 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L460 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L461 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L465 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L472
  3. No need to do this operation here https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L258 because it then is rewrited here https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L264
  4. Check param _addr for zero https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L555
  5. Check constructors and setters params for zero https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/features/Blocklist.sol#L14 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L100 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L139 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L146 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L153

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter