- Home
- Skills
- Agents & Orchestration
- TollGate - agent money safety review
Works with the AI Agents you already use
TollGate - agent money safety review
Audit code for money-moving AI agents to prevent double-spending, race conditions, and unrecorded transfers.
Free
TollGate - agent money safety review
Example session with this skill installed
Review the payment worker in services/billing.py and the idempotency logic in db/locks.sql. Find any race conditions in the spending cap logic.
- Read your context and instructions
- Compiled the tollgate - agent
I have completed the safety review of the billing worker and database constraints. I identified one Critical race condition and one High severity durability issue.
Agent money-safety review — Billing Service
| # | Path | Entry point | Decision | Provider call | Recorded | Verdict |
|---|---|---|---|---|---|---|
| 1 | Agent Refund | POST /refund | authorize() | stripe.Refund.create | action table | FAIL |
Findings
| # | Severity | Location | Failure scenario | Minimal fix |
|---|---|---|---|---|
| 1 | Critical | services/billing.py:142 | check_cap() reads the sum then writes. 50 concurrent requests can all read the same balance and spend past the limit. | Use SELECT ... FOR UPDATE on the actor row before calculating the rolling sum. |
| 2 | High | db/locks.sql:12 | The idempotency index is missing the actor_id scope. A replay with a different actor could collide with an existing key. | Update UNIQUE INDEX to include (actor_id, idempotency_key). |
Top 3 fixes, in priority order
Lock actor rows — prevents the race condition identified in check_cap(). Proves it: test_rolling_cap_is_atomic.
2. Scope idempotency keys — ensures unique constraints work across multiple users.
3.
Atomic commits — Move the Stripe call record and the database transaction into a single block to prevent unrecorded transfers.
Next steps
- Implement the
SELECT FOR UPDATEpattern in theauthorizefunction. - Add the provided concurrency test suite to your CI pipeline.
- Verify that the Stripe
idempotency_keyis derived deterministically from theaction_id.
Connects securely to your tools. The creator never sees your data.
About this skill
Building an AI agent that handles payments or irreversible API calls is a high-risk engineering challenge where a single race condition or unhandled timeout results in direct financial loss. This skill provides a specialized security auditor designed to find the four specific ways money-moving agents fail: double spending, unauthorized movement, unrecorded transfers, and lost state. It performs a deep-dive code review of authorization caps, idempotency logic, and human-in-the-loop flows to ensure your agent is safe for production traffic.
What it does
- Map side-effect paths by tracing every route where an agent causes a real-world effect from entry point to recording.
- Audit idempotency logic to ensure retries and duplicate webhooks cannot move money twice.
- Verify atomic caps by checking for row locks and preventing race conditions during spending threshold checks.
- Enforce failure classification by ensuring the system fails closed on timeouts or 5xx errors rather than assuming success.
- Review LLM grounding to prevent models from talking their way past rejections or inventing transaction records.
How it works
- Trace execution paths to identify every function that calls a payment provider or triggers an irreversible action.
- Execute triage greps to find common vulnerabilities like float-based math, lookup-then-insert patterns, or missing row locks.
- Audit against six invariants including choke point enforcement, atomic cap math, and single-transaction commits.
- Produce a severity-ranked report with specific file-and-line evidence and minimal, shippable fixes for every finding.
Frameworks & tools
This skill is framework-agnostic but optimized for stacks using SQL databases like PostgreSQL for concurrency control. It includes specific patterns for Python and JavaScript environments.
Why this beats prompting it yourself
Generic security prompts miss the nuance of agentic failure modes like model hallucination in audit logs or crash-recovery cycles. This skill enforces a strict evidence standard where a control only exists if it is backed by a database constraint or atomic code path.
Use cases
- Auditing a Stripe-integrated refund agent for idempotency and replay safety.
- Checking spending cap logic in a multi-agent autonomous procurement system.
- Verifying that human-in-the-loop approval flows survive process restarts.
- Reviewing webhook handlers to prevent double-processing of payment events.
Known limitations
Does not cover PCI-DSS certification, KYC/AML screening, fraud modeling, or the internal guarantees of external payment providers.
Focuses on code-level invariants and database constraints. Does not perform live network penetration testing or provide legal/regulatory compliance certification.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 5 days ago
- Free with an Agensi account