This value will likely be calculated on the front-end of the website and it will cause a loss in user funds.
All, functions marked as payable function in the PreMarket contract are subject to this vulnerability.
For example,
PreMarkets::createOffer takes an uint256 amount parameter in the CreateOfferParams struct. When using weth as the payment/collateral method it only verifies that msg.value is not less than amount or it will revert. This is bad because if the front-end of the website calculates the incorrect msg.value to send with the transaction the extraAmount = msg.value - amount all the extraAmount will be lost in the contract.
#PoC
Place the following code into PreMarkets.t.sol and run with forge test --mt test_wrong_msgvalue_loses_funds -vvv
Notice the console logged data.
If the Tadle front-end over calculates the msg.value in any of the PreMarkets payable functions user's will lose funds.
Foundry and manual review
In the PreMarkets::createOffer function make the following changes, so even if the msg.value is over calculated users will still only deposit the amount they passed as a parameter. Thus, protecting them from unexpected losses.
In the PreMarkets::_depositTokenWhenCreateTaker:
In the PreMarkets::listOffer:
In the PreMarkets::relistOffer:
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.