Suspended PartyBs can bypass the withdrawal restriction by exploiting `fillCloseRequest`
A suspended PartyB can bypass the withdrawal restriction by using a separate PartyA account to create a deliberately losing position, then filling the close request to move funds out. This allows the attacker to transfer ill-gotten gains out of the protocol, causing losses to the protocol and its users.
Source: https://github.com/sherlock-audit/2023-06-symmetrical-judging/issues/229
Found by
0xcrunch, 0xmuxyz, Juntao, PokemonAuditSimulator, Viktor_Cortess, ast3ros, bin2chen, circlelooper, josephdara, mrpathfindr, mstpr-brainbot, panprog, rvierdiiev, xiaoming90
Summary
Suspended PartyBs can bypass the withdrawal restriction by exploiting fillCloseRequest function. Thus, an attacker can transfer the ill-gotten gains out of the protocol, leading to a loss of assets for the protocol and its users.
Vulnerability Detail
File: AccountFacet.sol
26: function withdraw(uint256 amount) external whenNotAccountingPaused notSuspended(msg.sender) {
27: AccountFacetImpl.withdraw(msg.sender, amount);
28: emit Withdraw(msg.sender, msg.sender, amount);
29: }
30:
31: function withdrawTo(
32: address user,
33: uint256 amount
34: ) external whenNotAccountingPaused notSuspended(msg.sender) {
35: AccountFacetImpl.withdraw(user, amount);
36: emit Withdraw(msg.sender, user, amount);
37: }
When a user is suspended, they are not allowed to call any of the withdraw functions (withdraw and withdrawTo) to withdraw funds from their account. These withdrawal functions are guarded by the notSuspended modifier that will revert if the user's address is suspended.
File: Accessibility.sol
73: modifier notSuspended(address user) {
74: require(
75: !AccountStorage.layout().suspendedAddresses[user],
76: "Accessibility: Sender is Suspended"
77: );
78: _;
79: }
However, suspected PartyBs can bypass this restriction by exploiting the fillCloseRequest function to transfer the assets out of the protocol. Following describe the proof-of-concept:
- Anyone can be a PartyA within the protocol. Suspended PartyBs use one of their wallet addresses to operate as a PartyA.
- Use the PartyA to create a new position with an unfavorable price that will immediately result in a significant loss for any PartyB who takes on the position. The
partyBsWhiteListof the new position is set to PartyB address only to prevent some other PartyB from taking on this position. - Once PartyB takes on the position, PartyB will immediately incur a significant loss, while PartyA will enjoy a significant gain due to the zero-sum nature of this game.
- PartyA requested to close its position to lock the profits and PartyB will fill the close request.
- PartyA calls the deallocate and withdraw functions to move the assets/gains out of the protocol.
Impact
In the event of an attack, the protocol will suspend the malicious account and prevent it from transferring ill-gotten gains out of the protocol. However, since this restriction can be bypassed, the attacker can transfer the ill-gotten gains out of the protocol, leading to a loss of assets for the protocol and its users.
Code Snippet
Tool used
Manual Review
Recommendation
Add the notSuspended modifier to the openPosition and fillCloseRequest functions to block the above-described attack path.
function fillCloseRequest(
uint256 quoteId,
uint256 filledAmount,
uint256 closedPrice,
PairUpnlAndPriceSig memory upnlSig
- ) external whenNotPartyBActionsPaused onlyPartyBOfQuote(quoteId) notLiquidated(quoteId) {
+ ) external whenNotPartyBActionsPaused onlyPartyBOfQuote(quoteId) notLiquidated(quoteId) notSuspended(msg.sender) {
..SNIP..
}
function openPosition(
uint256 quoteId,
uint256 filledAmount,
uint256 openedPrice,
PairUpnlAndPriceSig memory upnlSig
- ) external whenNotPartyBActionsPaused onlyPartyBOfQuote(quoteId) notLiquidated(quoteId) {
+ ) external whenNotPartyBActionsPaused onlyPartyBOfQuote(quoteId) notLiquidated(quoteId) notSuspended(msg.sender) {
..SNIP..
}
Discussion
MoonKnightDev
We disagree with the severity of this issue because, in the current system, Party B is permissioned. Therefore, it is highly unlikely that Party B will be suspended.
Navid-Fkh
The mentioned PartyA will also be suspended by our bots; thus, they won't be able to withdraw any funds. Therefore, we won't have any problems
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
Root cause
Likely the `fillCloseRequest` and `openPosition` functions lack the `notSuspended` modifier, allowing suspended PartyBs to perform actions that indirectly transfer funds.
Impact
The attacker can transfer ill-gotten gains out of the protocol, leading to a loss of assets for the protocol and its users.
What the attacker needed
Suspended PartyB account; Attacker controls a PartyA wallet; PartyB is permissioned (per developer)
How it was found
- Suspended PartyB uses one of their wallet addresses to operate as a PartyA.
- Use the PartyA to create a new position with an unfavorable price that will immediately result in a significant loss for any PartyB who takes on the position, and set the partyBsWhiteList to PartyB address only.
- Once PartyB takes on the position, PartyB will immediately incur a significant loss, while PartyA will enjoy a significant gain.
- PartyA requested to close its position to lock the profits and PartyB will fill the close request.
- PartyA calls the deallocate and withdraw functions to move the assets/gains out of the protocol.
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.
In this system, users can be 'suspended' to stop them from taking money out. The report shows that a suspended user can still move money by creating a second account and making a trade that intentionally loses money to the suspended account, then closing the trade to get the funds out. This defeats the suspension and lets the attacker keep the money.
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.