Open code423n4 opened 2 years ago
Good catch
No value leak/functional impact imo (the interface has unimplemented functions, without fallback, if the caller "forget" what they wanted to deploy, calling these "ghost" fn will revert)
Downgrading as QA as there is no risk involved with the finding.
Picodes changed the severity to QA (Quality Assurance)
Picodes marked the issue as grade-a
Lines of code
https://github.com/jbx-protocol/juice-nft-rewards/blob/f9893b1497098241dd3a664956d8016ff0d0efd0/contracts/JBTiered721DelegateDeployer.sol#L83
Vulnerability details
Impact
JBTiered721DelegateDeployer.deployDelegateFor
cast every governance type toJB721GlobalGovernance
. If the chosen governance contract type isJB721TieredGovernance
orJB721GlobalGovernance
, the cloned contract is casted to the wrong contract type (JB721GlobalGovernance
). Therefore, regardless of the choice of the caller, the contract type of the delegate isJB721GlobalGovernance
instead of the chosen type of governance.Proof of Concept
There is 3 types of delegate depending to the governance type attached to it:
In the
JBTiered721DelegateDeployer.deployDelegateFor
function the newly deployed delegate of the chosen type of the caller is casted to theJB721GlobalGovernance
contract type and assigned to thenewDelegate
variable of typeJB721GlobalGovernance
regardless of the governance type.Link: https://github.com/jbx-protocol/juice-nft-rewards/blob/f9893b1497098241dd3a664956d8016ff0d0efd0/contracts/JBTiered721DelegateDeployer.sol#L83
Tools Used
Manual review.
Recommended Mitigation Steps
I recommend to clone, deploy and cast to the corresponding contract type depending on the governance type of the delegate in the conditionnal statements like this:
From my understanding the team want the return variable of the
JBTiered721DelegateDeployer.deployDelegateFor
function to be a governance agnostic delegate, which make sense considering how the variable is used inJBTiered721DelegateProjectDeployer
(only to set the delegate address as the data source). Therefore usingIJBTiered721Delegate
as return variable type is fine.