> For the complete documentation index, see [llms.txt](https://funarchy.gitbook.io/funarchy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://funarchy.gitbook.io/funarchy/security-for-prediction-market/trading-mechanism/clob-risks/signature-replay-attacks.md).

# Signature Replay Attacks

#### Description

A typical replay attack refers to the problem of repeated execution of identical transactions on a single chain due to inadequate nonce management.\
However, in structures like prediction markets (PMs), where multiple markets (Market A, Market B, etc.) are deployed with the same code or distinguished solely by `marketID` within a single contract, "signature reuse across markets" can be a critical issue.

If the domain separator (`chainId`, `verifyingContract` (contract address), or `marketId`) is not explicitly included in the signing message, an attacker can submit the signature generated by a user for market A to market B as is, stealing assets or executing unwanted orders.

#### Attack Scenario

<figure><img src="https://4210179539-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2DiVEbUgCTsp2iPassR9%2Fuploads%2F1cIEYmg2QBqjxxbhezUS%2Fimage.png?alt=media&amp;token=53e4dbf1-45e1-4f02-92f8-901b2475231d" alt=""><figcaption></figcaption></figure>

{% stepper %}
{% step %}
A user generates an EIP-712 signature required by the contract to submit an order or make a withdrawal on Market A.
{% endstep %}

{% step %}
Market A verifies the signature and processes the request, and the signature data is published on-chain.
{% endstep %}

{% step %}
The attacker copies the published signature and retransmits it to a Market B contract that operates with the same code logic but is a separate market.
{% endstep %}

{% step %}
If Market B's verification logic does not include verifyingContract (contract address) or marketId in the signature, it will incorrectly consider the signature for Market A as a signature for Market B and pass it.
{% endstep %}

{% step %}
As a result, assets in Market B are withdrawn regardless of the user's intention, or unwanted positions are entered into, resulting in direct losses for the user.
{% endstep %}
{% endstepper %}

#### Mitigation

* **EIP-712 Domain Separator Mandatory**
  * The domain of the signing message must include `chainId` and `verifyingContract` (contract address), ensuring that the signature is only valid for a specific contract on a specific chain.
* **Include business logic identifier**
  * When managing multiple markets within a single contract, you must include `marketId` or `roundId` in the signature message (Struct) to strictly limit the scope of use of the signature to a specific market.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://funarchy.gitbook.io/funarchy/security-for-prediction-market/trading-mechanism/clob-risks/signature-replay-attacks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
