> Source: https://developers.terrawallet.us/docs/security . Terra Wallet developer docs (early access).

# Security model

Terra is built so that a breach of Terra, of your Terra account or of an AI assistant cannot move your money.
This page explains how.

> **Early access.** These protections are part of the product design and the v1 contract. Some ship with each
> product as it launches.

## 1. Non-custodial by design

- Payments go from the customer's wallet straight to the merchant's wallet. Terra never holds funds or the keys
  that move them.
- The server never signs. Wallet keys stay on the user's device: in the Terra Wallet app, in the extension's
  encrypted vault, or in the merchant's own wallet.
- Refunds are drafts that a person signs in their own wallet. **No API route moves or signs funds**, for any
  caller.

## 2. Chain truth

- A payment, refund or subscription renewal counts only when the chain proves it, after that chain's
  confirmation policy.
- A transaction hash sent by a client, a redirect to your success page or a webhook from anywhere else is a hint
  to look, never proof.
- Tokens are identified by chain and contract, never by symbol. Names, symbols and logos are display metadata.
- When a chain data provider fails, the API returns an error (such as `PROVIDER_UNAVAILABLE`), never a false
  zero.

## 3. Keys and access

- Secret keys stay on your server. Terra stores only a keyed hash and an 8-character display prefix, shows the key
  once, and accepts it only in the `Authorization` header.
- Keys are bound to one project and one environment, carry explicit scopes, and can be rotated (24 hours of
  overlap) or revoked at once. An optional IP allowlist is in the design.
- Publishable keys (`tw_test_pk_`, `tw_live_pk_`) carry only checkout and connect scopes and work only on the
  exact https origins you allow.
- Every object is authorized per organization on every route. Another organization's object returns `404`.
- Live-mode actions need an Owner or Admin with an authenticator app enrolled.
- Every write is audited. Secrets never appear in logs, responses or the audit log.

## 4. Payout wallet protections

Changing where you get paid needs an authenticator code, an email confirmation and a 24-hour cooldown, and every
owner is alerted. A stolen login cannot quietly redirect your money. See [Payout wallets](https://developers.terrawallet.us/docs/pay/payout-wallets.md).

## 5. Webhooks

- HMAC-SHA256 signatures over a timestamp and the raw body, with a 5-minute replay window.
- Delivery only to public `https` addresses. Private, loopback, link-local, CGNAT and metadata ranges are refused
  and re-checked on every attempt against DNS rebinding. No redirects.
- See [Webhooks](https://developers.terrawallet.us/docs/webhooks.md) for verification code.

## 6. The public API

- TLS only, versioned paths and a published deprecation policy.
- Strict schemas that reject unknown fields, size caps on every string and hard limits on pagination.
- An `Idempotency-Key` on every create.
- Rate limits per key and per organization, plus edge WAF and rate-limit rules.
- Errors never echo input and never include stack traces.
- The OWASP API Security Top 10 checklist runs in CI, and an external penetration test comes before general
  availability.

## 7. Merchant and customer content

- Plain text only, with length caps. No merchant HTML or scripts on any Terra page.
- Logos are virus-scanned and re-encoded.
- Embedded checkout can be framed only by your allowlisted origins.
- Every signature and transaction request in Terra Wallet shows a decoded, readable summary and the requesting
  origin, checked against a phishing list.

## 8. AI and MCP access

- The Docs MCP server is read-only, needs no sign-in and has no access to any account or database. It serves
  only these docs.
- The planned Account MCP uses OAuth 2.1 with PKCE, sandbox-only tokens by default, per-tool scopes on the consent
  screen, a human confirmation for every write, and an org-wide switch that disables AI access.
- Never possible through MCP or any AI path: moving or signing funds, changing payout wallets, creating or
  revealing live secret keys or webhook secrets, changing team roles or two-factor settings, deleting an
  organization.
- Untrusted text (names, memos, webhook payloads) is returned only in labelled, length-capped data fields and
  never inside tool descriptions. Tool definitions are static.

See [Build with AI](https://developers.terrawallet.us/docs/ai.md).

## 9. Before live payments

Before mainnet payments, Terra Pay requires merchant verification (KYB) at onboarding, a restricted-business
policy, sanctions screening of paying addresses and a legal review per launch market. Capped on-chain auto-pay
subscriptions also need an independent contract audit, fuzzing and formal tests, and a testnet beta.

## 10. The Terra Wallet app audit

The Terra Wallet app completed an independent security audit by Certaris in June 2026 (A+, zero findings). That
audit covers the wallet app only, not the developer platform, Terra Pay or the SDK.

## 11. Your side

- Keep secret keys and webhook secrets in a secrets manager. Rotate them if they may have leaked.
- Verify every webhook signature, handle repeats and confirm payment state with the API before fulfilling.
- Fulfil orders from verified events, never from a redirect.
- Use a hardware wallet or multisig for payout wallets that receive large volumes.
- Pin any Terra script with its published SRI hash, and use a strict CSP.
