Operator can cause fee shares to be minted to address(0)
The factory contract requires a non-zero fee recipient when setting a fee, but allows the fee recipient to be changed to the zero address afterwards. An operator could therefore set a fee and then set the recipient to address(0), bypassing the check.
Source: https://github.com/sherlock-audit/2023-02-surge-judging/issues/124
Found by
0x52, 0xAgro, Aymen0909, BTK, Dug, GimelSec, SovaSlava, ast3ros, bin2chen, ctf_sec, favelanky, gogo, slvDev
Summary
When setting the fee rate it is required that the fee recipient is NOT address(0). An operator can bypass this check by changing the fee recipient to address(0) after setting fee.
Vulnerability Detail
https://github.com/sherlock-audit/2023-02-surge/blob/main/surge-protocol-v1/src/Factory.sol#L60-L65
When setting the fee it is required that if the fee != 0 then the fee recipient != address(0)
https://github.com/sherlock-audit/2023-02-surge/blob/main/surge-protocol-v1/src/Factory.sol#L52-L55
When setting the fee recipient there is no similar check. This means that an operator can bypass the check in setFeeMantissa by setting the fee recipient to address(0) after setting a nonzero fee value.
Impact
Operator can bypass fee recipient check
Code Snippet
https://github.com/sherlock-audit/2023-02-surge/blob/main/surge-protocol-v1/src/Factory.sol#L52-L55
Tool used
Recommendation
Implement a check similar to the one in setFeeMantissa that doesn't allow a nonzero fee when fee recipient = address(0)
Discussion
xeious
Fixed
xeious
https://github.com/Surge-fi/surge-protocol-v1/commit/29b31052b7e7e7335c0fd58a3a734f8aae22f094
IAm0x52
Fix looks good. Fee recipient can no longer be set to address(0)
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
The setFeeRecipient function lacks a check to prevent setting the fee recipient to address(0) when a non-zero fee is already set.
Impact
An operator could bypass the fee recipient check, potentially causing fee shares to be minted to address(0).
What the attacker needed
Operator role
The fix
The fix adds a check to prevent setting the fee recipient to address(0), as confirmed by the discussion.
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 has a rule that if a fee is charged, the recipient cannot be the zero address (a special address that effectively burns funds). However, the function that sets the recipient does not enforce this rule, so someone with operator rights can set a fee and then change the recipient to the zero address, getting around the rule.
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.