-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add overflow check on _minOfferPrice in fulfillOffer #33
Comments
How can a user call
|
I wrote a simple contract with remix that had this function With remix, if I call If I have time, I can launch a contract and see if I get this behavior on EVM. I think the issue is that every input to a function (at least in remix and I believe if you use web3 and a ABI to interact with a contract) takes 256 bits--regardless of what it "should" be. Also, on the main CK contract, it is pretty standard to check input types are what they should be (however just realized this is in a different context: the input is allowed to be 256 bits, but they require it is truly 128 bits). See lines 1424 - 1428 here: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code |
Also, I just realized that the impact of this issue and #27 are the same (although my issue is far more unlikely). However, the reason for the bug is different. Also, not to say they are wrong, but personally I am not able to reproduce their bug with remix. |
I still do not agree with you. This is a real issue that can happen. I just launched a contract:
Here's the address: https://etherscan.io/address/0x78734a93c98514fa5f605463a7f1efbf9d88e29e Unfortunately, I am having trouble getting etherscan to publish the code of the contract. But anyway, I called Here's is the abi if you want to test yourself: The point is depending on the compiler or perhaps the way you interact with the contract, the input can be |
A similar situation arises for some global variables (wanted to leave this as a comment since it seemed unnecessary to open an entire new bug report since it is somewhat similar): DescriptionThere are potential functionality issues due to overflow errors because of type casting variables as (Note as far as I am aware, the following global variables are safe with respect to overflow errors: ScenarioFor When someone calls ImpactLow likelihood and low impact (someone could lose a small amount of fees if the auction only lasts a few minutes). FixAdd a line like |
Thanks @sunsetlover for your feedback! We will take this into consideration |
Thanks for your participation, @sunsetlover! Our team has reviewed your submission, and we are pleased to reward you for your report. Severity: Note |
Description
Because of overflow errors, a user could accept an offer much lower than they want. It is possible although probably low risk but potentially high impact.
Scenario
A user calls
fulfillOffer
with a_minOfferPrice
that is larger thanuint128
. This could happen purely on accident by the user, or potentially intentionally or accidentally by a third party application the user is using.Because
_minOfferPrice
is larger thanuint128
,fulfillOffer
could potentially treat_minOfferPrice
as a very small number close to 0 (if say _minOfferPrice = 2^128 +1). ThenIn the meantime before the user's tx is mined, an attacker could perform a frontrunning attack.
He or she could see that this user will end up with an overflow error then
Impact
A user could essentially give away a high valued cat for a very small amount of money.
Reproduction
See my comment below: #33 (comment)
Fix
In
fulfillOffer
, add the following line in the beginning:require(_minOfferPrice == uint256(uint128(_minOfferPrice)))
The text was updated successfully, but these errors were encountered: