Sync ingestion skips the timekeeper attestation freshness check, so a lapsed lease renewal carrying the original accept attestations commits as canonical history
Report
Suggested severity tier: Low
Area: core attestation validation and sync ingestion, core/attestation.go, core/ledger.go (AddSyncedBlock), net/sync.go
Repository state checked: xeprotocol/xe HEAD 978785929bc17a2f4ab30c383e5fc9cf4d634512
Summary
A timekeeper attestation signs a payload built from the lease hash and a timestamp only (core/attestation.go, AttestationPayload and VerifyAttestation at line 36). The payload names no operation type and no block hash. On the live ingestion path, ValidateAttestations drops attestations whose timestamp sits too far from the node clock. That freshness test is the single skew comparison at core/attestation.go:86, and it runs only when a flag is off. The sync ingestion path sets that flag. AddSyncedBlock (core/ledger.go:735) calls the same addBlock function as the live path with the flag set to true, which skips the block timestamp window and passes the flag on as skipSkew to the lease validators. A renewal block that the live path rejects for stale attestations is committed in full when the identical block arrives through sync, and the receiving node treats it as ordinary canonical history.
The experiment below ran against the real core.Ledger and the real core.VoteManager from this tree, wired the way node/node.go wires them. A full verification record, with the harness source and its logs, is available on request.
The experiment
A consumer opened a lease of 1 vCPU, 1024 MB, and 10 GB for 3600 seconds at a cost of 40,000 micro-XUSD. The provider accepted it at time T0 (1792778684491395990) with two timekeeper attestations signed at T0 over the accept payload. The lease EffectiveExpiry was T0 + 3600s (1792782284491395990). The consumer held 99,960,000 micro-XUSD after the accept, and the escrow pending send held 40,000 micro-XUSD. The attestation set was then read back from the stored accept block, which is where any observer of the chain can read it.
The ledger clock was moved to T0 + 3 days. At that point the attestation set was 72 hours old. MaxAttestationSkew in force was 600,000,000,000 ns (10 minutes), so the set sat at 432 times the allowed skew. The lease itself had been expired in wall clock terms for about 71 hours.
Live path control. A consumer signed lease_renew block (duration 3600 seconds, cost 40,000 micro-XUSD, Previous set to the lease block) carrying the T0 attestation set was fed to Ledger.AddBlock. It was rejected with the error: lease_renew attestation: only 0 valid attestations from trusted timekeepers, need 2. The lease record was unchanged.
Sync path. The identical block, same hash, was fed to Ledger.AddSyncedBlock, the entry point the sync client uses at net/sync.go:607 and net/sync.go:632. It returned no error. The block was stored, the consumer frontier advanced to it, and a renewal segment was committed with StartTime equal to the stale attestation median, T0. EffectiveExpiry extended to T0 + 7200s (1792785884491395990). The consumer was debited the renewal cost, ending at 99,920,000 micro-XUSD, and the escrow pending send rose from 40,000 to 80,000 micro-XUSD.
Vote wiring. The block added callback fired for the sync committed renew, and inside the real VoteManager the callback invoked CastVote for that position. Vote storage for the renew position was withheld in the harness by the depsFinalized gate, for a harness reason explained in the limits section. In a separate phase of the same run, the identical wiring stored and emitted a real signed vote of weight 80,000 for a dependency free mint, which shows the callback path itself stores and emits votes when the production gates hold.
Cross operation bound. The renew above is itself the cross operation case: attestations issued for lease_accept were presented with a lease_renew block for the same lease. A settle block carrying the same set was rejected on both paths by its own median time gate, with the error: lease not yet expired: need timestamp >= 1792782284491395990, got 1792778684491395990. Each operation keeps a median time gate, and the accept median can satisfy the renew gate (core/lease_renew.go:58) while failing the settle and force-settle gates. The force-settle gate at core/ledger.go:1936 was read from code during verification. It was not run, and this report claims nothing runtime about force-settle.
Attacker preconditions
The attacker needs a consumer signed lease_renew block for a live, accepted lease, with Previous equal to the consumer frontier on the target node. Only the consumer can sign that block, so the attacker is the consumer, is colluding with the consumer, or is replaying a renew block the consumer signed earlier and that was withheld or never committed. Block signatures carry no expiry of their own, and the sync path also skips the block timestamp window, so a withheld block stays usable.
The attacker also needs the lease accept attestation set. That set is public. It is stored verbatim inside the on-chain accept block and was recovered from the stored block during verification, exactly as an attacker would recover it.
Delivery needs a sync serving position toward a victim. Sync in this codebase is a pull protocol. SetupSync (net/sync.go:303) registers the /xe/sync stream handler and a ConnectedF hook that starts a sync request on every new peer connection, and a periodic ticker (10 seconds, net/sync.go:346) re-syncs with known peers. The client sends its own frontiers in the request, so a serving peer learns where a crafted block must slot in. The crafted block must extend the frontier the victim already has for that account. Nodes whose view of the consumer chain still ends at the pre-renew frontier are the exposed population: lagging nodes, nodes that were offline, and new nodes syncing history from scratch, for whom the stale attested renew arrives as ordinary history. Once one node commits the block, that node serves it onward as history to later syncing peers. The attacker does not need to be a bootstrap node. The other pull path, blocksync, enters through Ledger.AddBlock, where the freshness check stays on, so the gap is specific to the /xe/sync path.
Impact
A renewal the network rules treat as lapsed is committed as canonical history on sync fed nodes. The consumer balance is debited and the escrow is topped up as if the renewal had happened while the lease was live, EffectiveExpiry extends by the signed renewal duration, and the provider can later settle against the extended expiry and collect the renewal segment emission. Nodes that processed live events after the real expiry and nodes that received the stale renew through sync first hold different histories for the same lease, and the position is then decided by the conflict and quorum rules with the stale renewal competing as an equal citizen. The gain is bounded to one renewal per signed block, at the duration, cost, and locked terms the consumer actually signed.
What was not proven
The two node network observation is outstanding. A source built node booted on localhost against the shipped testnet-0005 genesis bundle and stayed up, so the binary runs. The full two node run was not completed, because the shipped 0005 statechain genesis fixes sys.timekeepers, sys.minter, sys.oracle, and sys.dao_keyset to testnet keys whose private keys are unavailable. A local network first needs a self-authored genesis pair that sets those keys to keys the operator holds. Level B was used instead: it exercises the same Ledger and VoteManager composition the node binary uses, through the same two entry points, and every state figure above comes from that run.
Force-settle with a stale accept set was read from code and was not runtime tested, as stated in the experiment section.
Vote storage and emission for the renew position itself did not happen inside the harness. The depsFinalized gate in castVoteLocked (core/finalization.go) withheld the vote because the renew depends on a lease block above the harness final height. Finality cannot advance in a single process in this setup: the quorum threshold is 67 percent of delegated weight, and the embedded genesis account holds 42,000,000,000,000 of 42,000,000,080,000 total micro-XE, with no private key available outside the real network. On the production network the lease block the renew depends on is finalized by real representative weight, so the gate passes there. Commit of the renew and the CastVote invocation are proven; emission for that specific position is proven by the identical wiring in the mint phase of the same run.
The harness also ran with Difficulty set to 0 and a locally defined timekeeper set (threshold 2). Difficulty affects proof of work only. The timekeeper set definition stands in for the statechain sys.timekeepers value the real node reads, and the signatures under test are genuine timekeeper signatures either way.
Suggested fix
Apply attestation freshness on the sync path as well. The block timestamp window skip exists so a node can catch up on old blocks, and the attestation skew test can be separated from that skip and run against the wall clock at commit time. A block whose attestation set is older than MaxAttestationSkew at commit would then fail on sync exactly as it fails live. A second change removes the reuse at the source: bind the attestation payload to the operation type, so an accept set cannot be presented with a renew, settle, or force-settle block.
Reproduction
The verification harness is a Go program that uses this repository's own core package. It builds a core.Ledger and a core.VoteManager on a memory store, wired the way node/node.go wires them (SetBlockAddedCallback to VoteManager.OnBlockAdded, SetConflictCallback, and the QuorumManager RevoteFn and OnFinalized hooks), with a locally defined timekeeper set at threshold 2. Its steps:
- Create a lease (1 vCPU, 1024 MB, 10 GB, 3600 seconds, cost 40,000 micro-XUSD) and accept it through Ledger.AddBlock at time T0 with two genuine timekeeper attestations signed at T0. Read the attestation set back from the stored accept block.
- Move the ledger clock to T0 + 3 days, so the attestation set is 72 hours old against a MaxAttestationSkew of 10 minutes.
- Build a consumer signed lease_renew block carrying the T0 attestation set and feed it to Ledger.AddBlock. Observe the rejection: lease_renew attestation: only 0 valid attestations from trusted timekeepers, need 2.
- Feed the identical block, same hash, to Ledger.AddSyncedBlock. Observe that it commits: the renewal segment is stored with StartTime T0, EffectiveExpiry moves from T0 + 3600s to T0 + 7200s, the consumer is debited 40,000 micro-XUSD, and the escrow pending send rises from 40,000 to 80,000 micro-XUSD.
- As a bound check, feed a lease_settle block carrying the same set to both entry points. Observe rejection on both by the settle median time gate.
The harness source and its full run logs are available on request. The run ends with the line: RESULT: all checks PASSED. Keys and hashes differ per run because the harness generates fresh keypairs; the assertions are relative to T0, the medians, and the balances.
Thread
Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0010.