Skip to content

feat: add GLOAS pubkey-cache poisoning playbook (topup + slash) - #248

Open
barnabasbusa wants to merge 1 commit into
masterfrom
bbusa/gloas-pubkey-cache-poison-playbook
Open

barnabasbusa wants to merge 1 commit into
masterfrom
bbusa/gloas-pubkey-cache-poison-playbook

Conversation

@barnabasbusa

Copy link
Copy Markdown
Contributor

Adds a gloas-dev regression playbook for the validator pubkey-cache poisoning attack fixed in sigp/lighthouse#10569 — the "topup a validator then slash it right before the builder early-onboarding" case we had not tested. Inside the unfinalized window before the GLOAS fork it stages three still-pending deposits in order (a large top-up for an existing validator V0 that consumes the deposit churn, a 0xB0 builder deposit A, and a 0x01 validator deposit B), then slashes V0 before the fork so its pending top-up is skipped at the epoch boundary and the queued deposits reorder — the exact divergence that binds the wrong pubkey in a buggy global/eager pubkey cache. It then asserts the network stays healthy across the fork (fresh finality past the pre-attack checkpoint, no unexpected fork), builder A is onboarded, and validator B is onboarded and goes active (its index→pubkey mapping held and its signatures are accepted network-wide); a poisoned node rejects B and forks off, which the finality/fork checks catch. This is a single-chain reproduction and the timing is load-bearing and devnet-dependent (topupAmount and the slot offsets are config knobs); it fails fast if started after the pre-fork window. Note it permanently slashes V0, so point victimMnemonic at a disposable genesis validator.

@redpandabot redpandabot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds one new data-only playbook, playbooks/gloas-dev/pubkey-cache-poison-topup-slash.yaml, which stages a top-up, a 0xB0 builder deposit and a 0x01 validator deposit inside the unfinalized pre-fork window, slashes the topped-up victim, and then asserts finality/forks/builder-A/validator-B after GLOAS activates. The structure mirrors the existing builder-prefork-onboard playbook and the task names/configs I checked line up with the task implementations, but the pre-fork window guard leaves a hole where the staging can slip past the fork and the test still passes, and the slash itself is never asserted to have landed.

Issues

  • 🟡 playbooks/gloas-dev/pubkey-cache-poison-topup-slash.yaml:128 — fail-fast window guard still admits starts too late to stage deposits + slash — see the thread on that line
  • 🟡 playbooks/gloas-dev/pubkey-cache-poison-topup-slash.yaml:292 — slash submission is not asserted, so a failed slashing silently voids the test — see the thread on that line
  • 🟢 playbooks/gloas-dev/pubkey-cache-poison-topup-slash.yaml — generated playbook index not updated — playbooks/_index.yaml (regenerated with make generate-playbook-index, and what pkg/playbooklibrary serves to the UI library tab) has no entry for this new gloas-dev/pubkey-cache-poison-topup-slash.yaml, so the playbook stays invisible in the library until someone regenerates the index.

Reviewed @ f8b1a284
"A camel is a horse designed by committee."


# Need headroom before the fork to land both the deposits and the slash.
LATEST_DEPOSIT_SLOT=$((ACTIVATION_SLOT - 3))
if [ "$CURRENT_SLOT" -ge "$LATEST_DEPOSIT_SLOT" ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 fail-fast window guard still admits starts too late to stage deposits + slash

The guard only rejects CURRENT_SLOT >= ACTIVATION_SLOT - 3, so a start at ACTIVATION_SLOT - 4 or later than DEPOSIT_SLOT is accepted; the slot waits then return immediately and the three generate_deposits tasks (each with limitPerSlot: 1, so they consume successive blocks) plus the slash need to fit in the remaining ~4 slots. If any of them lands after ACTIVATION_SLOT, the top-up is no longer pending at the fork, the whole reorder premise disappears, and phase 5's finality/fork/builder checks pass vacuously instead of failing fast as the description promises. The headroom check should account for the deposits+slash that must still land before the fork (and reject starts past DEPOSIT_SLOT).

configVars:
minSlotNumber: "tasks.calc_slots.outputs.slashSlot"

- name: generate_slashings

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 slash submission is not asserted, so a failed slashing silently voids the test

generate_slashings only logs error generating slashing when generateSlashing returns an error and then falls out of its loop and returns nil, so the task reports success even though nothing was submitted. Since this attack depends entirely on V0 being slashed before the fork, a rejected/skipped proposer slashing (e.g. V0's status changed between the earlier active_ongoing check at line 188 and this task) leaves all the post-fork checks passing without the bug ever being exercised; asserting includedSlashings == 1 or the slashed status of V0 before phase 5 would close that.

@michaelsproul

Copy link
Copy Markdown

there's also a simpler construction, from claude below


🤖

  • Common state s: a genesis state with 64 validators, then 40 blocks with full attestations, ending at slot 40. The block at slot 31 carries two deposit requests of 32 ETH: key 64 with builder credentials 0xB0, and key 65 with 0x01 credentials. At s the finalized epoch is 3 and both deposits are pending.
  • Chain A, ending at s': Fulu blocks at slots 41 to 47, the upgrade at slot 48, then empty slots to 56.
  • Chain B, ending at s'': no block in slots 41 to 47, the upgrade at slot 48, then Gloas blocks at slots 49 to 56.
Step Chain A Chain B
Last Fulu epoch transition, at slot 48 finalizes epoch 4, so slot 31 is finalized; keys 64 and 65 become validators 64 and 65 finalized epoch stays 3; the queue scan stops at the first deposit
Upgrade at slot 48 queue is empty; no builder onboard_builders_from_pending_deposits makes a builder from the key-64 deposit
Gloas epoch transition, at slot 56 no change finalizes epoch 4; key 65 becomes validator 64

Both end states sit at slot 56 with the same finalized checkpoint, epoch 4 with root 64aff2cc…. validators[64] holds key 64 on chain A and key 65 on chain B.

This violates the intent as well as the letter. A client that keeps one index-to-pubkey map across both chains reads the wrong key at index 64 on one of them.

The cause is that the fork changes what a queued deposit becomes, at a fixed epoch. The queue position a chain has reached by that epoch depends on when that chain finalized the deposit's slot. Heze has the same split: EIP-8365 drops a queued 0x00 deposit for a new key, and the Fulu and Gloas rules make a validator from it.

@lodekeeper

Copy link
Copy Markdown

I don't think this playbook can trigger the poisoning as written, so a green run won't show whether a client is fixed. We reproduced the bug in Lodestar (both of our state transitions are affected, fix in progress) and checked this playbook's flow against the spec:

  1. The deposits aren't finalized at the last Fulu epoch transition. They land around ACTIVATION_SLOT - SLOTS_PER_EPOCH. At the F-1 → F transition the finalized checkpoint is at best epoch F-2, so process_pending_deposits stops at the top-up and none of the three is processed before the fork, slashed V0 or not. At the upgrade, A is onboarded as a builder (onboard_builders_from_pending_deposits doesn't check finality) and B later gets the next validator index. The slash never changes which key gets which index.
  2. It runs on a single chain. Every node applies the same transitions and assigns the same indices, so there is nothing for a global cache to get wrong. The bug needs two branches that put different keys at the same index, and a victim that processes the side branch first.

To catch it, the playbook needs that second branch. That could be the construction in the comment above (one branch finalizes the deposit slot before the fork, the other doesn't). Or it could be the top-up + slash variant, with the deposits already finalized at the F-1 → F transition and the slashing included only on the side branch, before the fork. Either way the victim has to run the side branch's F-1 → F transition (import a side-branch block from epoch F or later, or compute that branch's epoch-F checkpoint state) before the canonical transition that gives B its index (F → F+1 in the top-up + slash variant). On Lodestar the canonical transition then fails with ConflictingPubkey and the node stalls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants