No related function to set fee_protocol
The pool contract defines a protocol fee rate but provides no function to set it, so the protocol can never accumulate fees. An attacker cannot exploit this; it is a missing feature that prevents the protocol from earning revenue.
shaflow2 Follow with prapandey031, zhaojohnson and 4 others
Originally disclosed on Code4rena
Submitted by shaflow2, also found by prapandey031, zhaojohnson, DadeKuma, peanuts, oakcobalt, and wasm_it
There are no related functions to set fee_protocol, which prevents the protocol from accumulating protocol fees.
Proof of Concept
The pool contract defines the protocol fee rate fee_protocol, but there is no function to set it.
#[solidity_storage]
pub struct StoragePool {
...
fee_protocol: StorageU8,
fee_growth_global_0: StorageU256,
fee_growth_global_1: StorageU256,
protocol_fee_0: StorageU128,
protocol_fee_1: StorageU128,
...
}
The contract also defines the collect_protocol and collect_protocol_7540_F_A_9_F functions to collect fees. However, since the protocol fee rate cannot be set, the protocol will never accumulate any protocol fees.
#[allow(non_snake_case)]
pub fn collect_protocol_7540_F_A_9_F(
&mut self,
pool: Address,
amount_0: u128,
amount_1: u128,
recipient: Address,
) -> Result<(u128, u128), Revert> {
...
}
pub fn collect_protocol(
&mut self,
amount_0: u128,
amount_1: u128,
) -> Result<(u128, u128), Revert> {
...
}
Recommended Mitigation Steps
Add the relevant functions to enable protocol fees.
pkg/seawater/src/pool.rs:
+ pub fn set_fee_protocol(&mut self, new_fee_protocol: U256) {
+ self.fee_protocol.set(new_fee_protocol);
+ }
pkg/seawater/src/lib.rs:
+ #[allow(non_snake_case)]
+ pub fn set_fee_protocol(
+ &mut self,
+ pool: Address,
+ new_fee_protocol: U256,
+ ) -> Result<(), Revert> {
+ assert_eq_or!(
+ msg::sender(),
+ self.seawater_admin.get(),
+ Error::SeawaterAdminOnly
+ );
+
+ self.pools.setter(pool).set_fee_protocol(new_fee_protocol);
+
+ Ok(())
+ }
af-afk (Superposition) confirmed and commented:
See commit.
The submission and its duplicates have correctly identified that there is no mechanism to set the protocol fee in the system, causing fees to never accumulate in the current implementation.
I believe a severity of medium is appropriate given that its only harm is prospective earnings for the protocol itself.
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 contract lacks a setter function for the protocol fee rate, leaving it at its default value.
Impact
The protocol cannot accumulate any protocol fees, resulting in lost prospective earnings.
What the attacker needed
None
The fix
Add a function to set the protocol fee rate, restricted to the admin, as was done in a later commit.
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 setting for a fee that the protocol should earn, but there is no way to change that setting from its default value. Because the setting stays at zero, the protocol never collects any fees, even though the code to collect them exists.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.