DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: low
Invalid

Unsafe Downcast

Unsafe Downcast

  • Severity: Low

  • Confidence: High

Description

When a type is downcast to a smaller type, the higher-order bits are truncated, effectively applying a modulo operation to the original value. This can introduce vulnerabilities and cause the program to behave unexpectedly.

If you intend to perform an unchecked modulo operation, it is advisable to use the syntax uncheck{ x % y}. This not only makes the code clearer but also helps prevent potential bugs and ensures the intended behavior of the operation.

There are 13 instances of this issue:

File: contracts/facets/BridgeRouterFacet.sol
​
53 uint88(IBridge(bridge).deposit(msg.sender, amount))

usafe downcast size from - 256 to size 88

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/BridgeRouterFacet.sol#L53

File: contracts/facets/BridgeRouterFacet.sol
​
82 uint88(IBridge(bridge).depositEth{value: msg.value}())

usafe downcast size from - 256 to size 88

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/BridgeRouterFacet.sol#L82

File: contracts/facets/ERC721Facet.sol
​
162 uint40(tokenId)

usafe downcast size from - 256 to size 40

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/ERC721Facet.sol#L162

File: contracts/facets/MarginCallPrimaryFacet.sol
​
252 uint88(gasUsed * block.basefee)

usafe downcast size from - 256 to size 88

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/MarginCallPrimaryFacet.sol#L252

File: contracts/facets/MarginCallPrimaryFacet.sol
​
229 uint88(
230 m.ethDebt.div(_bidPrice.mul(1 ether + m.callerFeePct + m.tappFeePct))
231 )

usafe downcast size from - 256 to size 88

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/MarginCallPrimaryFacet.sol#L229-L231

File: contracts/facets/MarginCallPrimaryFacet.sol
​
284 uint88(a)

usafe downcast size from - 256 to size 88

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/MarginCallPrimaryFacet.sol#L284

File: contracts/facets/MarginCallSecondaryFacet.sol
​
192 uint88(a)

usafe downcast size from - 256 to size 88

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/MarginCallSecondaryFacet.sol#L192

File: contracts/facets/OwnerFacet.sol
​
55 uint8(s.assets.length)

usafe downcast size from - 256 to size 8

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/OwnerFacet.sol#L55

File: contracts/facets/OwnerFacet.sol
​
68 uint80(LibOracle.getOraclePrice(asset))

usafe downcast size from - 256 to size 80

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/OwnerFacet.sol#L68

File: contracts/facets/OwnerFacet.sol
​
281 uint8(vault)

usafe downcast size from - 256 to size 8

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/OwnerFacet.sol#L281

File: contracts/facets/YieldFacet.sol
​
142 uint80(dittoReward)

usafe downcast size from - 256 to size 80

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/YieldFacet.sol#L142

File: contracts/facets/YieldFacet.sol
​
170 uint16(protocolTime)

usafe downcast size from - 256 to size 16

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/YieldFacet.sol#L170

File: contracts/facets/YieldFacet.sol
​
175 uint96(totalReward - userReward)

usafe downcast size from - 256 to size 96

https://github.com/Cyfrin/2023-09-ditto/blob/main/contracts/facets/YieldFacet.sol#L175

Updates

Lead Judging Commences

0xnevi Lead Judge
almost 3 years ago
0xnevi Lead Judge almost 3 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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

Give us feedback!