Juicebox V2 contest - AlleyCat's results

The decentralized fundraising and treasury protocol.

General Information

Platform: Code4rena

Start Date: 01/07/2022

Pot Size: $75,000 USDC

Total HM: 17

Participants: 105

Period: 7 days

Judge: Jack the Pug

Total Solo HM: 5

Id: 143

League: ETH

Juicebox

Findings Distribution

Researcher Performance

Rank: 12/105

Findings: 2

Award: $1,161.19

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

3.4075 USDC - $3.41

Labels

bug
duplicate
2 (Med Risk)
valid

External Links

Lines of code

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBETHERC20ProjectPayer.sol#L271 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBETHERC20ProjectPayer.sol#L315 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBETHERC20SplitsPayer.sol#L256 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBETHERC20SplitsPayer.sol#L301 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBETHERC20SplitsPayer.sol#L301 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBETHERC20SplitsPayer.sol#L384

Vulnerability details

Impact

A long list of tokens do not revert in case of failure and instead return false. If one of these tokens is used in JuiceBox, the function will not revert on transfer allowing the attacker to call these functions for free. In a cases where minReturnedTokens are returned or ERC20 tokens are transfered in exchange for these ERC20 tokens, they would be able to call them for free.

Proof of Concept

Bob calls pay function using ZRX tokens but has only dust in his wallet. ZRX token returns false instead of reverting on failure. The pay function will still return the expected amount of tokens and run the pay function as if Bob sent the correct amount of ZRX token.

ZRX ERC20 compliant code:

function transferFrom(address _from, address _to, uint _value) returns (bool) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } }

Tools Used

manual review

check the return value of your transfer/transferFrom calls for a success bool and don't rely on the failure revert.

#0 - drgorillamd

2022-07-12T15:49:06Z

Duplicate of #281

#1 - jack-the-pug

2022-07-24T02:11:11Z

Duplicate of #242

Findings Information

🌟 Selected for report: 0x29A

Also found by: AlleyCat, hubble

Labels

bug
duplicate
2 (Med Risk)
sponsor disputed
valid

Awards

1157.7765 USDC - $1,157.78

External Links

Lines of code

https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/abstract/JBPayoutRedemptionPaymentTerminal.sol#L809 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/abstract/JBPayoutRedemptionPaymentTerminal.sol#L1199

Vulnerability details

Impact

The contract inherits from OpenZeppelin ReentrancyGuard.sol however it never uses the modifier to prevent reentry. As explained in the OZ docs

Contract module that helps prevent reentrant calls to a function. Inheriting from ReentrancyGuard will make the nonReentrant modifier available, which can be applied to functions to make sure there are no nested (reentrant) calls to them.

Because of this a reentrancy issue is introduced at L864 when setting local state variable _fee calls _takeFromFee which updates the state variable _heldFeesOf after making external ETH transactions. Allowing an attacker to reenter the contract when calling distributePayoutsOf.

Tools

Manual Review

Implement nonReentrant on your functions or use the checks, effects, interactions pattern to ensure there are no chances for a potential attack to reenter a contract, especially when sending ETH.

#0 - drgorillamd

2022-07-12T15:48:17Z

#1 - jack-the-pug

2022-07-24T02:11:36Z

Duplicate of #329

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