Skip to content
Sentraio

Agent security on NEAR

AI agents can hold money now.Sentraio decides what they may do with it.

A prompt-injected agent will try to pay the wrong account. With Sentraio, the money stays where it is.

Rules on-chain · Reasons in plain words · Allow signs · Warn asks a human · Block refuses · Panic in one click

01 — At a glance

Cheap to run, hard to fool.

Measured in the sandbox, not estimated: every number comes from the test suite or a worst-case run.

Gas per action · 0.0001 NEAR per Tgas

  • Agent payment6.9 Tgas · ~0.0007 NEAR
  • Payment with Clearance signature7.2 Tgas · ~0.0007 NEAR
  • Rejected attempt (strike)2.1 Tgas · ~0.0002 NEAR
  • Panic, 10 tokens + NEAR drained47.7 Tgas · ~0.0048 NEAR
  • Blocklist report1.9 Tgas · ~0.0002 NEAR

9

independent checks per payment

62

unit tests across contracts and packages

0

NEAR lost to the injected invoice

16%

of the 300 Tgas limit in the worst case

02 — Three layers

Check. Enforce. Explain.

Each layer works on its own; together the agent can only ask, never take.

01

Clearance

Who is being paid, and what will really happen?

Checks the receiver and the token before anything is signed, then simulates the payment on real contract code with real balances in a sandbox.

Look-alike names / Registry / Code changes / Simulation

Try Clearance →

02

Vault

The mandate the agent cannot step outside of.

On-chain limits per transaction and per day, single-use Clearance signatures, strikes that auto-freeze, and a constant-gas panic switch. Native NEAR included.

Limits / Approvals / Auto-freeze / Panic

Open the vault →

03

Tx X-Ray

Success on top, failure inside? It tells you.

Reads every receipt of any NEAR transaction, explains each failure with a fix, and shows where the funds actually are now.

Receipt tree / Fix hints / Funds now / Testnet + mainnet

Explain a transaction →

03 — How a payment flows

Four steps, one signature.

  1. 01

    Agent plans

    The LLM decides to pay. It holds only a function-call key for vault.execute.

  2. 02

    Clearance checks

    Nine signals, worst wins. Allow signs, warn waits for the owner, block refuses.

  3. 03

    Vault enforces

    Limits, receiver rules and a valid, unused signature, or nothing moves.

  4. 04

    Tx X-Ray explains

    Every outcome comes back as a plain-language report with the funds trail.

  • Block

    Block. Clearance never signs; the guard refuses.

  • Warn

    Warn. The owner decides with a wallet signature; the agent cannot approve itself.

  • Block

    Bypass. The vault rejects calls without a valid, unused signature.

04 — The attack, replayed

One injected invoice, five situations.

Run it yourself with pnpm demo:attack: local sandbox, no keys, no funds.

  • 01Injected invoice, plain wallet keyAttacker +5 NEAR.Failed
  • 02Honest invoice, through SentraioShop +2 NEAR, explained.Allow
  • 03Same injected invoice, through Sentraioshop-payrnents ≈ shop-payments. Attacker +0.Block
  • 04Compromised code calls the vaultApproval missing or forged. The key cannot move NEAR.Block
  • 05First order from a new vendorThe owner signs off in the wallet, then it pays.Warn

05 — Built on NEAR

What it stands on.

near-sdk (Rust)

Vault and registry contracts, pinned to build for mainnet protocol 86.

Docs ↗

near-workspaces sandbox

Clearance simulation and every end-to-end test.

Git ↗

NEP-141 / NEP-297

Token transfers and event logs that the vault and Tx X-Ray speak.

Spec ↗

NEP-413

Owner approvals are signed messages from a full-access key.

Spec ↗

Function-call keys

The agent key: one contract, one method, gas-only allowance.

Docs ↗

NearBlocks API

Receiver age and activity signals.

API ↗

FastNEAR RPC

Regular and archival nodes, so Tx X-Ray also reads old transactions.

Site ↗

Agent API

Spending policy for agents. Sentraio covers what it does not: counterparties, simulation, native methods.

Docs ↗

06 — Run it

Three commands, no wallet needed.

Real contracts and real token code in a local NEAR sandbox, with fake money.

pnpm install
pnpm demo:attack                  # the five situations above
pnpm dev:chain                    # sandbox for the dashboard
pnpm --filter @sentraio/web dev  # http://localhost:3000

07 — Honest limits

What it does not promise.

  • 01Simulation fully reproduces standard NEP-141 tokens; contracts with too much state (big DEXes) run partially, and Clearance says so with a warn.
  • 02Approvals are single-use and expire within 10 minutes: this narrows, but does not remove, the gap between simulation and execution.
  • 03Registry “blocked” needs a moderator. Many community reports only make an account “suspected”, so sybils cannot hard-block anyone.
  • 04A function-call key’s allowance pays gas only and cannot be topped up; the owner keeps the full-access key to rotate it.

08 — Questions

Questions judges should ask.

Isn’t this what NEAR’s Agent API already does?+

The Agent API caps spending and can freeze an agent, but its policy does not protect native methods and it does not ask who is being paid. Sentraio adds the counterparty check, simulation, a vault that covers native transfers, and the failure explainer. Use both.

What if a prompt injection takes over the agent?+

The agent can still only ask. Clearance blocks look-alike or reported receivers, and the vault refuses any call without a valid, unused Clearance signature. The agent’s key cannot transfer NEAR or add keys.

Can the agent approve its own warning?+

No. Answering a warn needs a fresh NEP-413 signature from a full-access key of the vault owner, checked on chain, single-use and valid for five minutes. The agent has no such key.

What if the guardian (Clearance) key leaks?+

An attacker could sign approvals, but only inside the owner’s mandate: limits and receiver rules are enforced by the contract. The owner rotates the guardian or hits Panic.

What happens when a transfer fails?+

The vault puts the amount back into its ledger and the daily budget. Tx X-Ray shows the failed receipt, the refund and where the funds are. Untracked tokens can be recovered with sync_balance.

Can attackers knock the contracts over with bots?+

Every caller pays their own gas and cannot grow the vault’s state. Loops are bounded (10 tokens, 50 receivers), and Panic costs the same however many agents exist.