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
Rank: 6/105
Findings: 1
Award: $3,859.26
🌟 Selected for report: 1
🚀 Solo Findings: 0
🌟 Selected for report: philogy
Also found by: Lambda, berndartmueller
3859.255 USDC - $3,859.26
https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBTokenStore.sol#L246 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBTokenStore.sol#L266 https://github.com/jbx-protocol/juice-contracts-v2-code4rena/blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBController.sol#L605
This vulnerability allows malicious actors to block other users from changing tokens of their projects. Furthermore if ownership over the token contract is transferred to the JBTokenStore
contract prior to the change, as suggested in the recourse section of Juicebox's 24.05.2022 post-mortem update, this vulnerability would allow an attacker to become the owner of tokens being transferred. For JBToken
based tokens this would allow an attacker to begin issuing arbitrary amounts the token that was meant to be transferred.
Exploit scenario:
JBTokenStore
contract, either directly by calling transferOwnership
on the token or indirectly by calling the changeFor
method on an older JBTokenStore
contract with _newOwner
set as the new JBTokenStore
contract. (For the newer Juicebox contracts the JBController
contract's changeTokenOf
method would be called)changeTokenFor
calling transaction to the new JBController
contract, triggering the JBTokenStore
contract's changeFor
method, linking it to one of the attacker's projects (this could be created in advance or as part of the same transaction via an attack contract)changeTokenFor
again with the _newOwner
set to the attacker's addressmint
method like JBToken
based tokens the attacker can now mint an arbitrary amount of the tokenManual review.
Before allowing a caller to change to a specific token ensure that they have control over it. This can be achieved by storing a list of trusted older JB directories and projects which are then queried. Alternatively the contract could require the caller to actually be the .owner()
address of the token to migrate, this would require admins to:
changeTokenOf
with themselves as the new ownerFuture migrations can be made more seamless by having older contracts directly call new contracts via a sub-call, removing a necessary transaction for the admin. The newer contracts needs to verify that the older contract is the owner address of the token that's being set and also has approval of the project owner which is being configured.
#0 - mejango
2022-07-08T21:19:28Z
nice
#1 - mejango
2022-07-08T21:21:49Z
the project should first changeToken and then transfer ownership
#2 - mejango
2022-07-12T15:40:29Z
Noted for improved risks documentation