Engineering · 21 Jun 2025

Signing boundaries in self-hosted gateways.

The interesting question is never 'can it sign.' It is 'who is allowed to, and how do you prove it later.'

On this page

Key takeaways

  • A gateway that can move value has a political architecture even when the code is simple.
  • Keys, RPC providers, and the database are not implementation details — they are the product boundary.
  • The boundary sentence must survive both counsel and the on-call engineer.
  • No hidden hosted signer and no custody mode: the implementation must follow the sentence.

A gateway that can move value has a political architecture even when the code is simple. Who holds the keys decides who is a vendor and who is an operator. This note explains how we drew that line in StablePay, and why we drew it so plainly.

Software or service?

Keys, RPC, and the database are not implementation details. They are the product. If the studio holds them, you bought a service. If you hold them, you bought software. The distinction has commercial, legal, and operational consequences, and it should be discoverable from the architecture, not the marketing.

ComponentService modelStablePay (software model)
Signing keysHeld by the providerHeld in your environment
RPC providersProvider's choiceThe ones you operate
DatabaseProvider's ledgerPostgreSQL you run
SecretsProvider-managedYour secret store
Path of fundsThrough the providerNot through the studio

The boundary sentence

We wrote one sentence and built to it: the customer operates the environment, the software records what it was asked to do, and the studio is not in the path of funds.

That sentence has to survive two very different conversations: one with counsel, who asks whether the studio is a custodian, and one with the on-call engineer, who asks where the key actually is at 2am. If the answer changes between those rooms, the architecture is lying.

Your applicationOwns customers and orders
StablePay in your environmentRecords what it was asked to do
Your signing processKeys in your secret store
The networkValue moves
The boundary drawn as a path — the studio is not on it

Where the studio is

Outside the path of funds. It ships software and documentation. It holds no keys, runs no signer, and cannot move value on your behalf.

What the implementation rules out

  • No hidden hosted signer. There is no fallback path where a studio-run service signs on your behalf.
  • No "we can hold this for you" mode. Convenience features that require custody are not built.
  • No dashboard that implies visibility we do not have. We cannot see a production wallet we do not run, and the interface does not pretend otherwise.
  • No phone-home for funds. Operation does not depend on the studio being reachable.

Hidden signer

  • A fallback where the vendor signs for you
  • A dashboard implying visibility you do not have
  • Operation depends on the vendor being reachable

A boundary you can draw

  • Keys and signing process in your environment
  • The gateway records intent; authority lives with you
  • Works if the studio disappears tomorrow

Who is allowed to sign?

Once the boundary is drawn, the interesting question moves inward: inside your environment, who can trigger a signature, and how do you prove it later?

Separate intent from authority

The gateway records payment intents. Authority to move funds belongs to whoever operates your signing process. Keeping those separate means an application bug cannot, on its own, become a transfer.

Make approvals explicit

For flows like contractor settlement, the sequence at Helios Grid was: a field-close event created a payable, a supervisor approval authorised it, and only then did a payment intent exist. Each step had a named human or system, and each left a record.

Leave a trail

An audit trail is not a log dump. It is the ability to answer, months later: who approved this, under what policy, and what did the system do next?

Field closeEvent from the ops tool
Supervisor approvalA named person authorises
PayableCreated from the approval
Payment intentIssued by StablePay
Settlement fileWritten for the ERP to ingest
Contractor settlement at Helios Grid — each step has a named human or system

A one-page threat model

Not a substitute for a security review — a way to keep the conversation concrete. For each row, name the control and the person who owns it.

ThreatWhat it looks likeWhere the control lives
Application bug creates a transferA retry loop or bad handler issues paymentsSeparation of intent from signing authority
Leaked signing keyKey in a repository or environment fileSecret store, restricted access, rotation
Forged webhookAttacker marks an order as paidSignature verification on the raw body
Compromised RPC providerFalse or delayed chain dataProvider choice you control, confirmation policy
Insider approval abuseOne person authorises and executesNamed approvers and an audit trail
Unpatched deploymentKnown issue never appliedPatch cadence and upgrade notes

Operating the boundary

Owning the boundary also means owning its hygiene. Our handover guidance is deliberately dull:

  • Keep signing keys in a secret store, not in environment files committed to a repository.
  • Restrict who can reach the signing process, and log every use.
  • Rotate on a schedule and after any personnel change that warrants it.
  • Test recovery: can you rebuild the gateway from backups without the studio?
  • Apply patch releases; a fixed vulnerability you have not deployed is still a vulnerability.

What we do not claim

StablePay is not a custodian, not a bank, and does not provide legal or compliance services. Whether a given operating model meets your regulatory obligations is a question for your counsel.

Questions to ask any gateway vendor

  1. Where do production signing keys live, and who can use them?
  2. Can the vendor move funds on my behalf, even in an emergency?
  3. If the vendor disappeared tomorrow, what stops working?
  4. Which parts of the payment record can I query directly?
  5. How would I prove, to an auditor, who approved a specific payment?

Boundary review before go-live

  • Signing keys live in a secret store, not an environment file in a repo.
  • Access to the signing process is restricted and every use is logged.
  • Recovery has been tested: the gateway can be rebuilt from backups.
  • Approvers are named, and no one person can authorise and execute.
  • Patch releases have an owner and a cadence.

The key lifecycle

Keys are not a thing you have; they are a thing you manage across a life. NIST's key management guidance [1] describes the lifecycle in phases, and the useful takeaway for a payments team is that every phase needs an owner and a procedure, not just the moment of creation.

GenerateIn a secure environment, with sufficient entropy
DistributeOnly to the process that needs it
UseLogged, rate-limited, least privilege
RotateOn a schedule and on events
RevokeWhen compromised or retired
DestroyVerified and recorded
A key's life
PhaseQuestion to answerTypical control
GenerateWhere and how is the key created?Inside the secret store or an HSM-backed service, never on a laptop
DistributeHow does it reach the signing process?Pulled at runtime by an authenticated workload, not baked into an image
UseWho or what can request a signature?A narrow API, allow-listed callers, and logged requests
RotateHow often, and what triggers an early rotation?Calendar schedule plus personnel and incident triggers
RevokeHow quickly can a key stop being trusted?A documented procedure that has been drilled
DestroyHow do we know old material is gone?Deletion from every store and backup policy, recorded

Where keys can live: a comparison

There is no single right place for a key, only trade-offs between convenience, isolation, and cost. The important discipline is choosing deliberately and being able to explain the choice.

OptionIsolationOperational costGood fit
Environment variable or fileLow — readable by anything that can read the process environmentLowestLocal development only
Secret manager (e.g. Vault, cloud secret store) [3][4]Medium — access controlled and audited, key still enters process memoryLow to mediumMost application secrets and signing keys at moderate value
Cloud KMS or HSM-backed signing [4]High — key material never leaves the service, callers request signaturesMediumHigher-value keys where exfiltration must be impossible
Multi-party or offline signingHighest — no single party can sign aloneHighTreasury-scale funds where approval is the point

Whichever tier you choose, the signing interface should be narrow. A service that only signs transactions matching a policy — allowed destinations, amount limits, and required approvals — is much safer than one that signs whatever it is handed. The OWASP guidance on secrets management [2] and cryptographic storage [5] is a solid baseline for the surrounding controls.

Separating intent from authority in practice

The gateway records what your application wants to happen. The signing process decides whether that is allowed. Keeping those apart means a bug in the application cannot, by itself, move value. A policy layer between them is where business rules become enforceable.

Illustrative — a policy check that sits between intent and signatureTypeScript
type Payout = { id: string; to: string; amount: bigint; approvals: string[] };

const policy = {
  maxSingle: 50_000n * 10n ** 6n,           // per-payout ceiling (token minor units)
  requiredApprovals: (amount: bigint) => (amount > 10_000n * 10n ** 6n ? 2 : 1),
  allowedDestinations: new Set<string>(loadVerifiedAddresses()),
};

export function authorise(p: Payout): { ok: true } | { ok: false; reason: string } {
  if (p.amount > policy.maxSingle) return { ok: false, reason: "exceeds single-payment limit" };
  if (!policy.allowedDestinations.has(p.to)) return { ok: false, reason: "destination not verified" };
  const needed = policy.requiredApprovals(p.amount);
  if (new Set(p.approvals).size < needed) return { ok: false, reason: `needs ${needed} distinct approvals` };
  return { ok: true };
}

Separation of duties

No single person should be able to both authorise and execute a payment. The concept is old and well defined [6]; the implementation is a table of who may do what, enforced in code and reviewed on a schedule.

What to log, and what never to

Log thisNever log this
Who requested a signature, from where, and whenPrivate keys, seed material, or raw secrets
The policy decision and the reasonFull authentication tokens
Transaction identifiers and amountsAnything that would let a reader reconstruct a key
Approvals with approver identityUnredacted webhook secrets
Key rotation and revocation eventsPersonal data beyond what the record needs

Audit logs are evidence. Ship them to storage that the signing process cannot modify, and alert on the events that should be rare: a signature outside business hours, a policy override, a new destination.

A key compromise runbook

Plan for the worst case while calm. The first hour of a suspected compromise is not the time to design a procedure.

  1. 01

    Contain

    Disable the signing endpoint or revoke the credential. Stopping further use matters more than understanding how it happened.

  2. 02

    Preserve evidence

    Snapshot logs and note the time. Do not rebuild the environment yet.

  3. 03

    Assess exposure

    What could the key sign, and what has it signed since the suspected time?

  4. 04

    Move remaining funds

    To a newly generated destination controlled under the new procedure, if the policy requires it.

  5. 05

    Rotate everything downstream

    Anything that trusted the old key or that shared its storage.

  6. 06

    Review and record

    A blameless review with actions and dates, and a note for counsel where appropriate.

Rehearse this. A tabletop exercise once or twice a year exposes missing contact details and unclear authority far more cheaply than a real incident.

Closing

The implementation follows the sentence. If you can draw the boundary on a whiteboard and defend it to both counsel and the on-call engineer, you have software. If you cannot, you have a service with a nicer interface.

References & further reading

  1. 1
  2. 2
    Secrets Management Cheat Sheet — OWASP Cheat Sheet Series
  3. 3
    Vault documentation — HashiCorp
  4. 4
  5. 5
    Cryptographic Storage Cheat Sheet — OWASP Cheat Sheet Series
  6. 6
    Separation of duty — NIST Computer Security Resource Center glossary
Found this useful? Share it

Get the next essay in your inbox

Practical writing on payments infrastructure, operations software, and shipping real systems. No spam, no sales sequence.

We only use your email to send the studio's writing. See the privacy policy.

About the authors

Product behaviour described here reflects what is implemented and tested; anything else is marked as planned. Code samples are illustrative.

All writing

Have a system like this to run?

Explore the catalog, or write down the problem and the constraints. We respond when the fit is real.

Free apps from the studio. Enter your email, get a private download link. Free for personal use.

Get them free

Have a product to sell? We review, list, and sell it for you — you keep 90% of every sale.

Apply to sell with us