> ## Documentation Index
> Fetch the complete documentation index at: https://yieldxyz.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Defense Mode

> Server-side Shield validation inside the Yield API, in Monitor or Block mode per project.

Defense Mode is Shield running server-side, inside the Yield API's transaction pipeline. Every unsigned transaction the API constructs is validated before it is returned. In **Monitor** mode a failed validation is logged and the transaction is still returned; in **Block** mode it is rejected before it reaches the client.

<Note>
  Defense Mode complements client-side Shield rather than replacing it. Server-side validation checks what the API constructed; [client-side Shield](/documentation/platform/shield/index) checks what you received, after it left the API. Running both covers both paths.
</Note>

## How it works

```mermaid theme={null}
flowchart TD
    A[Client request] --> B[Yield API constructs unsigned transaction]
    B --> C{"Shield (Defense Mode)<br/>decode · pattern match ·<br/>receiver/owner/spender checks ·<br/>tamper detection"}
    C -->|valid| D[Transaction returned to client]
    C -->|invalid, Monitor| F[Logged · transaction returned]
    C -->|invalid, Block| E[Rejected · client receives an error]
```

Defense Mode uses the same engine as the client-side library: the same validators, vault registry and calldata tamper detection (see [What Shield checks](/documentation/platform/shield/index#what-shield-checks)). It runs in the same process as transaction construction.

| Mode | On a failed validation | Default |
| - | - | - |
| Monitor | Logged server-side; the transaction is returned as normal | Yes |
| Block | Rejected; the client receives an error instead of the transaction | Enabled per project by yield.xyz |

yield.xyz enables Block for a project after a Monitor period on live traffic, and can switch a project back to Monitor through configuration. Every validation, allowed or failed, is logged server-side.

Yields without a registered Shield validator are currently skipped server-side rather than blocked. Check coverage with `isSupported(yieldId)` (see [Shield features](/documentation/platform/shield/features)).

## Threat model

| Threat | Covered by Defense Mode | Notes |
| - | - | - |
| Transaction construction altered inside the API (compromised code or dependency) | Yes, in Block mode | Shield validates the constructed transaction independently of the code that built it. Shield currently runs in-process, so a full compromise of the API runtime is not covered; isolating Shield in a separate deployment is planned but not scheduled |
| Response altered between the API and your client | No | Covered by client-side Shield |
| Client modifies a transaction after receiving it | No | Client-side Shield and wallet confirmation |
| Protocol-level exploit in a contract Shield approves | No | Shield checks transaction structure, not the safety of the underlying protocol |
| Gas parameters (`maxFeePerGas`, `gasLimit`) | No | Not validated today |
| Amount changed from what the user intended | Only when an intended amount is declared | Declare `args.amount` or `args.shareAmount` when calling Shield client-side |
| Phishing or a user approving an unwanted transaction | No | Wallet-level confirmation |

For high-value or sensitive flows, ask yield.xyz for the current list of known coverage gaps.

## For integrators

When Defense Mode is enabled for your project, nothing changes in your integration code. In Block mode, a rejected transaction returns **HTTP 500** with the message `Transaction blocked by security validation`. The detailed reason is logged server-side and not returned, so Shield's logic can't be probed through error messages. If you believe a block is incorrect, contact yield.xyz with the request timestamp and your project so the reason can be looked up.

Keep validating client-side as well: see [Shield integration](/documentation/platform/shield/integration).

## Next steps

<CardGroup cols={2}>
  <Card title="Shield overview" icon="shield-check" href="/documentation/platform/shield/index">
    What Shield checks and where it runs.
  </Card>

  <Card title="Shield features" icon="list-check" href="/documentation/platform/shield/features">
    Coverage matrix and validation errors.
  </Card>

  <Card title="Shield integration" icon="plug" href="/documentation/platform/shield/integration">
    Library, binaries, and language guides.
  </Card>

  <Card title="Security deployment options" icon="layer-group" href="/documentation/platform/shield/security-tiers">
    Client-side, server-side, or both.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.