Loops HouseDrainproof

NEAR HACKATHON
Team
1 member- DAOwner
David Peluola
Overview
Drainproof is the test suite for an AI agent's money rules, plus a NEAR vault that enforces them on-chain.
Problem: an agent with a wallet can be talked into paying the wrong account, paying twice on a retry, or blowing its budget. Many tools enforce spending rules. Few test them, and a one-line policy change can quietly open a hole.
What I built:
- A deterministic policy engine (TypeScript, no LLM in the decision): per-payment and daily limits, recipient allowlists, approval thresholds, exact integer amounts, idempotent retries, fail-closed.
- 40 attack scenarios (prompt injection, boundary amounts, races, replayed approvals, malformed input) plus a look-alike recipient pack, run by a CLI and a one-step GitHub Action that fails the pull request when a policy change would let the agent be drained. Demo: PR #2.
- Drainproof Vault, a Rust NEAR contract that holds the funds and enforces the same policy. The agent only gets a function-call key for request_payment, so it cannot withdraw, change the policy or transfer directly.
Proof on NEAR testnet (every hash is in the README): the agent paid the allowlisted shop; the same prompt-injected payment to attacker.testnet was refused by the contract; I then deleted every access key on the vault, so its code can never change; payments and refusals still worked after the lock; and the owner withdrew through the contract.
NEAR's role: function-call access keys and contract-enforced policy make the protocol, not the agent, the last line of defence. The 16 of 40 scenarios a contract can express also run against the vault on a local NEAR node in CI.