DSS

DSS 2026 / Day 1 / Amber Hall

Formal Verification of Stake Pools: From General Design to a Real-World Application

Kevin Lotz

14:28 · Recording

Watch on YouTube ↗Open recording viewerOriginal programme entry
Download plain textDownload timestamped JSON

Source: YouTube automatic caption track · Exported 2026-11-16. Timestamps link to the source video. Cue end times were not supplied.

Transcript

0:00Okay.

0:01Uh thanks for the introduction. Hi

0:03everyone. My name is Kevin.

0:05I work as a formal verification

0:06researcher for Cetora and yeah,

0:09as was introduced,

0:10I want to talk in the next 15 minutes

0:12about

0:13formal verification of stake pools.

0:15I'm keeping it fairly abstract, so I'm

0:17starting with general design of what

0:19stake pools are, so mental model of the

0:22moving parts and of the one of the

0:25arguably most important invariants that

0:27stake pools should guarantee you.

0:30From there on, I'm going to go to a

0:32concrete implementation that we formally

0:33verified at Cetora and the outcome of

0:36this formal verification was that we

0:38found

0:39security bug, a high severity one that

0:41was lingering around for a couple of

0:42years and survived multiple audits.

0:46Okay.

0:47Let me Well,

0:49okay, there we go.

0:51Yeah, so first a quick primer on what's

0:53what I mean by stake pools. I think the

0:55concept is pretty simple.

0:57So you have some assets and you want to

0:58stake them, but you don't want to go to

1:00a single validator directly, so you can

1:03go to a stake pool and it much like

1:05behaves like a

1:07like a standard vault. So users deposit

1:10their assets into the stake pool, they

1:11lend in their reserve and the stake pool

1:14means back shares proportional to

1:16whatever you deposited into it.

1:19But then on top of that, there's some

1:20kind of operator that moves the funds

1:23out of the pool to one or multiple

1:26validators where they can experience

1:28slashing, but hopefully they only earn

1:31rewards. So at the later point in time,

1:33users can redeem their shares and get

1:35back hopefully more than what they put

1:37into the pool in the first place.

1:40So that's

1:41that's the general idea of stake pools.

1:44And whenever we see something that

1:46resembles vaults in any shape, what we

1:49tend to prove is or what we

1:51try to verify is an invariant called

1:53solvency.

1:55So what this means basically is that the

1:57shares that are issued at the moment

1:58these are always less than or to the

2:00extractable value and then the case of

2:02stake that is

2:04whatever is in cash in the reserve plus

2:06the current value at the validators that

2:08are staked so including the rewards.

2:11We ignore

2:12slashing because that's the only

2:14exception that can break solvency so for

2:16for that invariant we simply ignore it.

2:19And so what this says is if everybody

2:21was to redeem their shares at once now

2:24at the same time then there would be

2:25enough value in the pool to honor every

2:28share.

2:29We tend to prove this because it

2:32it covers many classes of bugs at once.

2:34For example if you mint too many shares

2:36on on the deposit due to a rounding

2:39issue or some kind of fee setup that is

2:41that is not correct then you will

2:43probably find this

2:45violation to solvency. Same for paying

2:47payouts or for a state that can where

2:50the internal accounting can drift from

2:51the on-chain state.

2:54So we have this solvency the invariant

2:57and invariant here means that we want to

2:58make sure that the pool

3:01satisfies this at every reachable state.

3:04So the principle or the technique that

3:07you can use to verify this is called

3:09induction and

3:11this thing doesn't work. Oh, there we

3:12go.

3:14So what you do is

3:17okay you prove first that the solvency

3:20invariant holds whenever you create a

3:22new pool. So when a freshly created pool

3:25solvency needs needs to hold and then

3:27what you prove in the next step is for

3:28every

3:29state mutating function or operation or

3:32outside event you take a solvent pool.

3:34So you take any pool that is in a

3:35solvent state. You execute that function

3:38and you assert or you verify that the

3:40the pool is still in a solvent state

3:41afterwards.

3:42If you can do this for any operation and

3:44any outside state change so for example

3:47airdrops

3:49then you can be guaranteed that the pool

3:50is

3:51solvent in every state.

3:54And you can use your favorite formal

3:55verification framework of your liking to

3:58prove this. For example you can use the

4:00approach with NES that was described in

4:02the talk before that.

4:04You can also use fuzzing if you don't

4:06want full guarantees.

4:07In the example that I'm going to show

4:08next, what we use is the

4:11and in a nutshell, you give it the

4:13invariant and the code and it comes out

4:15with the logical formula that can either

4:17be proven, making sure or guaranteeing

4:19the property holds

4:20or it gives you a counter example

4:22telling you where solvency can be

4:24violated.

4:26Okay, so we proved this particular

4:28invariant for the Solana stake pool

4:30program. That's the standard stake pool

4:33program on Solana.

4:35It's running since 2021.

4:38Two weeks ago, there were about 64

4:40active pools.

4:42They together had 33.1 million SOL

4:45locked and

4:47there was roughly 3.4 billion

4:50USD, so quite a lot.

4:52And it was audited a couple of times

4:54since it was deployed and last year we

4:56also formally verified it.

5:00So first, how does the Solana stake pool

5:02program work? Okay.

5:06Okay, there we go.

5:07So it's more or less the same thing as

5:09the general model. We have users that

5:11deposit SOL into the stake pool.

5:14So this was supposed to be an animation.

5:16Now I see the whole thing now.

5:19And the pool mints back what's called

5:21pool tokens, which is nothing different

5:23than the shares we saw on the general

5:24model.

5:25Then an operator, the staker comes into

5:28play that takes

5:29that takes tokens out of the SOL out of

5:31the reserve, puts them to the

5:33validators. They land first in the

5:34transient stake. There's kind of a

5:35buffer because on Solana, stake can only

5:38enter validators upon epoch boundary. So

5:41after an epoch ends, the stake is moved

5:43to the validator's active stake where it

5:45gains rewards.

5:46If the users want to redeem their

5:48shares, they go back to the pool.

5:52They'll redeem their shares, they get

5:53burned

5:54and the stake pool

5:57moves SOL back to the user

6:00for whatever these shares are worth at

6:02the moment.

6:04What you have to care about is if the

6:05reserve has less than some kind of set

6:07minimum value. Um this is

6:10kind of value that is never supposed to

6:11be um um like uh it's always supposed to

6:14be withheld in the reserve.

6:16So if you if there are not enough funds

6:19to fulfill a redemption,

6:20uh then either you have to wait until

6:22other users top up with the reserve or

6:24the staker comes in and unstakes

6:25something so the pool has enough funds

6:27available at the next epoch.

6:30So we tried to prove uh solvency on that

6:33particular protocol.

6:36And in that case it's simply like

6:39restated that the pool tokens

6:41are less than or equal to the

6:42extractable value. So the pool tokens

6:44are the shares and the extractable value

6:46in that case is the whatever is in the

6:48reserve minus this minimal balance that

6:51I said cannot be touched.

6:53Uh plus whatever is staked in the

6:54validators including the reserve we have

6:57already gotten uh the the rewards we

6:58have already gotten plus what is in the

7:00transient stake.

7:02So we were able to prove this but there

7:03was a catch uh that we had to assume

7:06something about the reserve

7:08which sounds a bit ridiculous at first

7:10if you have never like got in touch with

7:12the Solana um system

7:15which is that the pool can actually move

7:16around uh the soul that is in in the

7:19accounts so in the reserve and in the

7:21stake accounts.

7:23Um what this is or why we need this is a

7:25is like a peculiarity of the Solana

7:28runtime

7:29because on Solana

7:31um every every account so every piece of

7:33structured data um that is stored has

7:36one owner program and that owner program

7:38is the only one that can move actually

7:40soul out of that account.

7:42So in case of the stake pools uh the

7:45reserve uh the owner program of that

7:47reserve was not actually the pool itself

7:49but it was what is called the stake

7:51program which is a Solana native program

7:54which is out of scope of the pools or

7:56the pools are built on top of that.

7:59But the users interact with the pool so

8:02how does it work? Um the users go to the

8:05pool and they

8:07say they want to redeem some shares,

8:10and the stake pool then goes to the

8:12stake program, signs a request for the

8:15stake program to move some SOL out of

8:17the reserve,

8:18and the stake program then checks the

8:20authority, that's another field on that

8:22account that is set to the address of

8:24that stake pool program, and the stake

8:27program checks who signed the request,

8:29and if that is the stake pool program,

8:30then that request is is carried out, so

8:33it's granted.

8:35Um yes, so this is why we needed this

8:37assumption. So in other words, what we

8:40needed to prove is

8:41um that the pool at all times is the

8:44authority of the reserve and the

8:45validator and the transient stake.

8:48Um if you look at the code, this looks

8:49like a completely reasonable assumption

8:52um because you know, the authority is

8:54set once and then never touched,

8:56but it is actually violated. We could

8:58not verify this, and here's what could

9:00happen.

9:02So

9:04this is going to be hard to explain now,

9:05okay, because the animations don't work.

9:07So um if the user wants to say you have

9:10a reserve that has 20 SOL, uh so it now

9:13shows zero point something something, so

9:15it's supposed to be 20.

9:17And the user there's some user that can

9:19withdraw their 20 SOL because he has

9:21enough pool tokens. So it goes to the

9:22stake pool program um asking

9:25to withdraw the the 20 SOL by giving it

9:28the pool tokens.

9:29And uh so the stake pool program goes to

9:32the stake program, asking the stake

9:33program to on behalf of the user move

9:35out that 20 SOL and give that 20 SOL to

9:38the user.

9:39The stake program sees that the

9:40authority is properly set to the stake

9:42pool as it should be

9:44uh presented here, but um yeah, the

9:47stake program then moves the 20 SOL from

9:50uh the stake program moves the 20 SOL

9:51from the reserve to the user.

9:54After that has happened, the reserve

9:56technically drops to zero SOL,

9:58and what the stake program then does is

10:01it moves the states of the reserve to

10:03uninitialized. So if whenever the stake

10:05program sees a reserve dropping to zero,

10:08it just moves it to an uninitialized

10:10state.

10:12And even worse, after the transaction

10:14ended, so when it sets it to an

10:16uninitialized state, at the same time

10:18the authority is set to none. So the

10:20stake pool is not the authority anymore

10:22of that reserve.

10:24And even worse, for an account that has

10:26zero soul or has soul below a certain

10:28rent minimum threshold, at the end of

10:30the transaction that account gets

10:31deleted from the runtime. So the reserve

10:34completely vanishes and everything that

10:35flows into that reserve by for example

10:37unstaking from the validators cannot be

10:39accessed anymore.

10:42That in itself is is bad enough, but it

10:44compounds with a different issue

10:46which is that

10:48the stake program can actually

10:49reinitialize accounts before the

10:52transaction ends.

10:53So this is what this picture here

10:55presents, because if we have a malicious

10:57user,

10:58the user itself can transfer a minimum

11:01value, so a very small value back to the

11:03reserve.

11:04And

11:05you know, then it's refunded, it won't

11:07get deleted. And in the same transaction

11:08go to the stake program asking the stake

11:11program, hey, can you reinitialize that

11:13account?

11:14And the only thing that the stake

11:16program does is check if it 's an

11:17uninitialized account.

11:19It sees the uninitialized account

11:20because we withdraw all of the soul, so

11:22the stake program will happily carry out

11:24that request and the user can put

11:26himself in place of the authority. So

11:28now every funds funding every deposit

11:31that goes into that reserve or

11:32everything that goes from the validators

11:34that gets unstaked into that reserve is

11:36now under complete control of this user.

11:40So that's a

11:41very nasty state to be in.

11:44Let's check why this happened. If you

11:46remember back, I told you that there's

11:48supposed to be some kind of minimum

11:50value always kept in the reserve.

11:54That was good intention, but it wasn't

11:56properly enforced

11:58because there was a check in place that

11:59only checked if you withdraw something

12:01that at that moment there is more than

12:03that minimum balance in the vault.

12:06What was not checked is that if you if

12:09you withdraw something, then after you

12:11carry out that withdrawal,

12:12um there's still more than that minimum

12:14balance left in the in the reserve. And

12:17that minimum value, of course, needs to

12:18be greater than zero.

12:20So the fix was very simple, which was to

12:22put back or put in that exact check that

12:24if you redeem shares and you withdraw

12:26the funds from the reserve, then there's

12:28still more than that minimum minimum

12:30minimum balance.

12:31So once that fix was uh put in, which

12:34was very like very few lines of code, uh

12:36we could prove this invariant. So there

12:38was no other counterexample to this

12:40invariant,

12:42uh meaning that it's is fully proven

12:43now.

12:44And all of the other assumptions that we

12:45needed for solvency, which I left out in

12:47this talk, were also proven, fully

12:49verified, and solvency itself was

12:51verified. And at that moment, we were

12:53guaranteed that um or we have verified

12:55that solvency

12:57holds for this Solana stake pool

12:59program.

13:01So quick recap

13:02quick recap what we what we've seen is

13:04that we found uh high severity security

13:07bug that allowed the user to completely

13:08take over the funds of a stake pool

13:11um just by violating an implicit

13:14assumption that the um account or that

13:17the pool itself could always move the

13:19funds around.

13:21And the cause was fixed or the issue was

13:23fixed by a very simple missing check on

13:26the minimum balance.

13:28So um the key takeaways that I you know

13:31think this this shows is that

13:33check your implicit assumptions because

13:35if you looked at the code base, you

13:37wouldn't see that this thing that

13:39account removal dropping to zero, this

13:41doesn't this does happen outside of the

13:43code base of the of the stake pools and

13:45within uh the runtime itself.

13:48And also ideally um do complement your

13:51audits with formal verification because

13:53formal verification makes you

13:56or forces you to make your implicit

13:57assumptions explicit because you have to

13:59list them in order to prove other

14:01invariants. So once you do that, you

14:03wonder oh is this really true? And you

14:05can also like we did in this case uh

14:07verify those assumptions uh

14:11individually independently.

14:12And you know in some some cases like in

14:15this one you get um unexpected results.

14:18Um yeah, this is all I have. Uh thank

14:21you. I don't think we have time for

14:22questions, but you can catch me

14:24afterwards. Thanks.

Source and accuracy details

Source export SHA256: 7e583abd9188723eb4a0490ab392a44bb18add0ef6738ec9caa5056ff1647adf