buyOption()
allows the buyer to pay more than they need
#123
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate
This issue or pull request already exists
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L223-L224
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L90
Vulnerability details
Impact
The premium you have to pay to buy an option is fixed at the creation of the vault. There's an array with all the possible values. But, when buying an option the function allows the user to pay more than they actually need to. There's no benefit in paying more. It would just be a mistake by the buyer to the benefit of the vault owner.
Proof of Concept
Here the
buyOption()
function verifies the payment: https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L223-L224It uses
>=
instead of==
.Tools Used
none
Recommended Mitigation Steps
Use
==
to only allow the correct amount to be paidThe text was updated successfully, but these errors were encountered: