code-423n4 / 2022-10-juicebox-findings

2 stars 0 forks source link

Unsafe downcast operations can lead to silent failures #225

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/jbx-protocol/juice-nft-rewards/blob/f9893b1497098241dd3a664956d8016ff0d0efd0/contracts/JBTiered721DelegateStore.sol#L688-L696

Vulnerability details

Solidity won't perform automatic checks when downcasting and it's possible for some fields to overflow while adding tiers.

Proof of Concept

Similar behavior can occur for other fields for a tier.

https://github.com/jbx-protocol/juice-nft-rewards/blob/f9893b1497098241dd3a664956d8016ff0d0efd0/contracts/JBTiered721DelegateStore.sol#L688-L696

Impact

Slient overflows will affect tier accouting and can cause unexpected behavior in the protocol.

Recommended Mitigation Steps

Make use of a safe-cast library. E.g. OpenZeppelin's SafeCast.

drgorillamd commented 1 year ago

Nice finding, disagree with severity (another tier can be added to fix it/no function/availability of the protocol impacted)

c4-judge commented 1 year ago

Picodes marked the issue as duplicate

c4-judge commented 1 year ago

Picodes marked the issue as satisfactory