Security model
This page is written for a technical reader. It explains which structures protect funds in FlowPayra Lite, what each kind of key can and cannot do, and which residual risks are known and accepted.
Non-custodial structure
Section titled “Non-custodial structure”- The system holds no funds. The payer’s wallet transfers tokens directly to the payees, and the split completes atomically within a single transaction. The contracts are not upgradeable, have no owner and no withdrawal function, and hold a zero balance when a transaction ends.
- The hot wallet pays gas only. The hot wallet is used for gas sponsorship and for submitting subscription charge transactions. It holds a small amount of native coin, never handles payment funds, and uses a different private key from the quote signer key.
- Refunds are sent directly from the receiving address. The system only verifies the refund transaction; it does not transfer on anyone’s behalf.
A compromised server therefore does not directly lead to payment funds being taken: there are no funds in the system to withdraw, and the contracts transfer only as the payer authorized.
Merchant contracts: an ownerless factory and immutable clones
Section titled “Merchant contracts: an ownerless factory and immutable clones”The contracts on EVM chains have three layers:
| Layer | Contract | Deployment | Description |
|---|---|---|---|
| Implementations | FlowPayRouterImpl, FlowPaySubscriptionsImpl |
Created by the factory’s constructor, once per chain | The business logic; no owner, not upgradeable, no withdrawal function. Calling a business function on an implementation directly reverts (onlyClone) |
| Factory | FlowPayFactory |
Deployed through the CREATE2 deployment proxy, once per chain | Its constructor creates the two implementations and stores their addresses as immutables. It has only two functions, predict(signer, salt) and deploy(signer, salt) (idempotent); no owner, no configuration |
| Merchant contracts (clones) | Router clone, Subscriptions clone | Once per quote signer key per chain | Minimal proxies with immutable arguments (based on EIP-1167). The quote signer address is written into the clone’s bytecode as an immutable argument |
Properties of the merchant contracts:
- No initializer, no admin, no modifiable parameters. The signer address is part of the clone’s bytecode and cannot be changed by anyone; there is no front-running of an initializer.
- The code cannot change. A clone can only delegate to the implementation bound by the factory. The implementations are not upgradeable, and the factory cannot change the implementation addresses.
- The deployer does not matter. A clone’s address is determined uniquely by the factory address, the implementation address, the signer address and the salt, and the deployer has no rights over the contract.
- Merchants are structurally isolated. A payer’s allowance is granted to one merchant’s clone and cannot be used by another merchant’s clone. A payer can also revoke the allowance for a single merchant’s clone.
- The contract address identifies the merchant. The
verifyingContractof the EIP-712 domain is the merchant’s clone address, so signatures are bound to that merchant and that chain.
Any change to the contracts changes the factory’s init code and therefore yields new factory, implementation and clone addresses; subscriptions on existing clones continue under their original terms. Deployment verification compares the on-chain code hash of each contract with the code the release should produce, and the console does not confirm a deployment when any required contract differs. The procedure is described under Chains and contracts.
Security boundary: funds move only on the payer’s authorization
Section titled “Security boundary: funds move only on the payer’s authorization”Threat model: any merchant system is assumed to be potentially malicious or compromised. It can sign arbitrary quotes, read the mempool, front-run transactions and deploy its own clones.
Core invariant: every transfer the contracts make out of a payer’s address must be backed by that payer’s own authorization of the complete payment terms, either a transaction sent by the payer or the payer’s EIP-712 signature. A merchant signature, a third-party submission or an existing allowance can never on its own be the basis for moving funds.
What the payer authorizes
Section titled “What the payer authorizes”For a one-time payment the payer authorizes a PaymentIntent (EIP-712, with the merchant’s Router clone address and the chainId as the domain) containing:
| Field | Meaning |
|---|---|
orderId |
The order identifier, unique within the merchant’s clone |
payer |
The paying address |
token |
The token (the zero address for the native coin) |
amount |
The total amount |
payTo |
The split array: every receiving address with its amount |
deadline |
The deadline |
- The splits are part of the signed structure as an array, not merely as a hash, so the wallet’s signing screen can show each receiving address and amount.
- The domain contains the
chainIdand the clone address, so a signature cannot be replayed on another chain or another contract. The Router and Subscriptions use different domain names, and every kind of signature has its own type string. - Each order identifier can be paid only once per clone (
paid[orderId]).
For a subscription the payer authorizes SubscriptionTerms, which additionally contain the amount per period, the per-period splits, the interval, the first payment time, the maximum number of payments (which must be greater than 0), whether the first period is charged immediately, the funding source, the deadline for subscribing and a unique salt.
Two kinds of signature
Section titled “Two kinds of signature”| Signature | Signer | Protects | Purpose |
|---|---|---|---|
Payment authorization (PaymentIntent / SubscriptionTerms) |
The payer | The payer | Decides whether funds can leave the payer’s address, to whom, how much and how many times. It is the contracts’ only basis for moving funds |
Merchant signature (quoteSig) |
The quote signer key written into the clone | The merchant | Proves that the amount and the payees were issued by this merchant, so that a payer cannot alter them and nobody else can use the merchant’s order identifiers |
Signature checks first attempt ECDSA recovery; the signature is valid if the recovered address equals the signer. Otherwise, and only when the signer has code, ERC-1271 is checked. EIP-7702 delegated accounts can therefore sign with their own private key, contract wallets use ERC-1271, and the zero address is never valid.
Payment authorization methods
Section titled “Payment authorization methods”| Method | Payer’s authorization | Enforced by the contract |
|---|---|---|
| Native coin | A transaction sent by the payer | msg.sender == payer, msg.value == amount; each split in the transaction parameters is transferred |
| Allowance | A transaction sent by the payer | msg.sender == payer. The contract pulls only from msg.sender, so a leftover allowance can be used only by the payer |
| EIP-3009 | A receiveWithAuthorization signature |
The contract computes nonce = hash(PaymentIntent) on chain and requires it to equal the nonce in the signature; to is the contract itself. The signature is therefore usable only for this order and these payees |
| Permit2 | A permitWitnessTransferFrom signature |
witness = hash(PaymentIntent); the signed structure shows the complete terms in the wallet |
| EIP-2612 permit / DAI permit | The permit signature itself carries no order information | One of two: the payer submits the transaction (msg.sender == payer), or the payer’s EIP-712 signature over the PaymentIntent is attached and someone else may submit it. A permit signature alone is always refused |
Allowances are kept minimal: one-time payments approve the exact amount, and Permit2 and EIP-3009 are signed per payment; only the witness variant of Permit2 is used. A DAI permit can only grant an unlimited allowance, which the checkout states explicitly before signing.
The quote signer key cannot move funds
Section titled “The quote signer key cannot move funds”The quote signer key can only prove that a quote was issued by the merchant. The contracts never treat a merchant signature as a basis for moving funds, so a holder of a leaked key cannot take a payer’s funds or redirect a payment. The effect of a leaked key is limited to its clones:
- signing phishing quotes that look genuine (the payer must still authorize the complete terms);
- occupying order identifiers on the clone;
- canceling subscriptions on the clone with
cancelByMerchant(an interruption of revenue, not a loss of funds).
The response is an emergency rotation; see Key management.
The contracts hold no balance
Section titled “The contracts hold no balance”- The allowance, EIP-2612 and DAI permit paths execute
transferFrom(payer → payee)for each payee, so funds go directly. - The EIP-3009 and Permit2 paths pull the funds into the clone and distribute them within the same transaction, leaving the clone’s balance at zero.
- Native coin is sent to each payee in turn.
- If a transfer to any payee fails, the whole transaction reverts. Direct paths check each payee’s balance delta; paths through the clone check the amount the clone actually received and send all of it on.
- Every state-changing entry point has a re-entrancy lock, and state is written before external calls.
- Split rules are enforced by the contract: 1–10 payees, non-zero and distinct addresses, none equal to the clone itself or to the payer, every amount greater than 0, and a sum equal to the total.
Subscription guarantees
Section titled “Subscription guarantees”The subscriptions contract (FlowPaySubscriptions) charges according to the terms signed by the payer. An allowance is a precondition, never the basis for a charge:
- Creation: only by the payer calling
subscribe, or by someone submitting the payer’s signature over theSubscriptionTerms(subscribeWithSig). - At most once per period:
charge(subId)can be triggered by anyone, but the amount, payees and frequency are fixed by the terms. - No catch-up: a missed period is never charged later.
- Capped: cumulative charges never exceed
amount per period × maximum payments. The maximum must be greater than 0, so there are no open-ended subscriptions. Nothing can be charged before the first payment time. - Immutable terms: after creation, the amount, interval, payees and splits cannot be modified; the contract has no function that changes terms. Plan changes are made by creating a new subscription that the payer authorizes again.
- Cancel at any time: the payer can cancel at any time (
cancel, orcancelWithSigsubmitted by someone else with the payer’s signature) or revoke the allowance (approve(0), Permit2lockdown). The main payee (payTo[0]) can cancel, and the merchant’s quote signer can signcancelByMerchant. Canceling only stops future charges. - Shared allowances stay within each subscription’s terms: several subscriptions of one payer on the same merchant clone and token share one allowance; the contract counts each subscription separately, and none can exceed its own terms.
There are two funding sources: a token allowance for the Subscriptions clone (which an EIP-2612 permit can grant within the subscribe transaction), or a Permit2 allowance.
TRON: the factory variant
Section titled “TRON: the factory variant”TRON uses a dedicated factory, FlowPayFactoryTron, which is the only contract that differs on the TRON track:
- The two implementations and the clone logic are identical to EVM. The factory’s ABI (
deploy,predict, theMerchantDeployedevent) matches the EVM factory, and it likewise has no owner, no upgrade path and no withdrawal; anyone can calldeploy. - Clones are created with CREATE rather than CREATE2 and recorded in a mapping keyed by
(signer, salt), which makesdeployidempotent: for an existing key it returns the recorded pair of addresses. - As a result, clone addresses on TRON are not known before deployment, and
predictreturns the zero address until the clones are deployed.
FlowPayFactoryTron was covered by the second internal review (see Security reviews).
Solana: the flowpay program
Section titled “Solana: the flowpay program”On Solana, one Anchor program reproduces the semantics of the EVM contracts: one-time payments with atomic splits, pre-authorized subscriptions charged one period at a time, and merchant quote signatures that only protect the merchant.
- Payer authorization: the payer signs the transaction whose instruction data carries the full
PaymentIntent/SubscriptionTerms(order identifier, token mint, amount, every payee with its amount, deadline, interval, number of periods and so on). Every transfer out of the payer is backed by a transaction the payer signed. - Merchant quote signature: the quote signer is an Ed25519 key that signs a 32-byte digest of the terms. The Ed25519 program instruction must come immediately before the FlowPay instruction, and the program checks the public key, the signature and the digest by instruction introspection. The three kinds of digest (payment, subscription, cancellation) use distinct domain prefixes. A quote signature can never move funds on its own.
- Merchant account (
Merchant): a PDA derived from the quote signer’s public key and a salt. Every merchant shares the same program and has its own merchant account, which is the only thing a merchant creates. PaidOrderrecord: a PDA derived from the merchant account and the order identifier. Its existence is the “already paid” record; a second payment of the same order identifier fails (AlreadyPaid), whether by token or by SOL.- Delegate-based subscriptions: the payer’s token account delegates to the merchant’s delegate PDA an amount of at least
amount per period × maximum payments.chargeis permissionless, but charges at most once per period, never catches up and never exceeds the cap; before transferring it checks that the delegate is still in place and the delegated amount is sufficient. The payer, the main payee or the merchant’s quote signature can cancel, and canceling only stops future charges. - Payees are paid only into their associated token accounts (ATAs): the receiving account must be the payee’s ATA for the mint, otherwise the instruction is refused (
PayeeTokenAccountInvalid); a missing ATA is created by the program. Every transfer is atransfer_checked, and the destination’s balance delta is verified. - Token-2022: a mint’s extensions are checked against an allow list, at payment, at subscription opening and at every charge. Mints carrying the transfer fee, confidential transfer fee, transfer hook, permanent delegate or non-transferable extensions are refused, and so is any extension the list does not name (including ones added to Token-2022 later).
- Rent recovery: a
PaidOrderrecord can be closed by whoever funded its rent once the paid terms’ deadline has passed (close_paid_order); a subscription account can be closed once it is canceled or completed and its terms’ deadline has passed (close_subscription). Only the rent payer recorded in the account may close it, so a third party cannot remove a record. - No admin: the program has no admin, no configuration account and no withdraw instruction, and it holds no funds after an instruction completes.
One difference from EVM: a Solana quote signature does not include the payer, so any address holding a quote can pay or subscribe with its own funds. Payer funds are unaffected. Screening of the paying address at quote time is therefore not binding on Solana, and risk addresses are screened against the actual payer at booking.
Key management
Section titled “Key management”Quote signer keys
Section titled “Quote signer keys”- Storage: when kept locally, the private key is stored in the database encrypted with the master key; the console neither displays it nor offers it for download, and offline backups are exported from the command line as a password-encrypted JSON keystore (a standard Ethereum keystore for secp256k1; the same container, marked with its scheme, for a Solana ed25519 key), checked offline and restored as the same key. A key can alternatively be kept in AWS KMS or Google Cloud KMS: the private key never leaves the KMS and cannot be exported, and the server holds only access credentials (encrypted with the master key) or an instance role.
- KMS constraints: a signature returned by the KMS must recover to the registered signer address, otherwise it is treated as a failure. When the KMS is unavailable the system does not fall back to another key; quotes answer
503 signer_unavailableand an alert is raised. - Key ring and rotation: a key moves through the states pending, active (only one at a time), retiring and retired. Because the signer address is part of the clone bytecode, replacing the key means deploying a new set of clones for the new signer address on every chain. Quotes of the replaced key are still booked while valid, and subscriptions on its clones continue to be charged under their original terms.
- Emergency rotation: once the new key is active, the old key’s valid quotes and unsent subscription terms are voided immediately. The Router of a compromised or retired key books only payments that exactly match a quote issued by this system; anything else raises the
unquoted_paymentalert and is not booked. Subscriptions on the old clones are migrated by the payers through a payment method change (subscription.migration_requested). - Rotation requires the admin role and step-up verification for each action, is recorded in the audit log, and notifies the other admins.
Master key
Section titled “Master key”- The master key (32 bytes) encrypts sensitive database content with AES-256-GCM: RPC URLs, webhook secrets, TOTP seeds, payer and admin email addresses, mail provider and SMTP credentials, the bounce notification URL’s secret, third-party risk provider credentials, alert channel configuration, KMS connection credentials, locally stored quote signer private keys and others.
- The master key exists only in configuration (the configuration file or an environment variable) and is never written to the database. A master key leaked on its own decrypts nothing.
- Rotation: the new key is generated in the browser and shown once. After the admin writes it to the configuration, keeps the previous key as a decryption-only key and restarts, re-encryption is started from the console. This requires the admin role and step-up verification for each action, and approval by a second admin when dual approval is on.
- If the master key and the database leak together, rotate the master key and re-encrypt, treat the quote signer key as compromised, and replace the webhook secrets and the RPC, mail provider and SMTP (then connect bounce notifications again) and risk provider credentials.
API keys and webhook secrets
Section titled “API keys and webhook secrets”- An API key is shown in plaintext once and stored only as a hash. A leaked key can at most create orders or subscriptions and read data within its scopes and mode. By default the business API can only reference registered payees and cannot introduce new receiving addresses. A test key cannot create live orders.
- Webhooks and return URLs are signed with HMAC-SHA256, with separate secrets for live and test mode; see Webhooks.
Console security
Section titled “Console security”| Measure | Description |
|---|---|
| Passkeys and security keys | Based on WebAuthn with user verification required, bound to the site’s domain and resistant to phishing. An account with a registered key can sign in without a password |
| Authenticator app (TOTP) | Available only while the account has no passkey or security key registered; it is disabled automatically once a key is registered |
| Recovery codes | 10 single-use codes stored as argon2 hashes; a session started with a recovery code can only open the account security page to register a factor again |
| Sign-in protection | A security factor must be registered at first sign-in; 5 consecutive failed verifications during or after sign-in lock the account for 15 minutes (passkeys and security keys still sign in); wrong passwords at the sign-in page never lock the account and are limited per account name and IP; sessions expire after 12 hours and after 30 minutes of inactivity; passwords have at least 12 characters |
| Step-up verification | Each sensitive action is issued a grant with a scope, a digest of the action and a 5-minute lifetime. With a key, the signature itself covers the action and can be used only once. Changing payee addresses, split rules, API keys, security settings, quote signer keys and the master key requires verification every time; for general configuration one verification within 5 minutes is sufficient |
| Payee address protection | Payee addresses can only be configured in the console; besides step-up verification, a change requires entering the last 4 characters of the new address |
| Dual approval | When enabled, changing a payee address, replacing the main payee, turning the split whitelist off, withdrawing from the hot wallet, and adding a member, resetting a member’s factors, re-enabling a member or changing a role take effect only after a second admin approves with a key. Requests expire after 24 hours, and turning dual approval off itself requires a second admin’s approval. Quote signer key rotation does not go through dual approval |
| Audit log | Every sensitive action is written to the audit log with the values before and after the change; key actions are also emailed to the other admins |
| Roles | admin (all permissions), operator (operational actions), finance (read-only and exports, with email addresses masked); permissions are enforced on the server as well |
The procedures are described under Admins and passkeys.
Further protections:
- Amounts, splits and deadlines are signed by the back end and checked by the contracts. The static assets of the checkout and the console are embedded in the program and served with a CSP.
- Gas sponsorship submits transactions only for currently valid quotes, simulates them and screens the paying address first, and is bounded by submission limits, a daily budget and a gas price cap.
- Payments are booked after the required confirmations; on a chain reorganization, bookings are rolled back by block hash and a notification is sent.
- Token listing probes for and refuses fee-on-transfer and rebasing tokens; a token is used through EIP-3009 only if it passes the caller check (
receiveWithAuthorizationaccepts calls from the receiving address only); an upgradeable token whose implementation changes is paused pending review.
Residual risks
Section titled “Residual risks”The following limitations are known and accepted, and are stated as they are:
- Interface spoofing. A malicious or compromised merchant system can present a forged checkout and induce a payer to sign unfavourable terms. The contracts cannot prevent this. The mitigation is that the signed structures use readable field names and list every receiving address and amount for the wallet to display. Payers should check what the wallet’s signing screen shows.
- Quote signer key compromise. Payer funds are not at risk, but phishing quotes can be signed, order identifiers occupied, and every subscription on the affected clones canceled; this requires an emergency rotation and migration of the subscriptions by the payers.
- Pausing a subscription is off-chain only. The keeper does not charge while a subscription is paused, but the on-chain subscription remains valid and anyone can still call
charge; such charges are booked as usual. - The window between canceling in the system and on chain.
chargeis open to anyone, so a period may be charged before the on-chain cancel lands. The system books the charge and raises an alert, and the merchant refunds it. - Charge timing. “At most once per period” is a rule on the period grid, not a minimum interval: if a period is charged only at its end, the next period can be charged as soon as it starts, so two charges may be close together.
- A signed payment authorization cannot be revoked on the Router before its deadline. It can only be revoked at the token level (for example by canceling the EIP-3009 authorization, invalidating the Permit2 nonce, or
approve(0)). Quotes are valid for 10 minutes. - DAI permits are unlimited. This is a property of DAI’s permit; the checkout states it before signing.
- Token behaviour. Paths through the clone check only the amount the clone received, so a token that charges a fee only on outgoing transfers leaves payees short. Balance-delta checks constrain what payees receive, so a token that takes extra from the sender makes the payer pay more. A non-compliant EIP-3009 token could leave funds locked in a clone. These cases are excluded by token listing requirements and probes, not by the contracts.
- Receiving addresses the contracts cannot recognize. A payee that is the same merchant’s other clone, an implementation contract, Permit2 or a token contract is not rejected by the contracts; the back end refuses such addresses when payees are registered.
- Funds sent to a clone by mistake cannot be recovered. Clones have no withdrawal function; this is the cost of having no admin.
subscribeWithSigcan be front-run with its funding data stripped. Funds are not at risk; when the back end detects that a landed subscription lacks its allowance, it follows up with the authorization.- After a Solana record is closed. Once a
PaidOrderrecord is closed, another quote of the same order identifier with a later deadline could be paid again (with the payer’s own funds and signature). The back end accounts for payments by their on-chain events and treats this as a duplicate payment. - Duplicate payments across chains. A single valid quote, in-flight locking and short validity reduce the likelihood; when it happens, the order is marked
duplicate_paidand a refund is opened. - Parts that depend on the operator. Risk address screening depends on the quality of the lists and third-party data. Protecting the server, the master key and the admin accounts is the responsibility of the party running the deployment.