Skip to content
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

An adversary is able to extract the value by creating an identical market, but with different finalization time. #124

Open
hats-bug-reporter bot opened this issue Sep 28, 2024 · 3 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@hats-bug-reporter
Copy link

Github username: @Rassska
Twitter username: m_Rassska
Submission hash (on-chain): 0x2af608995e56e59bedc52897b80e6b7a646f814436b166de2c8562e1c02cc465
Severity: high

Description:

Description

  • Upon the market creation, ERC20 tokens are deployed respresenting an exact outcome. A bytecode tied to a certain outcome depends on tokenID which itself depends on:

    • collateralToken
    • collectionID
  • This means that there's a possibility to front-run the market creation by changing only openingTime, which results in having the same tokenID for each outcome for both markets within Seer, but on reality, we'll have 2 different questions with openingTime being deviated from each other.

Attack Scenario

  • Someone creates a categorial market X representing a chess match with a valid openingTime(in 2 hours should be resolved)
  • An adversary sees it, and creates an identical market Y on Seer, which itself creates another question on reality.eth, but with openingTime specified as delta < X.openingTime.
  • Since the erc20 tokens deployed for outcomes are the same, an adversary can finalize his market with a desired outcome receiving his collateral back and sells other outcomes on amm.
  • As a result, he's able to extract free-risk value.

Mitigation Steps

  • There should not be cases, where two different question_ids on reality.eth having the same erc20 positions deployed.
@hats-bug-reporter hats-bug-reporter bot added the bug Something isn't working label Sep 28, 2024
@Rassska
Copy link

Rassska commented Sep 28, 2024

Mitigation Steps addition

The Seer has to be sure that:

  • question_id(reality) is tied to ERC20 outcomes deployed
    But currently it's:
  • tokenId(which doesn't include openingTime) -> ERC20 outcome

@greenlucid
Copy link

tokenId relies on collectionId, which relies on conditionId

uint256 tokenId = conditionalTokens.getPositionId(collateralToken, collectionId);

conditionId relies on questionId

deployERC20Positions(parentCollectionId, conditionId, config.outcomeSlotCount, params.tokenNames);

questionId is a bytes32 created for internal use, and relies on questionIds

questionIds array is filled with the reality.eth ids, that are reliant on the openingTime

askRealityQuestion(config.encodedQuestions[i], config.templateId, params.openingTime, params.minBond);

So, how can you create two tokens with the same id, with different openingTimes?

Proof of Concept or you made it up

@clesaege
Copy link

As pointed out by @greenlucid, the collectionId would be different. If you still think the issue is correct, you can show a test.

@clesaege clesaege added the invalid This doesn't seem right label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants