Skip to content
Business logic Audit finding Intermediate

Multiple functions aren't payable so quotes that require protocol fees won't work correctly

Several external functions that use 0x quotes are not marked payable, so they cannot accept the ETH protocol fee required by some quotes. This makes those functions incompatible with such quotes, potentially causing wasted gas or bad rates for users.

0x52 Follow with Bauer

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-03-sense-judging/issues/28

Found by

0x52, Bauer

Summary

There are multiple functions that use quotes but that aren't payable. This breaks their compatibility with some quotes. As the 0x docs state: Certain quotes require a protocol fee, in ETH, to be attached to the swap call.

The following flows use a quote but the external/public starting function isn't payable:

RollerPeriphery

  1. redeem

Periphery

  1. removeLiquidity
  2. combine
  3. swapPT
  4. swapYT
  5. issue

Vulnerability Detail

See summary.

Impact

Functions won't be compatible with certain quotes causing wasted gas fees or bad rates for users

Code Snippet

https://github.com/sherlock-audit/2023-03-sense/blob/main/auto-roller/src/RollerPeriphery.sol#L104

https://github.com/sherlock-audit/2023-03-sense/blob/main/sense-v1/pkg/core/src/Periphery.sol#L325

https://github.com/sherlock-audit/2023-03-sense/blob/main/sense-v1/pkg/core/src/Periphery.sol#L409

https://github.com/sherlock-audit/2023-03-sense/blob/main/sense-v1/pkg/core/src/Periphery.sol#L433

https://github.com/sherlock-audit/2023-03-sense/blob/main/sense-v1/pkg/core/src/Periphery.sol#L240

https://github.com/sherlock-audit/2023-03-sense/blob/main/sense-v1/pkg/core/src/Periphery.sol#L263

Tool used

Manual Review

Recommendation

Add payable to these external/public functions

Discussion

jparklev

Confirmed: We've forgotten to add payable to the functions mentioned

jparklev

Fixed here for sense-v1: https://github.com/sense-finance/sense-v1/pull/345 And here for the auto-roller: https://github.com/sense-finance/auto-roller/pull/33

We took the suggested fix and added payable to the mentioned functions

IAm0x52

Fixes look good. Payable has been added to Periphery#removeLiquidity, combine, swapPT, swapYT and issue. Also adds payable to RollerPeriphery#redeem

The original report as published on Sherlock, by 0x52. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 developers forgot to add the 'payable' modifier to functions that need to forward ETH for protocol fees.

Impact

Functions won't be compatible with certain quotes causing wasted gas fees or bad rates for users.

What the attacker needed

None

The fix

The functions were fixed by adding the payable modifier.

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.

Some functions in a smart contract need to receive ETH (the cryptocurrency) to pay for a service, but they were not marked as 'payable', which is a keyword that allows a function to accept ETH. Without it, those functions cannot be used with certain quotes that require a fee, so users might lose gas or get worse rates.

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.

More by 0x52

View all

211 more disclosed reports, best first.

More from Sense Update #1

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.