fillQuote uses transfer instead of call which can break with future updates to gas costs
The contract uses transfer to send ETH, which forwards a fixed 2300 gas stipend. If gas costs change, integrations with smart contracts could break because the recipient may not have enough gas to execute its fallback function.
Source: https://github.com/sherlock-audit/2023-03-sense-judging/issues/33
Found by
0x52, 0xAgro, Bauer, Breeje, Saeedalipoor01988, martin, sayan_, tsvetanovv
Summary
Transfer will always send ETH with a 2300 gas. This can be problematic for interacting smart contracts if gas cost change because their interaction may abruptly break.
Vulnerability Detail
See summary.
Impact
Changing gas costs may break integrations in the future
Code Snippet
Tool used
Manual Review
Recommendation
Use call instead of transfer. Reentrancy isn't a concern since the contract should only ever contain the callers funds.
Discussion
jparklev
Accepted: we should use .call instead of transfer when transferring ETH, specifically if the receiver is a contract that is integrating Sense.
jparklev
Fixed here: https://github.com/sense-finance/sense-v1/pull/348
We ended up removing the protocol fees entirely, which obviated the need for the suggested fix here
IAm0x52
Fix looks good, transfer has ben changed to call but the occurrence is rollerPeriphery appears to have been missed:
IAm0x52
Additional missed transfers:
https://github.com/sense-finance/sense-v1/pull/346/files#r1167351042 https://github.com/sense-finance/auto-roller/pull/32#discussion_r1167351433
fedealconada
Fix looks good, transfer has ben changed to call but the occurrence is rollerPeriphery appears to have been missed:
fixed here
fedealconada
Additional missed transfers:
https://github.com/sense-finance/sense-v1/pull/346/files#r1167351042 [sense-finance/auto-roller#32 (comment)]
fixed here
(https://github.com/sense-finance/auto-roller/pull/32#discussion_r1167351433)
fixed here
IAm0x52
Fixes look good. All three occurrences have been address. 2 occurrences in RollerPeriphery addressed in PR#32 and the other in Periphery addressed in PR#346
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 use of transfer instead of call, which hardcodes a 2300 gas stipend that may become insufficient if gas costs change.
Impact
Changing gas costs may break integrations in the future.
What the attacker needed
None
The fix
The issue was fixed by replacing transfer with call, and the protocol fees were removed entirely, obviating the need for the fix.
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.
When a smart contract sends Ether using transfer, it only gives the recipient a small fixed amount of gas (2300) to run any code. If the recipient is a contract that needs more gas to process the payment, the transfer will fail. This report says that if gas costs go up in the future, even simple recipients might need more than 2300 gas, so the transfer could break.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.