TL;DR: In TEE Income Oracle my gateway touches every message and still can’t read the statement or change the tier, because each hop is signed, encrypted or bound to a one-time value. What a carrier can still do is stop the bytes, so availability isn’t protected. The enclave doesn’t trust its own clock either. On Solana the last hop works because the pool derives the attestation address from the wallet that signed the borrow, so a borrower can only ever reach their own tier. If you came for the Solana part, jump to the PDA section.
This is part 2 of 3 on how TEE Income Oracle works.
- A bank statement goes in, a risk tier comes out: the trust model of an income oracle on Solana
- My own server carries every byte and still can’t read or forge one: from borrower to Solana pool in six hops
- The crypto held, the restarts didn’t: what breaks first in an enclave oracle
Part 1 set up the trust model: an enclave scores a bank statement, and everything outside it, including my own gateway, is treated as hostile. This post walks one session through to show what that means in practice, from the borrower’s first click to the Solana pool that lends against the result. The scope is the same: Solana devnet and a sandbox bank I wrote.
If you want the other end of this, the browser page that refuses to show a tier until Solana agrees, read The browser doesn’t trust the server. It is the same idea from the frontend side.
One session, end to end
Here is the happy path, trimmed to the steps that matter. The full sequence is in the repo’s architecture doc.
- The borrower starts a session with the gateway, giving a wallet and a test borrower profile (a persona).
- The gateway asks the sandbox bank for consent, and gets back a consent signed by the AA.
- The gateway asks the enclave to create a session, passing the policy, the wallet and the consent.
- The enclave returns a signed data request. The new session key was created inside it.
- The borrower signs the session intent with their wallet.
- The gateway carries the signed request to the bank, unchanged.
- The bank returns an encrypted statement with signatures.
- The gateway hands the raw bytes to the enclave. The enclave verifies, decrypts, scores and wipes.
- The enclave returns an 83-byte payload and a signature.
- The gateway submits it to Solana, where a secp256k1 check runs and a SAS attestation is created.
- The borrower borrows against the attestation.
Notice who does what. The gateway (my server) is in the middle of nearly every step. The enclave is in steps 3, 4, 8 and 9. The gateway never holds a key that matters.
What the gateway can and can’t do
The gateway touches every message and can still do very little. This table shows what it sees at each hop and what it can’t do:
| Hop | The gateway/host sees | It can | It cannot |
|---|---|---|---|
| Session create | Public key material and the signed request | Read public keys | Change the key (the signature covers it) or swap the enclave’s request key (the bank checks a binding signature) |
| Bind wallet | The intent and the wallet signature | Drop it | Bind a wallet it doesn’t control |
| Fetch | Ciphertext and signed envelopes | Store it | Decrypt it or alter it (the AES-GCM tag and signatures break) |
| Evaluate | Raw bytes in, signed payload out | Replay old bytes | Get them accepted (one-time session nonce) |
| Submit | The Solana transaction | Censor it | Change the tier (the signature breaks) |
| Borrow | Nothing relevant | Nothing | Use another wallet’s attestation, a stale one, or one from a build the pool hasn’t approved |
Read the “cannot” column as a list of the reasons each hop holds:
- Session create holds because the enclave signs the request that carries its keys. If the gateway changed a key, the signature would no longer match.
- Bind wallet holds because the borrower signs the intent with their own wallet. The gateway has no way to produce that signature.
- Fetch holds because the statement is encrypted to a key that only exists inside the enclave, and signatures cover what’s sent. A changed byte breaks the AES-GCM tag. The bank’s signature on the statement data is my sandbox’s extension: in real AA, no bank signature reaches the lender (part 1 explains).
- Evaluate holds because each session has a one-time nonce. Replaying old bytes gets nothing accepted.
- Submit holds because the signature covers the tier. A relayer that edits it invalidates it.
- Borrow holds because of how the pool finds the tier, which is the last section of this post.
One more rule sits under all of this: verify before parse. The enclave checks signatures with pinned keys before it parses anything, so hostile bytes never reach the parser. The keys are compiled into the image. That is the cost: rotating one means shipping a new build. I accept it, because it is the point of the second move in part 1: a key compiled into the measured image can’t be swapped by the host.
Why plain HTTP is fine
The enclave talks plain HTTP to the gateway. That sounds wrong, and it’s fine for a specific reason: every byte that matters is signed or encrypted end to end. The enclave produces signed requests and consumes signed responses. Whoever carries them can’t change them.
That covers integrity. It does not cover availability. The enclave’s port is public, so anyone who can get consents can fill its 256 open-session slots and lock other borrowers out. The gateway rate-limits session creation, and I accept this as a liveness risk. The host and gateway can already deny service anyway, so availability was never something this design could promise. The last column of the table says “censor it” for a reason.
The enclave’s clock is not trusted
There is one more thing a carrier controls: time. The host runs the enclave’s clock, so the enclave can’t be asked what day it is.
So the scoring window doesn’t come from the clock. It comes from the statement’s own dates, which must sit inside the range the enclave requested and inside the signed consent. Freshness is checked on chain, against the Solana clock. The check allows five minutes of skew, and a signature is usable for ten minutes after it is issued.
The cost is that the limits are fixed. A submission that arrives after the ten-minute window is rejected.
The Borrow hop on Solana: a PDA is the permission check
The last two hops are the ones on Solana: the gateway submits the enclave’s signed result, and the borrower borrows against it. This section assumes you know what a PDA is (a Program Derived Address, an address derived from seeds that only the deriving program can sign for) and roughly how an Anchor program is laid out.
What lives on chain
Four things on Solana carry the weight.
- The registry maps an image id to the attester key and its status. Ids are append-only and never reused, even after a revoke, so revoking one permanently invalidates its attestations. The id space is 255 for the life of a deployment.
- The attestation address is derived from the borrower’s wallet. The pool derives it from the wallet that signs the borrow, so it can’t be handed another wallet’s tier.
- The signed message is domain-separated, so a signature can’t be replayed in another context.
- Refreshes need a strictly newer
issued_atper wallet, so an old signature can’t replace a newer tier.
Nothing personal goes on chain. The attestation carries a tier, ids, hashes and timestamps, in an 83-byte payload.
The address is the permission check
Most access control in a program is a check you write: require!(caller == owner). Here the check is the address itself.
The tier is stored as a Solana Attestation Service (SAS) attestation, a standard credential any program can read. Its address is a PDA derived from the seeds attestation, the credential, the schema and a nonce, and the nonce is the borrower’s wallet. In the pool’s borrow instruction the borrower account must sign, and the attestation account’s seeds use that key. The credential and schema come from the pool’s own config. The pool doesn’t accept an attestation account the caller points at. It derives the address from the signer and reads that account.
So the borrower can only reach their own tier. To use someone else’s income, they would have to sign as that wallet. No comparison in my code can be forgotten, because there is nothing to compare: the wrong tier has no address the pool will ever derive. The payer can be a different account, such as a relayer, but only the borrower’s own key decides which attestation is read.
The pool still checks what it reads. The address pins the credential and schema. The pool requires the stored signer to be the oracle’s own derived address, so a foreign credential can’t pass. It also checks freshness, that the enclave build is approved and still active, and the policy hash. That is the G6 link from part 1.
The oracle’s signer is a PDA too
The SAS credential has an authorized signer. In TIO that signer is a PDA of the oracle program, derived from the seed sas_signer. It has no private key.
That matters for two reasons. It can’t be stolen, because there is nothing to steal. And only the oracle program’s logic can sign with it, which means a tier can be written only after the program has checked the enclave’s signature against the registry. The enclave never writes to chain itself. It signs a payload, and the program decides whether to turn that into an attestation.
A signature that can’t be replayed
What the enclave signs is domain-separated. The signed bytes cover a tag, the program, the credential, the schema, the wallet, the payload and an expiry. Each part closes a replay:
- The tag, program, credential and schema stop a signature from one deployment or one schema being accepted by another.
- The wallet stops one borrower’s signature being used for another.
- The expiry stops an old signature from living forever.
Replacing a tier follows one more rule: a refresh must carry a strictly newer issued_at for that wallet. Without it, someone could resubmit an older, better signature over a newer, worse tier. A refresh closes the old attestation and creates a new one, and submit_attestation does both itself. The relayer gets the old rent back and pays the new rent, so a refresh costs about nothing. The SAS attestation expires 30 days after issued_at, and the pool adds its own limits on attestation age, statement age and statement length.
Why SAS and not a custom program
Pro. A tier written as a standard credential is readable by any pool that reads SAS, not just mine.
Con. I depend on someone else’s program. The rent for an attestation (about 0.002 SOL) stays locked until the same wallet refreshes, because I haven’t built a close path for expired attestations.
Why secp256k1, and what it costs
The enclave signs with a secp256k1 key because Oyster gives each enclave one at boot. So the oracle uses Solana’s secp256k1 precompile rather than the native ed25519 one.
Pro. Solana verifies the signature in a built-in instruction, and the key type is platform-neutral, so changing the TEE never changes the on-chain check.
Con. Every transaction carries an extra instruction and the bytes that go with it.
There is also a classic bug class here. The program never verifies the signature itself. The precompile does, one instruction earlier, and the program reads back what the precompile was given. The instruction-index fields in the precompile instruction must point at the precompile itself, or an attacker can make the check pass against other data. I test that case explicitly. If you copy this pattern, test it too. The five checks, and the attack each one stops, are in Don’t pass the signed bytes twice.
How the attested key is tied to this exact code (G3 and G4) is covered in Seven checks: verifying an AWS Nitro attestation in the browser.
What this doesn’t cover
The registry is still the weak link, G5 from part 1. An admin registers the enclave key, and in the demo that same wallet is also the program upgrade authority. The PDA design protects borrowers from each other. It doesn’t protect anyone from a stolen admin key. That, and what I’d change, is in part 3.
Where to look yourself
docs/ARCHITECTURE.md: the full sequence, the on-chain layout and the threat table, hop by hopdocs/FORMATS.md: the 83-byte payload and the signed message, byte by byte- The verify page runs the verifier in your browser and reads Solana directly. As of 23 November 2026 it is up, on a paid enclave that runs to about 8 December. After that the hosted pages may go offline. The repo, the docs and the verifier stay.
Previous: part 1, the trust model. Next: part 3 looks at what breaks first.