changeTreasury() Lack of check and remove old
Source: https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/208
Found by
HonorLt, VAD37, bin2chen, nobody2018
Summary
changeTreasury() Lack of check and remove old
Vulnerability Detail
changeTreasury() used to set new treasury The code is as follows:
function changeTreasury(uint256 _marketId, address _treasury)
public
onlyTimeLocker
{
if (_treasury == address(0)) revert AddressZero();
address[2] memory vaults = marketIdToVaults[_marketId];
if (vaults[0] == address(0) || vaults[1] == address(0)) {
revert MarketDoesNotExist(_marketId);
}
IVaultV2(vaults[0]).whiteListAddress(_treasury);
IVaultV2(vaults[1]).whiteListAddress(_treasury);
IVaultV2(vaults[0]).setTreasury(treasury);
IVaultV2(vaults[1]).setTreasury(treasury);
emit AddressWhitelisted(_treasury, _marketId);
}
The above code has the following problem:
- no check whether the new treasury same as the old. If it is the same, the whitelist will be canceled.
- Use setTreasury(VaultFactoryV2.treasury), it should be setTreasury(_treasury)
- not cancel old treasury from the whitelist
Impact
whiteListAddress abnormal
Code Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/VaultFactoryV2.sol#L228
Tool used
Manual Review
Recommendation
function changeTreasury(uint256 _marketId, address _treasury)
public
onlyTimeLocker
{
if (_treasury == address(0)) revert AddressZero();
address[2] memory vaults = marketIdToVaults[_marketId];
if (vaults[0] == address(0) || vaults[1] == address(0)) {
revert MarketDoesNotExist(_marketId);
}
+ require(vaults[0].treasury() !=_treasury,"same"); //check same
+ IVaultV2(vaults[0]).whiteListAddress(vaults[0].treasury()); //cancel old whitelist
+ IVaultV2(vaults[1]).whiteListAddress(vaults[1].treasury()); //cancel old whitelist
IVaultV2(vaults[0]).whiteListAddress(_treasury);
IVaultV2(vaults[1]).whiteListAddress(_treasury);
+ IVaultV2(vaults[0]).setTreasury(_treasury);
+ IVaultV2(vaults[1]).setTreasury(_treasury);
- IVaultV2(vaults[0]).setTreasury(treasury);
- IVaultV2(vaults[1]).setTreasury(treasury);
emit AddressWhitelisted(_treasury, _marketId);
}
Discussion
dmitriia
Keeping it separate from 435 because of whitelist observation (1)
pauliax
Escalate for 10 USDC.
I believe it is unfair to leave it as a solo medium.
#410 also mentions the problem with whitelisting: "Also, probably the old treasury should be removed from the whitelist to prevent accidental abuse of privileges." but was grouped together with other issues from #435.
sherlock-admin
Escalate for 10 USDC.
I believe it is unfair to leave it as a solo medium.
#410 also mentions the problem with whitelisting: "Also, probably the old treasury should be removed from the whitelist to prevent accidental abuse of privileges." but was grouped together with other issues from #435.
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
3xHarry
fix Pr: https://github.com/Y2K-Finance/Earthquake/pull/137
hrishibhat
Escalation accepted
Added relevant duplicates based on whitelist observation
sherlock-admin
Escalation accepted
Added relevant duplicates based on whitelist observation
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
IAm0x52
Fixes look good. Carousel now directly uses the treasury address sent on factory
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity access control bug in Y2K. Sherlock made it public on 12 April 2023. Found in the 57 audit contest (finding M-7), also found by 3 other wardens.
About Access control
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.