Added some tests to confirm Oracle price manipulation. #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, my name is Anthony, wonderful code you got here, I love it, however, I made a little realization.
Since the oracle price returns
int256
, I think that these values can be manipulated by an attacker to return values < 0, where by when cast touint256
will overflow causing the price to be > 1,000,000 as specified in the code.(This can be used in favour of or against USDC.)
I suggest making sure that returned prices are >= 0 before casting to
uint256
, to be safe.Reference:
https://github.com/Anish-Agnihotri/Hyperbitcoinization/blob/master/src/Hyperbitcoinization.sol#L125-L129
My Recommentation:
PS: I whopped up a fake Oracle for this test.
Location:
test/myFolder/AnotherHyperbitcoinization.t.sol
I am open to corrections if any.
Once again, wonderful contract, great job 馃憤馃従!