The listOffer()
function is marked as payable
, allowing it to receive ETH. However, the function only requires payment in specific circumstances, which could lead to unexpected behavior and potential loss of funds.
The listOffer()
function is marked as payable
.
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L299
Token transfer only occurs when the offer settlement type is Protected:
if (makerInfo.offerSettleType == OfferSettleType.Protected) {
uint256 transferAmount = OfferLibraries.getDepositAmount(
offerInfo.offerType,
offerInfo.collateralRate,
_amount,
true,
Math.Rounding.Ceil
);
For other settlement types (e.g., Turbo), no token transfer occurs, but the function can still receive ETH.
Users may send ETH unnecessarily when listing offers with non-Protected settlement types. Sent ETH in these cases would be locked in the contract without a clear mechanism for retrieval.
Proof of Concept:
A user creates an offer with a Turbo settlement type.
The same user calls listOffer()
and sends ETH along with the transaction.
The function executes successfully, but the sent ETH is not used and becomes locked in the contract.
Users may send ETH unnecessarily when listing offers with non-Protected settlement types and sent token in these cases would be locked in the contract without a clear mechanism for retrieval, causing loss of funds.
Manual review
Add a check at the beginning of listOffer()
to revert if msg.value > 0
for non-Protected settlement types.
Invalid, these are by default, invalid based on codehawks [general guidelines](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#findings-that-may-be-invalid). The check implemented is simply a sufficiency check, it is users responsibility to only send an appropriate amount of native tokens where amount == msg.value when native token is intended to be used as collateral (which will subsequently be deposited as wrapped token). All excess ETH can be rescued using the `Rescuable.sol` contract. > Users sending ETH/native tokens > If contracts allow users to send tokens acc111identally.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.