Your AI agent can drain your Stripe account at 3am and n8n won't stop it

@designer_drc I Thought about it, and decided against putting it in the decision path. Here’s the reasoning.

What makes the log worth anything is that every decision has a reason you can read. “R2 denied it, amount over 500.” A score can’t do that. It says 0.82, and nobody — including me — can tell your client why. The moment the log contains a number nobody can explain, it stops being evidence and becomes a vibe.

There’s a practical problem too. Anomaly detection needs a baseline of normal, and most of these workflows don’t have the volume to build one. A clinic doing forty bookings a day never produces a distribution worth trusting. You’d get false positives, and an approval queue that cries wolf gets click-through-approved inside two weeks. Then it’s worse than nothing, because the one real alert lands in a queue nobody reads anymore.

But the instinct is right and there’s a deterministic version of it. Aggregate rules — more than N of these in an hour, total over X in 24 hours. That catches the shape most of these attacks actually have, because draining an account is a volume problem, and it catches it with a rule you can still read six months later.

Where I think scoring does belong is out of the decision path, running over the log. Let it look at what already happened, propose a rule, and have a human accept it. The statistical part improves the rules, the rules keep making the decisions, and the log stays explainable.

Curious whether you’d draw the line in the same place.

This is the right answer and it’s better than gating, so let me say that first. Capability beats permission. If the agent can’t reach the credential, you’re not depending on a check being correct — you’ve removed the thing the check was protecting.

Where I’d still add a layer, inside your pattern rather than instead of it, is the rules themselves.

In that design the policy is n8n nodes in the child workflow. That works, and it has two properties worth knowing about. It’s editable by anyone who can edit the workflow, and it leaves no record of what it used to say. Six months from now a client asks you to show that the agent could never refund more than 500 in March. You can show them the workflow as it is today. You can’t show them what it was in March, who changed it, or when.

The second is what happens at ten of these. One refund workflow with deterministic rules is elegant. Twelve action types across five clients is twelve workflows with hand-written rules in each, drifting apart, and no single place that answers “what are all our rules about money.”

And the part I’d be most careful about: your workflow rejects out-of-policy requests, but does it record them? The refusals are the interesting data. A compromised agent looks exactly like a healthy one in the executions list, right up until you notice it asked for eleven refunds it didn’t get. If those attempts aren’t written down somewhere durable, the only signal you had is gone.

So I’d keep your architecture exactly as described and have the child workflow make one call for the decision rather than encoding the rules in nodes. Credential stays where you put it. The agent still can’t reach Stripe. The rules move to one place, versioned, with every request recorded including the refused ones.

Genuine question, because you’ve clearly thought about this harder than most: in your pattern, how do you answer the client who asks what the rules were three months ago?

1 Like

@BorkoB I think I’d draw the line pretty close to where you have.

The bit I’d change in my original pattern is that I wouldn’t leave the policy embedded as hand-written logic inside each action workflow once this grows beyond one or two cases.

I’d still keep the sensitive credential and final Stripe action inside the dedicated child workflow, but I’d have that workflow call a common policy layer and record the exact policy version used for every decision, including denials.

That solves the three-month question much more cleanly. If a client asks what the refund rules were in March, I want to be able to say “this request was evaluated against refund-policy v17, effective from X to Y, and rule R2 applied”, rather than trying to reconstruct it from whatever the workflow looks like today.

n8n does have workflow history, and source control can give you more change history depending on how the instance is set up, so I wouldn’t say there is literally no history available. But I agree that I wouldn’t rely on workflow history alone for an audit requirement like this.

The policy itself should be versioned independently, and the decision record should reference that immutable version.

I also completely agree on denied requests. Those are probably more interesting than the approved ones from a security point of view. If an agent suddenly asks for 11 refunds and all 11 are rejected, financially nothing happened, but operationally that is exactly the event I want preserved and visible.

So I think the pattern becomes:

Agent can request an action, but cannot reach the credential.

The action workflow re-reads authoritative data, calls the versioned policy layer, records allow/deny/approval against the policy version, and only then performs the sensitive operation if permitted.

That still keeps the capability boundary we were talking about, but avoids the policy logic slowly drifting across a pile of separate workflows.

I think your point about using scoring outside the decision path fits nicely with that too. Let it analyse the decision log and suggest new rules, but keep the thing actually authorising money movement deterministic and explainable.

@Michael_Long You’ve just written the spec for the thing I have open, and more precisely than I had it.

So this is useful rather than agreeable, here’s where mine actually is. The decision record stores which policy and which rule fired — but the rule identity is positional, an index into a list. Reorder the rules and an entry from last month quietly points at a different one. Policies are edited in place, no versions. There’s a separate activity log recording who changed a policy and when, which sounds like it closes the gap and doesn’t: it says “rules changed”, not what they changed from or to.

So today I can answer “which rule decided” and “when was this policy last touched”, but not “what did that rule say in March.” Your v17 example is the gap exactly. I caught it two days ago, looking at a decision response and noticing that field was an index.

What I’m doing about it first is the cheap half rather than the right one — store the rule set before and after in each change event, so the history is at least reconstructable by timestamp. Immutable versions stamped on the decision is the correct answer and the one that survives a real audit. But I’d rather ship something honest this week than something complete in a month.

One thing worth adding from fixing an adjacent bug this week. When you do stamp the version onto the decision, capture it atomically with the evaluation, not at write time. A policy edited between evaluation and record leaves you citing a version that wasn’t the one used — an audit trail that’s internally consistent and wrong, which is worse than one that’s obviously incomplete. Same shape as hashing the payload at check time rather than trusting it hasn’t moved by execution.

And yes on denials. Eleven rejected refunds is nothing financially and the most interesting thing in the log operationally.

@BorkoB that atomicity point is a good catch. An audit record that confidently names the wrong policy version is definitely worse than one that admits it can’t reconstruct the decision.

Also, credit where it’s due: this has turned into one of the better threads I’ve seen on AI agent controls in n8n because it’s moved past the usual “just add human approval” answer and into the details that actually matter in production.

I’d probably make one small change even in the “cheap half” you’re shipping now: stop using the rule’s position as its identity.

Give each rule a stable ID that survives reordering, then store that ID on the decision. Even before full immutable policy versions exist, that removes one class of ambiguity immediately.

Then the interim model could be stable rule ID on every rule, full before/after rule set on every policy change, and the decision records the rule ID plus whatever revision/timestamp was actually used during evaluation.

That gives you something reconstructable today without pretending it is immutable versioning.

Longer term I agree the clean answer is a real policy version created on change and evaluated as a specific immutable object. The important part, as you said, is that the evaluator and the decision record agree on that version as part of the same operation.

I’d probably treat the policy version the same way I’d treat an idempotency key or payload hash: it becomes part of the decision context at evaluation time, not metadata added afterwards.

And yes, the denials point keeps getting more important the more I think about it. A burst of denied actions is effectively a security signal, not just failed workflow traffic.

Taking the stable ID now — you’re right that it’s cheap and it removes the ambiguity straight away. I’d rather ship two honest halves than wait on one complete thing.

One wrinkle worth naming for anyone doing the same. Existing decision records already point at positions. Once rules have IDs you have two eras in the log: entries that name a rule, and entries that name a slot. The temptation is to backfill and make it look uniform. I think that’s wrong — better for the log to say which era an entry belongs to than to imply a precision it never had.

On denials as a signal, agreed, and I’d add the inverse. A rule that was catching things and suddenly catches nothing is usually not good news. It normally means an action type changed or a field got renamed, and the gate is now standing in front of traffic that no longer reaches it.

I had exactly that last week, for an unrelated reason — a transposed letter in an action type I’d sent someone. Every call would have matched no policy at all and fallen through to the org default, and the log would have looked busy and healthy the entire time. I caught it by eye in a screenshot, which is not a control.

So the alert isn’t only “denials spiked.” It’s also “this rule stopped firing” and “calls are arriving for action types no policy covers.”

And thanks — the thread’s been more useful to me than anything I’ve read on this.

Mcpherson_AI nailed the core problem. Tool availability quietly becoming authorization is the whole threat model, and no amount of prompt engineering fixes it because the agent is the wrong layer to enforce it.

The fix is receipts written by the execution layer, not the agent. When the layer that actually runs the tool records what was called, with what inputs, what came back, and when, hashed at execution time, you get an audit trail the agent can’t edit, omit, or hallucinate. BorkoB’s point about carrying the decision ID through the outbound action and binding the downstream receipt back to it is exactly right: that’s the correlation primitive. The receipt is the thing you bind to.

In practice: every tool call the agent makes should produce its receipt from outside the agent’s control. Then ‘why did this action happen’ has an answer that doesn’t depend on asking the agent.

1 Like

Right, the part I keep coming back to is that the evidence can’t depend on the agent describing its own behavior.
The decision, execution event, and downstream receipt need to be independently correlatable.
Otherwise “why did this happen?” eventually turns into asking the same system you’re trying to audit.

Disclosure: I build in this space, so weigh that accordingly.

@Michael_Long’s child workflow is the right shape. I’d add one step inside it, because without that step the boundary moves the credential and leaves the trust exactly where it was.

Basically, the agent gets to call your function and nothing else. It can only act after its exact intent has been approved. Inside the function:

  1. Look up the charge and the existing refund state from Stripe. Do not use the amount or the order id the agent passed in.
  2. Hash the values you just looked up. Ask for approval on that.
  3. A person approves the looked-up values.
  4. Right before the Stripe call, check the hash again. If it does not match, refuse.
  5. The function holds the credential and makes exactly one call, built from the values the hash covers.
  6. Write what Stripe returned back against the same id.

Step 1 is the whole point. The approval ends up bound to values the agent could not choose. If you hash what the agent sent instead, a person approving “refund 500 on order 12” is approving the agent’s sentence, and nobody has checked that order 12 was refundable or that 500 was ever the charge amount. That failure walks straight through the credential boundary.

The general shape: freeze the intent, approve the frozen version, and keep the credential out of the agent’s reach. Those are three separate things and you need all three. I call that frozen version a facts hash.

Step 6 is the other half. Same id on the decision, the execution and the result, written by the function. Then “why did this happen” has an answer that does not come from asking the agent.

What I do not have a good answer for: this only works on values you can look up. An amount you can look up. A sentence inside an email body you cannot, and that is the case where the action is inside policy and the text still says something false. So for those, what do you actually put in front of the person, and how do you show them which parts came from a lookup and which came from the model?

@Souvent22 I think the answer to your last question is that provenance has to be preserved while the message is being built, not reconstructed after the model has written it.

If the model generates one polished paragraph and then we ask “which parts came from Stripe and which came from the model?”, we’ve already made the reviewer’s job much harder.

I’d keep the inputs separate: verified facts from Stripe or the CRM, original source material where relevant, and model-generated wording. Then the approval view can show those separately alongside the exact message that will be sent.

So if the message contains a refund amount, customer name or order status, those values should come from the verified data the workflow retrieved. The model can use them when writing the message, but it shouldn’t be the source of those facts.

For anything genuinely free-form that has no authoritative source, I’d mark it clearly as model-generated rather than presenting it with the same apparent authority as looked-up data.

That way the reviewer can see what the system knows, what came from the original source, and what the model added, instead of being asked to fact-check one polished block of text with no provenance.

@Souvent22 — step 1 is the correction. Hashing what the agent sent binds the approval to the agent’s sentence, not to anything true.

To be precise about what I guarantee: what was approved is what executes. Not: what was approved is true. Only the first one is mine. Your facts hash works on top of it — the workflow does the lookup, passes the looked-up values, and the binding holds to those. What’s missing is that nothing forces it. An approval built on the model’s numbers looks identical to one built on verified facts, and the record can’t tell them apart.

@rambozambo, @Mcpherson_AI — same boundary on my side, and worth being exact about it. The decision record is written server-side before the action and the caller can’t rewrite it afterwards. The execution claim is different: the caller reports it. So I can prove what was approved. I cannot independently prove what ran. A receipt written by the layer holding the credential is what closes that, and that layer isn’t me.

Michael_Long — provenance travelling with the fields instead of being reconstructed after the model has written one polished paragraph is the answer to Souvent22’s question, and it’s buildable on my side. Marking which payload values came from a lookup and which the model wrote, then showing the reviewer that difference rather than one block of equally-authoritative text. That moves ahead of most of what’s on my list.

@BorkoB This is the cleanest statement of the boundary yet. “I can prove what was approved. I cannot independently prove what ran.” That’s the whole gap in one sentence.

The receipt has to be written by the layer that holds the credential and executes the call, because that’s the only record the caller can’t rewrite afterward. My earlier post said receipts from outside the agent’s control, but yours is the sharper version: not just outside the agent, the credential holder specifically. If the caller reports its own execution, you get the same problem one level down.

One honest limit worth naming, since you named yours: even the credential layer’s receipt only proves what crossed its boundary, the exact call it made and the response it got back. It doesn’t prove downstream truth. Your out-of-band read-back (Stripe webhook, CRM lookup) is still the other half of it. Receipt says “this is what the layer did.” Read-back says “this is what the world looks like now.” Both, bound by the same correlation ID, is the full answer. Either one alone leaves a hole.

Agreed on the credential holder — “outside the agent” wasn’t tight enough, and a caller reporting its own execution is exactly where my side stops.

The correlation ID is where I’d add a practical constraint. It has to survive systems that have never heard of any of us. A Stripe webhook doesn’t know my decision ID unless it was placed somewhere Stripe hands back — idempotency key, metadata, a reference field. Same for a CRM read-back. So the ID can’t be internal to whoever issues it. It has to be chosen early and deliberately planted in whatever the downstream system will echo.

Which makes it three records rather than two: what was approved, what the credential layer actually called and got back, and what the authoritative system says now. Different writers, different trust properties, one ID across all three. I own the first and I can’t own the other two — but the ID is the thing that has to be agreed between them.

@BorkoB The three-records framing is the right one, and “chosen early and deliberately planted” is the load-bearing detail. The credential holder is the only writer that sees both the approval and the real call, so it’s the only honest stamper of the ID. Plant it at approval time and it becomes the join key across three differently-trusted writers: what was approved, what the credential layer called and got back, what the authoritative system says now. A receipt-shaped record at each boundary (ID, timestamp, hash of what that writer actually saw) turns reconciliation from an exercise in trust into a query.

One constraint your version already implies: the third record is the weakest link in the chain of custody, because you can’t write to it, only read it. A webhook says “Stripe told me,” a dashboard or API read-back says “I asked Stripe directly.” Pair the read-back with the receipts, never substitute. The receipts prove what crossed each boundary; the read-back proves the world agrees. Same ID on all three, and the audit becomes boring. Boring is the goal.

@rambozambo your last one landed. The credential holder being the only honest stamper of the ID is the part I keep coming back to, and you are right that the read-back is the weakest link, because I can only read it and never write it. Boring is the goal. I am not there yet, but the log is at least honest about where it stops.

this might be something for you too. @Michael_Long @Souvent22 @Mcpherson_AI @designer_drc @StefanGwiggner

Working version is up, with the workflow JSON and the policy JSON, so you can run it instead of reading about it: Try to get something past my policy gate

The receipt gap you all pointed at is still open, and it is named in the post.

Thank you for this. These threads made the thing better than it was, and it has been the best community experience I have had.

Peace out :smiley:

2 Likes

Protopond said: Automated agents should have clearly defined limits, especially when they can interact with financial systems. Approval requirements and restricted permissions seem like useful safeguards for preventing unintended actions.

1 Like

@BorkoB the provider receipt on the execution record. Take your three records: two of them are already signed by a layer that is not the caller, and the reason the third is not is the design, not a gap.

Record zero, the model call that wrote the payload. That call crosses a pipe that holds the credential and makes the call itself, so the pipe signs the crossing, not the agent. The ID you plant at the gate goes out as the session header and comes back inside the signed record: bound at the moment of the call, not correlated afterwards. Every crossing carries the SHA-256 of the exact request the pipe sent, the hit-or-miss verdict and the price; the SHA-256 of what the model sent back lands on the same record this week. Signature hashes are sealed into hourly Merkle slots, public at /v1/public/clock, with roots anchored through OpenTimestamps, so the record proves when as well as what. One from this morning, the session id is the planted one: Metrecept | Proof, not trust
Opens in a browser, checks against a public key directory, no account with anyone.

Record three, the read-back. The same pipe makes read-only GETs to Stripe or a CRM on the agent’s behalf and signs that crossing too: same record shape, same key, same clock. That turns the weakest link in your chain, “what the world says now”, into a record written by a layer that is neither the caller nor the vendor. One ID across zero, one and three.

Record two, the write itself, is signed by whoever holds the write credential, because a recorder signs what it did and never what someone else did. The pipe makes model calls and reads; it does not make the write, so it does not put its name on the write. That is the standard to hold the write layer to, and the record shape above is what it should look like when they meet it.

The principle under all of it: the record is made by the layer that did the thing, at the moment it did it, signed with a key the audited party never held, checkable by a stranger. The agent cannot edit it, the workflow owner cannot edit it, and neither can I. Session receipt is the $0 kind. I built the pipe.


Edit, 13 October, answering your #40 below. Kept in this thread, as you asked in the approvals thread.

@BorkoB yes. Here is the run as I would do it with you, then the shape of it already done tonight so you can see every piece before you plant yours.

  1. The workflow mints one ID before anything else. A UUID is fine. It is yours, not mine, and it is minted before the model is asked anything.
  2. The model call crosses the pipe with that ID in X-Metrecept-Session. Each crossing gets its own signed record (request SHA-256, response SHA-256, HIT or MISS, price). GET /v1/sessions/<id> then mints the session receipt, and its session_sha256 is sha256(<id>). The raw ID never leaves the workflow and is not in the receipt; a stranger who is handed the ID hashes it and matches the receipt, and nothing else matches.
  3. The same ID goes to Guardian as the idempotency key, so your decision record is unique on it, and into the Stripe call as Idempotency-Key and in metadata, so what Stripe says afterwards carries it back on its own signed event.
  4. The stranger’s walk: hash the ID, match the session receipt (signed by the pipe, key in a public directory, no account with anyone); same ID, your decision record; same ID, Stripe’s event, signed by Stripe. Three writers, one ID, none of them the agent and none of them writing another’s step.

Done tonight with the ID 2db01b8a-a820-4c33-8682-f078de3663af, three calls, the second a replay of the first, the third a changed payload, then the session:

sha256("2db01b8a-a820-4c33-8682-f078de3663af") is 34f824639709e90b5004a7d5c10f5117c3fb67459fab8044e4fa776c8b18693a, which is the session_sha256 on that session receipt. Each link opens in a browser and checks the Ed25519 signature against the public key directory; no account with anyone. Those four signature hashes are leaves of the hour 20261013T00Z, open as I write this, sealed at 01:00 UTC and handed to the OpenTimestamps calendars inside the quarter hour after: https://api.metrecept.co.uk/v1/public/clock/slots/20261013T00Z

On the hour from the post above, 20261012T03Z: the public slot still reads calendar_pending_bitcoin. Two of the three calendars now return a Bitcoin block-header attestation for that hour’s commitment, blocks 971150 and 971155. The slot view will read bitcoin with the heights once the pass that writes that back is live; I will not call it anchored on the public view before the view says so.

Update, 00:58 UTC: that pass is live. https://api.metrecept.co.uk/v1/public/clock now reads bitcoin with blocks 971150 and 971155 for 20261012T03Z (and for 20261009T17Z and 20261012T04Z, the hours of the receipts in the other threads).

What the run does not prove, by my own rule: the write. Your record is the decision, the pipe’s record is the model call and any read-back it made, Stripe’s is the write. Nobody signs another’s step. The pipe did not stop anything. The session receipt is the $0 kind.

Ready when you are. Plant your ID, send it to me with the hour, and I run the pipe end; or if you want to hold the model call yourself I will hand you a key for the run.

1 Like

That split is clear, thank you. Guardian sits at the door of record two: it decides before the write and records who approved, but it doesn’t hold the write credential either. The workflow does. So by your own rule, Guardian’s record is the decision, not the write.

What interests me is one ID across all of them. If the workflow plants one ID and passes it to your pipe as the session header and to Guardian as the idempotency key, a stranger could follow one action from the model call, through the approval, to what Stripe says afterwards. Would you try that on one test run with me?

@iwasinnam21 yes, let’s run it. You run the pipe end; I’ll plant the ID, the Guardian check and a Stripe test-mode payment.

One correction on my side before we start, because it matters for the walk. Guardian’s idempotency key is not one of the fields in the hash chain. So I’ll put the ID in the payload as well. The payload is chained, so the ID becomes part of the record a stranger can check, not just a uniqueness rule.

Two questions back.

Stripe signs its webhooks with the endpoint’s secret, which only the account owner holds. So a stranger can’t verify Stripe’s event on their own; they’d have to trust me, or have access to the account. How would you close that step of the walk?

And can your public clock take a leaf from outside the pipe? If Guardian could seal its chain head into your hourly slot, the decision record would get the same outside timestamp as your receipts. Right now Guardian’s verifier runs inside Guardian, and that’s the gap I care about most.

I’ll post the ID and the hour here when it’s planted.

1 Like

@BorkoB good. Payload, not the key, is the right correction: a uniqueness rule is enforced once and forgotten; a chained field is checkable for as long as the chain is.

On Stripe. You are right that nobody outside the account can verify Stripe’s signature; it is an HMAC with a secret only you hold, so the walk cannot end at “Stripe signed this”. It can end one step earlier, at bytes you committed to before anyone asked. When the webhook lands, hash the raw body Stripe sent (the exact bytes its signature covers) and put that digest, the event id and the planted id into the chained Guardian record. The Stripe event itself carries the planted id twice, as request.idempotency_key and in metadata, so the record and the event name each other. A stranger then checks two things without your secret: that the record was sealed in a public hour before the dispute, and that the event body you show them later hashes to what was sealed. What they cannot check is that Stripe, not you, produced that body. That last step is the account holder’s, or an auditor’s with a read-only key to the account, and I would state it as the boundary rather than paper over it. Same shape as a bank statement: the stranger verifies the bookkeeping is consistent and dated; the bank’s say-so is the bank’s.

On the clock: yes. Until tonight every leaf was the SHA-256 of a signature the pipe itself produced, and the slot view said so (leaf_algo: sha256(ed25519_sig)); there was no door for an outside digest. You named the gap that matters most, so I built the door this evening. It is implemented, tested and live on api.metrecept.co.uk:

  • POST /v1/clock/leaf with {"digest_sha256": "<64 hex>"} and a pipe key. It seals your digest into the current UTC hour beside the receipts and returns the slot id, the leaf index and the inclusion URL. Same tree, same hourly seal, same calendar anchoring and Bitcoin upgrade as every receipt in that hour.
  • The leaf is sha256("metrecept-clock-external-leaf/v1" || digest). Domain-separated, so an outside digest can never be presented as a receipt signature or the reverse, and a stranger derives it from your digest with one line.
  • Marked, not hidden: every slot view carries external_leaf_count and lists external_leaves, and inclusion answers leaf_type: external with your digest_sha256, so nobody mistakes an outside leaf for a receipt. The clock’s own not list now says it: an external leaf is a digest a key-holder asked us to seal; we did not see, sign or vouch for what it names.
  • Stranger’s check: GET /v1/public/clock/inclusion?digest=<hex>, or python scripts/verify_clock.py --digest <hex> --base https://api.metrecept.co.uk, which derives the leaf, recomputes the RFC 6962 path to the root and prints the hour’s commitment.

Not a receipt, not billed. It fixes the hour and nothing else. The first two outside leaves on the clock went in a few minutes ago, in hour 20261013T22Z at indices 20 and 21: the SHA-256 of two cross-check fixtures I cut this evening for an outside auditor, each of which contains receipts that are themselves leaves of that same hour. Digests eae3edea6fd647d799868b78f001c7906d9d43471f1d0e3f348ecfd538be30c2 and 1637e02f8f87df9cb5db278c542441ab7d97af2b1e2bc3f1b91d9d2b3a22e9c7; GET /v1/public/clock/inclusion?digest= either one answers now, status: open until the hour seals at 23:00 UTC, and I will post the sealed inclusion path here after that. Guardian’s chain head should be the next: seal the head at decision time, and the decision record and the crossing it governed sit in one hour with one outside timestamp neither of us can edit, which is exactly the property your in-Guardian verifier cannot give you.

Until you have a key in hand the head can also ride tonight’s run the older way: put it in the body of the planted-id crossing, and the receipt’s request_sha256 is over that body. Sign the body with X-Metrecept-Attest as well and the receipt carries your key id and the body digest under the pipe’s signature (demo/attest_demo.py, verify_receipt.py --attest in the open repo).

Post the id and the hour when it is planted; I run the pipe end and put the receipts here.