Lack of access control in PublicVault.sol#transferWithdrawReserve let user call transferWithdrawReserve() multiple times to modify withdrawReserve
The transferWithdrawReserve function in PublicVault.sol lacks access control, allowing anyone to call it repeatedly. An attacker could decrement the withdrawReserve state variable to zero when the withdrawal proxy address is zero, preventing legitimate withdrawals.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/163
Found by
Jeiwan, ctf_sec
Summary
Lack of access control in PublicVault.sol#transferWithdrawReserve let user call transferWithdrawReserve() multiple times to modify withdrawReserve
Vulnerability Detail
The function PublicVault.sol#transferWithdrawReserve() is meants to transfers funds from the PublicVault to the WithdrawProxy.
https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/PublicVault.sol#L341-L363
However, this function has no access control, anyone can call it multiple times to modify the withdrawReserve value
Impact
A malicious actor can keep calling the function transferWthdrawReserve() before the withdrawal proxy is created.
If the underlying proxy has address(0), the transfer is not performed, but the state withdrawReserves is decremented.
Then user can invoke this function to always decrement the withdrawReserve to 0
// prevent transfer of more assets then are available
if (withdrawReserve <= withdraw) {
withdraw = withdrawReserve;
withdrawReserve = 0;
} else {
withdrawReserve -= withdraw;
}
Code Snippet
https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/PublicVault.sol#L341-L363
Tool used
Manual Review
Recommendation
We recommend the project add requiestAuth modifier to the function
function transferWithdrawReserve() public {
We can also change the implementation by implmenting: if the underlying withdrawProxy is address(0), revert transfer.
Discussion
IAmTurnipBoy
Escalate for 1 USDC
Invalid. Impossible for withdrawReserve != 0 and there isn't a withdraw proxy, because of the following logic. Anytime there is a liquidation a liquidation accountant is deployed and that ALWAYS deploys a withdraw proxy. If there's no liquidations then there's no withdrawReserves.
sherlock-admin
Escalate for 1 USDC
Invalid. Impossible for withdrawReserve != 0 and there isn't a withdraw proxy, because of the following logic. Anytime there is a liquidation a liquidation accountant is deployed and that ALWAYS deploys a withdraw proxy. If there's no liquidations then there's no withdrawReserves.
You've created a valid escalation for 1 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Evert0x
Escalation rejected. There's no hard requirement to always have a liquidation accountant..
sherlock-admin
Escalation rejected. There's no hard requirement to always have a liquidation accountant..
This issue's escalations have been rejected!
Watsons who escalated this issue will have their escalation amount deducted from their next payout.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
A malicious actor could repeatedly call the function to reduce withdrawReserve to zero, potentially preventing legitimate withdrawals, though the report notes this only occurs before the withdrawal proxy is created.
What the attacker needed
WithdrawReserve > 0; withdrawProxy address is zero
The fix
The function should be protected with an authentication modifier or should revert if the withdrawal proxy address is zero.
How it was found
- Call transferWithdrawReserve() when the withdrawal proxy address is zero.
- The transfer is skipped but withdrawReserve is decremented.
- Repeat the call until withdrawReserve reaches zero.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract function that moves funds between vaults can be called by anyone because it has no permission check. If the destination vault is not set up yet, the function still reduces an internal counter, so an attacker can repeatedly call it to zero out that counter. This could block other users from withdrawing their funds.
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.