Skip to content
hqBrimaxPublic

About

AI Payment Security Layer for NEAR. Policy engine, counterparty scoring, TEE attestation via HashiCorp Vault.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Sentinel — AI Payment Security Layer

Give AI a wallet without giving it the keys to everything.

What it does

Sentinel is a security middleware that sits between any AI agent and its wallet on NEAR. Before an agent sends funds, the layer checks:

  1. Policy Engine — spending limits, allowed recipients, daily caps, human approval thresholds
  2. Counterparty Check — scores the receiver (account age, contract status, blocklist, AI risk analysis) → returns allow/warn/block
  3. Audit Trail — logs every payment attempt with full evidence and TEE attestation
  4. Prompt Injection Defense — blocks malicious prompts from tricking the agent into paying bad addresses

Problem

AI agents that hold crypto wallets can be tricked into sending funds to attackers via prompt injection, phishing, or compromised instructions. There is no standard security layer that gates agent payments before signing. Sentinel provides that layer.

How NEAR fits

  • Uses NEAR RPC (testnet) to query account info, contract status, and balance for counterparty scoring
  • Designed for function-call access keys: agents sign with keys scoped to one contract, never full-access keys
  • Function-call keys can't transfer NEAR or add keys, and lock themselves out if gas runs out — the agent gets money but not the keys
  • TEE attestation verifies policy engine integrity
  • Shared blocklist for cross-agent reputation

How AI is used

  • OpenRouter (free models) powers AI risk analysis for each payment
  • The AI scores counterparty risk (0-100) and provides human-readable reasons
  • Prompt injection demo shows AI-powered defense: a malicious prompt tries to make the agent pay a known scammer, and the security layer blocks it

Track

NEAR Hackathon — AI Security & Defense (security)

Tech Stack

  • Backend: FastAPI + Python
  • Frontend: Vanilla HTML/CSS/JS (no framework dependencies)
  • AI: OpenRouter (free models) via OpenAI-compatible API
  • Blockchain: NEAR RPC (testnet) for on-chain account/contract queries
  • Deployment: Render (Docker)
  • Icons: Lucide (via CDN)

Libraries and Tools

  • fastapi, uvicorn, httpx, openai, python-dotenv, pydantic
  • No frontend framework — pure HTML/CSS/JS for minimal dependencies
  • Docker for deployment

Setup

cd backend
pip install -r requirements.txt
export OPENROUTER_API_KEY=your_key
python main.py

Open http://localhost:8000

How to Try

  1. Open the app at https://near-sec-agent.onrender.com/
  2. Set a policy: Scroll to "Policy Configuration", set max per TX to 100, daily limit 500, require human above 50. Click "Set Policy".
  3. Check a payment: In "Counterparty Check", enter agent_id "demo-agent", recipient "alice.near", amount 10. Click "Check Payment". See the risk score and verdict.
  4. Run the attack demo: Click "Run Attack Demo". Watch 7 steps: a prompt-injected agent tries to send 500 NEAR to scammer.near. The security layer blocks it at every step.
  5. Audit trail: Scroll down to see all logged transactions with risk scores and decisions.

API Endpoints

Method Endpoint Description
GET /api/health Health check + TEE status
POST /api/policy Set agent policy
GET /api/policy/{agent_id} Get agent policy
POST /api/check Counterparty check (allow/warn/block)
POST /api/blocklist/add Add to shared blocklist
GET /api/blocklist View blocklist
GET /api/audit View audit trail
GET /api/audit/stats Audit statistics
GET /api/tee/attestation TEE attestation status
POST /api/demo/prompt-injection Run attack demo

License

MIT — see LICENSE

Hackathon

Built for NEAR HACKATHON (Nov 1-14, 2026). Track: AI Security & Defense.

Repository is public. Demo: https://near-sec-agent.onrender.com/

About

AI Payment Security Layer for NEAR. Policy engine, counterparty scoring, TEE attestation via HashiCorp Vault.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages