The signing policy proxy: decide, sign, record, and fail safely on a latency budget

Parse the exact bytes, deny by default per key, write the record before the signature leaves, and decide in advance how each key fails. Keep it cheap by doing no network, no locks and no allocation on the path.

Read the briefing
About 3 min to read 7 drills

What to remember

  1. Sign the bytes you checked. If the policy parses one form and the signer signs another, a difference between them is a bypass. Never re-serialise.
  2. No record, no signature, for keys that move money. That's what 'auditable' has to mean. The local append is cheap; the shipping happens off the hot path.
  3. Fail per key, decided in advance. A money key fails closed. A vote key's failure mode is different. An argument during an outage is too late.
  4. Whoever can change the policy can move the money. So policy changes need the same care as signing: two people, versioned, shadowed, one-step rollback.
  5. Refuse what doesn't expire. A durable-nonce transaction stays valid until the nonce moves, so a signature can sit in reserve. Allow it only by name.

The big picture

A policy proxy decides what may be signed, under which conditions, and leaves a record, without adding latency anyone notices. It's the core of a platform role on a trading system, and a good design question because every choice trades safety against latency and liveness. What's being scored is how you handle those trades.

The mental model

A bouncer who reads the exact page you want stamped, checks it against rules written for that stamp, writes it in the book, and only then stamps. If the book is full, or the rules are unreadable, the door doesn't open.

Diagrams

The path
caller (a service identity)
  | unix socket or shared-memory ring
  v
who is asking? which key roles may they use?
  v
parse the exact bytes -> programs, accounts,
                         amounts, tip, nonce
  v
rules, deny by default, per key
  v
append decision + hash + policy version
  | before the signature leaves
  v
sign -> reply

off the path: ship the ring to write-once storage

In depth

Ask first

Which keys? A validator's vote key, a trading hot key and a treasury key have nothing in common. What's the latency budget, and who agreed it? Are callers on the same host? What's the most you'd accept losing per key per hour? If this proxy dies, which is worse: missed slots, or lost money?

What the rules look like on Solana

A transaction is a list of signatures and a message: header, account keys, recent blockhash, instructions. So rules can check, from the bytes alone: the fee payer and required signers; that each invoked program is on the allow-list; each instruction against a decoder for that program; value out per transaction and per window; compute-budget price and tip ceilings; and that the blockhash field isn't a durable nonce unless this key is allowed one.

Versioned messages can load accounts from lookup tables, so the bytes alone don't show every account. Resolve them from a local, verified copy, or refuse. Simulation is too slow for the hot path, so known transaction shapes do that job, and simulation stays on the slow path.

Why it can be fast

No network, no allocation, no locks. Rules compile to a table at load. Counters live on one core with a single writer. The hop is a unix socket or a shared-memory ring between pinned cores. The audit write is an append to a pre-allocated ring, chained by hash. Ed25519 signing itself is cheap on a modern core, so most latency risk is in your hops and your jitter, not in the check. Agree the budget first, measure at p99.9, and fail CI when it's exceeded.

Failure, decided in advance
What breaks Money keys Vote and identity keys
Proxy down No signature Stop; explicit failover with a single lock, never two copies
Audit ring full Stop signing, page Decided in advance: usually keep voting, count the gap, page
Bad policy file Keep the last good one, alert Same
Unknown instruction Deny; break-glass with a second approver and a time limit Deny
Bad clock Limit by slots and counters, not wall time Same
Proving it works

Golden transactions for every allowed shape. Property tests and fuzzing on the parser. A differential test against the validator client's own parser, because that's the one that decides what actually executes. Replay last week's traffic in shadow before enforcing. Roll out as shadow, then one small key, then the rest. Drills: a full ring, a bad policy, a failover.

Myths and facts

Myth: A policy engine that re-parses and re-serialises the transaction is cleaner.

Fact: It opens a gap between what was checked and what's signed. Check and sign the same bytes.

Myth: Fail closed is always the right answer.

Fact: For money, usually. For a validator's vote, stopping costs rewards and a careless failover risks double-voting. It's decided per key.

Myth: The audit log can be asynchronous for everything, since it's only logging.

Fact: If a signature can leave without a record, you can't claim an audit trail. Make the local append synchronous and cheap, and the shipping asynchronous.

Myth: Policy can live in a config file anyone on the team can edit.

Fact: That file controls the money. It needs review, signatures, versions and rollback.

How pros do it

  • Deny by default, per key, with rules written for that key's purpose.
  • Put the policy version and message hash in every record, so 'why was this allowed on Tuesday?' has an answer.
  • Limit by slots and counters rather than wall-clock time where you can.
  • Keep value caps and key separation, so a policy bug has a bounded worst case.
  • Ship records within seconds to storage the host can't rewrite, and verify the chain has no gaps.

Questions people ask

Where should it run: in-process, a sidecar or an enclave?

Say what each buys. In-process is fastest but shares fate with the caller, so RCE reaches the key. A separate process on pinned cores with its own user is the usual middle. An enclave or HSM keeps root out, at the cost of a hop and, on bare metal, of what's available. Choose per key, then say the cost of your choice.

What if the trading team says the check costs too much?

Measure it together first; the cost is usually a copy or a syscall somewhere else. Then offer something specific: a narrower rule, a capped key with a time limit and a named owner. Never leave a silent bypass in place.

Should it simulate transactions?

Not on the hot path: it needs state and takes too long. Use known shapes and decoders there, and simulation on the slow path for new shapes or treasury actions.

Further reading

Drills · 7

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Design round

Design a proxy in front of a signing key: it decides what may be signed under which conditions, fails safely, produces an auditable record, and the trading systems shouldn't notice the latency.

  • Callers are services on the same bare-metal host
  • Solana transactions, signed with ed25519
  • The key moves real money
In short

Parse the exact bytes, check deny-by-default rules for that key, append a record, then sign; decide failure modes per key and keep the path free of network, locks and allocation.

A strong answer covers
  • Asks which key, the latency budget, and what the worst acceptable loss is
  • Parses the exact bytes and signs those same bytes
  • Deny by default, per key: programs, instructions, value per window, tip and fee ceilings, durable nonces
  • The record is appended before the signature leaves, with the policy version
  • Failure modes are stated per key, in advance
  • No network, locks or allocation on the path, and a measured budget
  • Policy changes are reviewed, signed, shadowed and reversible
What a strong answer does
  • Correctness of the path: Same bytes, deny by default per key, record before signature, policy version in each record.
  • Failure and trade-offs: Failure decided per key, and names what each choice costs.
  • Latency reasoning: Agrees a budget, removes network, locks and allocation, and measures at the tail.
  • communication: Clarifies, states the plan, draws it, walks what breaks.
Why

Interviewers score the trade-offs: where it runs and what that costs, what happens when each part fails, and how you'd prove it's correct. The worked answer is in this topic's primer. Practise drawing it in five minutes, then talk through what breaks.

The common mistake

Designing a generic policy service with a database and an HTTP API. That can't meet the budget, and it shows you didn't start from the constraint.

2 Pick the strongest answer

Your proxy decodes the message into a struct, checks the rules, then re-encodes the struct and sends those bytes to the signer. In review, what's the problem?

  1. Re-encoding is too slow for a hot path; otherwise it's fine. It's also slower, but the correctness problem is the serious one.
  2. The struct needs to be zeroized after use. A transaction isn't a secret. It's about integrity between check and sign.
  3. Nothing, as long as the encoder has tests. Tests don't cover inputs an attacker crafts to exploit a difference you haven't imagined.
  4. A difference between how you decode and how the network decodes, or a re-encoding difference, means the signed bytes may not be what you checked. It's a parser differential: the classic bypass of any check that isn't on the final bytes.
In short

What you checked and what you signed can differ, so a parser difference becomes a bypass: sign the original bytes.

Why

Check and sign the same bytes. Reject anything your parser doesn't fully consume, and reject unknown versions. Fuzz the parser, and differential-test it against the validator client's parser, since that's what decides what executes.

The common mistake

Treating this as a performance question.

3 Scenario: what do you do next?

A busy market. Your policy proxy's local audit ring is 95% full, because shipping off the host has stalled. It's a hot trading key.

Step 1. The ring will be full in about a minute. What's your first move?

  1. Delete old records to make room. Those are your evidence, and they haven't reached storage yet.
  2. Page, and find why shipping stalled, while the proxy keeps following its written rule for a full ring. The rule was decided in advance, so nobody has to argue during the incident. The human job is the cause.
  3. Disable the audit write so trading isn't interrupted. That's a silent bypass of the control exactly when an attacker would want one.

Step 2. The ring fills. The desk is shouting. What happens to signing on this key?

  1. It stops until records can be written. Tell the desk why, and give them an estimate. No record, no signature is what makes the trail mean anything. Losing some trades is the bounded cost you accepted.
  2. Sign anyway and write the records to memory, to catch up later. A record that can vanish on a crash isn't a record, and you've changed the rule under pressure.

Step 3. Service is back. What do you change?

  1. Make the ring much bigger and move on. It delays the same failure, and nobody would notice until it happened again.
  2. Alert on shipping lag well before the ring can fill, size the ring from real rates, and rehearse this failure. It removes the class of problem instead of adding a reminder to a runbook.
In short

Decide by the rule you set in advance: for a money key, no record means no signature, so stop signing and page rather than sign without a record.

Why

The interview signal is holding a pre-decided line under pressure, while working the cause. A different answer is fine for a vote key, since the failure cost differs, as long as it was decided in advance.

4 Pick the strongest answer

Which rule would you least want to leave out of a hot trading key's policy, from the list below?

  1. Refuse transactions using a durable nonce unless this key is explicitly allowed them. A signed durable-nonce transaction stays valid until the nonce advances, so a signature can be held in reserve and used later.
  2. Require a human approval on each signature. Not possible on a hot path. It belongs on the warm and cold tiers.
  3. Only sign transactions below 1232 bytes. The network enforces the size limit anyway. It adds no safety.
  4. Only sign during business hours. Crypto trades around the clock, and a clock is a weak control for a hot key.
In short

Refuse durable-nonce transactions unless named, because a signature that never expires can be held and used later.

Why

Ordinary transactions expire with their blockhash in about a minute, so a stolen signature has a short life. Durable nonces remove that limit. They have good uses, but on a hot key they should be off unless named. Reported analyses of the Drift incident describe pre-signed durable-nonce transactions used later.

The common mistake

Reaching for a wall-clock rule because it's easy to explain.

5 Answer out loud

Who can change the policy on your proxy, and how does a change reach production?

In short

Two people, signed and versioned, replayed in shadow against recent traffic, with a one-step rollback and an alert on every change.

What a strong answer does
  • Treats the policy as a key: Two signatures verified on the host before load, versioned, change alerts.
  • Safe rollout: Shadow replay against recent traffic, gradual enforcement and one-step rollback.
  • Emergency path: Time-limited, second approver, alerts on use, reviewed afterwards.
Why

Whoever can change the policy can move the money, so it's a signing path too. The strong answer treats it that way, and also says how an emergency change works without becoming the normal route.

The common mistake

Saying 'it's in Git with code review' and stopping. Who can merge? What verifies the file on the host?

6 Read the output

The interviewer points at this and asks whether you'd call the result auditable. What's wrong with it?

fn sign(req: &Req) -> Result<Sig, Deny> {
    let d = policy.check(&req.bytes)?;
    let sig = key.sign(&req.bytes);
    audit_tx.try_send(Record::new(&d, &req.bytes)).ok();
    Ok(sig)
}
  1. Nothing: the log is best-effort by design, and that's acceptable for audit. A best-effort audit trail can't answer 'was this the only one?'
  2. Records should be written by the policy check, not here. Where it's called from matters less than that nothing leaves without it.
  3. try_send can block the hot path. try_send doesn't block. That's the problem: it fails and the failure is ignored.
  4. The record is written after signing, and try_send(...).ok() silently drops it when the channel is full, so a signature can leave with no record. Order and error handling both break the guarantee.
In short

It signs first and silently ignores a failed write, so a signature can leave with no record.

Why

Append first, and treat a failed append as a decision: deny for a money key. .ok() on a fallible write is the line to spot in code review. It also has no chain or sequence number, so a gap wouldn't even be visible later.

The common mistake

Focusing on performance instead of the guarantee.

7 Quick recall

Two parsers disagreeing about the same bytes is called a parser what?

In short

A parser differential: two parsers read the same bytes differently, which can bypass a check.

Accepted

differential · parser differential · difference

Why

Parser differentials have caused real bypasses across protocols. Sign the bytes you checked, and test your parser against the one that finally executes the message.

Next lesson Threat-modelling a signing path: assets, actors, boundaries and what's left over
Drill · The signing policy proxy
0:00

Loading…