hats-finance / SeeR-PM-0x899bc13919880db76edf4ccd72bdfa5dfa666fb7

1 stars 0 forks source link

Users unable to redeem due to overflow #99

Open hats-bug-reporter[bot] opened 2 months ago

hats-bug-reporter[bot] commented 2 months ago

Github username: @0xmahdirostami Twitter username: 0xmahdirostami Submission hash (on-chain): 0xde135ac616f16a3c0c7f1c8f0525bf4331326803b0681e00426aad0be2cae995 Severity: high

Description:

description

The user could make a scalar market with upper lower than type256max, and if the answer will be between min and max the result will be max - answer

Consider a scenario where a user creates a valid market with 2^256 - 3. The result is 10, so the output will be 2^256 - 3 - 10. If the user's balance multiplied by the result exceeds the limit, the user can't redeem their tokens.

impact

User unable to redeem their tokens

mitigation

Check upper bond in the factory to be less than type128 max

line of issue

https://github.com/hats-finance/SeeR-PM-0x899bc13919880db76edf4ccd72bdfa5dfa666fb7/blob/4e56254cbd071b6f678a108ccdb8660951636d27/contracts/src/RealityProxy.sol#L145-L147

https://github.com/hats-finance/SeeR-PM-0x899bc13919880db76edf4ccd72bdfa5dfa666fb7/blob/4e56254cbd071b6f678a108ccdb8660951636d27/contracts/src/interaction/conditional-tokens/ConditionalTokens.sol#L250

greenlucid commented 2 months ago

I didn't test, but it seems like you're right. In the example you gave, it would already overflow during reportPayouts in this step:

https://github.com/hats-finance/SeeR-PM-0x899bc13919880db76edf4ccd72bdfa5dfa666fb7/blob/4e56254cbd071b6f678a108ccdb8660951636d27/contracts/src/interaction/conditional-tokens/ConditionalTokens.sol#L97

Interesting how they implemented this safety mechanism for multi scalar markets, but not in this one, was it a slip?:

https://github.com/hats-finance/SeeR-PM-0x899bc13919880db76edf4ccd72bdfa5dfa666fb7/blob/4e56254cbd071b6f678a108ccdb8660951636d27/contracts/src/RealityProxy.sol#L170

The conditions to trigger this vulnerability seem difficult, though:

I wouldn't call this a high vulnerability (it seems very theoretical, I doubt scalar markets with upperBound > 1e9 even get any traction, let alone something like 50 digits), but I think it's indeed something Seer might agree it's an issue, since they addressed it for a similar case.

Out of Scope

Any issue that is only theoretical but can't happen in practice.

0xmahdirostami commented 1 month ago

@greenlucid thanks for your feedback, actually i resubmitted it in issue #100 with more details to become eligible for a high-quality report, i think its better to discuss under that issue.

For now, I want to give feedback on your comment:

I didn't test, but it seems like you're right. In the example you gave

It would already overflow during reportPayouts in this step: https://github.com/hats-finance/SeeR-PM-0x899bc13919880db76edf4ccd72bdfa5dfa666fb7/blob/4e56254cbd071b6f678a108ccdb8660951636d27/contracts/src/interaction/conditional-tokens/ConditionalTokens.sol#L97

Interesting how they implemented this safety mechanism for multi-scalar markets

  • exactly true

The conditions to trigger this vulnerability seem difficult, though: I wouldn't call this a high vulnerability (it seems very theoretical, I doubt scalar markets with upperBound > 1e9 even get any traction, let alone something like 50 digits), but I think it's indeed something Seer might agree it's an issue, since they addressed it for a similar case.

Long-term freezing of user funds (ex: preventing a market from resolving for 100 years) or Significant protocol insolvency.

In this issue, user is unable to redeem for 100 years.

clesaege commented 1 month ago

This is pretty different than for multiscalar. For multiscalar, there isn't a specified upper bound, so if the result is very high, that would have caused an issue. So we should handle reality potentially giving very high values, but we don't need to prevent at the contract level someone from giving in very high upper bounds. Here you would need to make a market with a crazy high upperbound: 115792089237316195423570985008687907853269984665640564039457.584007913129639933 which would be a clear giveaway. This would be akin to reporting a vuln in any ERC20 which doesn't introduce a cap on the max supply.

As per contest rules, are excluded:

greenlucid commented 1 month ago

Another point that can be made here: