Bounty
XE-0138 · Bounty

node: canAttest accepts forged provider identifiers via a zero-mid directory match, and RequestAttestation has no timekeeper gate

Closed · duplicate —claimed Minor xe#236 filed 2026-10-31 15:35 UTC by 0xDimzy

Report

node: canAttest accepts forged provider identifiers via a zero-mid directory match, and RequestAttestation has no timekeeper gate

Suggested severity: Low–Medium (I am deliberately not claiming a higher tier — see Impact)

Area: timekeeper attestation issuance — node/attestation.go, node/node.go Pin: xeprotocol/xe HEAD 978785929bc17a2f4ab30c383e5fc9cf4d634512 (2026-10-15) Duplicate check: searched for canAttest, zeroMid, "0000000000000000", forged attestation, identifier forgery, directory attestation — no existing issue covers this. Related but distinct: #54 (rate-limit TOCTOU), #19/#23 (freshness on sync), #25 (VM existence gate).

Summary

Node.canAttest (node/attestation.go:32-55) is the authorisation gate for attestation requests. For any identifier that is not a live lease, it falls through to a directory check that accepts an identifier of the form

account[:32] + "0000000000000000" + account[48:]

for any registered provider account. That identifier is neither a lease nor a directory account, yet the node signs it.

Separately, Node.RequestAttestation (node/node.go:2218-2235) signs with n.KeyPair without checking whether this node is actually a timekeeper (i.e. whether its key is in the sys.timekeepers keyset).

Affected code

node/attestation.go:32-55

func (n *Node) canAttest(identifier string) error {
    if lease := n.GetLease(identifier); lease != nil {
        switch lease.State {
        case core.LeaseCreated, core.LeaseAccepted:
            return nil
        }
        return fmt.Errorf("lease %s is %s: no attestation-gated transitions remain", ...)
    }
    if n.Directory != nil && len(identifier) == 64 {
        if _, ok := n.Directory.Lookup(identifier); ok {
            return nil
        }
        const zeroMid = "0000000000000000"
        if identifier[32:48] == zeroMid {
            for _, reg := range n.Directory.List() {
                a := reg.Account
                if len(a) == 64 && a[:32] == identifier[:32] && a[48:] == identifier[48:] {
                    return nil          // <-- accepts a forged identifier
                }
            }
        }
    }
    return fmt.Errorf("unknown attestation identifier %s: not a live lease or a registered provider", ...)
}

node/node.go:2218-2235

func (n *Node) RequestAttestation(source, identifier string) (*core.TimekeeperAttestation, error) {
    if len(identifier) != 64 { return nil, fmt.Errorf("invalid attestation identifier length: %d", len(identifier)) }
    if err := n.allowAttestation(source, identifier); err != nil { return nil, err }
    if err := n.canAttest(identifier); err != nil {
        logging.Warnf("Attestation request from %s rejected: %v", source, err)
        return nil, err
    }
    n.recordAttestation(source, identifier)
    ts := core.Now().UnixNano()
    return core.SignAttestation(identifier, ts, n.KeyPair)   // no timekeeper gate
}

The directory is public: GET /directory returns every registered provider account.

Reproduction

GOTOOLCHAIN=auto go build -trimpath -buildvcs=false -o xe ./cmd/xe
./xe node --api-port 18080 --api-bind 127.0.0.1

Registered directory account (from GET /directory):

c20d6fc8151ae99de5fd06c2b6dc8225ce22697448fba94abcd72b3d2cf8ff1b

Forged identifier = account[:32] + "0000000000000000" + account[48:]:

c20d6fc8151ae99de5fd06c2b6dc82250000000000000000bcd72b3d2cf8ff1b

Request — HTTP 200, attestation issued

POST /attestation/request
Content-Type: application/json

{"lease_hash":"c20d6fc8151ae99de5fd06c2b6dc82250000000000000000bcd72b3d2cf8ff1b"}

{
  "public_key":"b5373a066fad131039357c292caf0f2fe97101ba05b4fc7623fd765c898e32d2",
  "timestamp":1793395907883507785,
  "signature":"83242ebcabddb7c875a23204fd40936140498a1b47a30f55dc94b1033139040d3a601bebceb257d975dd72a111ebc231323cdb6a0439514ee08fd894ba1a8906"
}

Control 1 — same prefix/suffix, middle NOT zeros → rejected

{"lease_hash":"c20d6fc8151ae99de5fd06c2b6dc82251111111111111111bcd72b3d2cf8ff1b"}
HTTP 400 {"error":"unknown attestation identifier c20d6fc8151a...: not a live lease or a registered provider"}

Control 2 — unrelated identifier → rejected

HTTP 400 {"error":"invalid attestation identifier length: 60"}

The only difference between acceptance and rejection is the 16 middle hex characters. Deterministic, and requires no secret material — only the public directory listing.

Impact — stated honestly

I am not claiming this is a mint bypass or escrow theft. Two independent controls stop that:

  1. Attestations are bound to the settled lease hash. core/attestation.go:82 calls VerifyAttestation(&a, leaseHash), and AttestationPayload (core/attestation.go:11-21) hashes the lease hash into the signed payload.
  2. An attacker cannot choose a lease hash. core/ledger.go:1592 sets LeaseHash: b.Hash — the lease hash is the block hash, not an attacker-supplied field.

What it does give:

  • Attestation issuance for identifiers that are neither leases nor accounts. The gate's stated contract is not what the code enforces. Any future consumer that trusts "the timekeeper signed this identifier" inherits the defect.
  • Rate-limit amplification beyond #54. allowAttestation keys on source + ":" + identifier, and the identifier space is unbounded (any provider account; the middle 16 hex only needs to be zeros). #54 covers concurrent requests for one identifier; this widens the key space without limit.
  • No timekeeper gate. A node not in the sys.timekeepers keyset still signs. core.ValidateAttestations rejects untrusted public keys, so there is no direct consensus impact today — but a misconfigured or compromised non-timekeeper node will burn signing CPU and produce well-formed-looking signatures.

Suggested fix

  1. In canAttest, drop the zero-mid fallback entirely, or require the constructed identifier to resolve to a lease whose Provider matches the matched directory account. The current check compares only account bytes, with no lease lookup and no provider binding.
  2. In RequestAttestation, verify the node's own key is a member of the active sys.timekeepers keyset before signing, and error otherwise. This makes the endpoint safe to expose on any node.
  3. Consider binding the attestation payload to the operation type (as PR #23 does for freshness) so an attestation cannot be replayed across lease operations.

Notes

  • Verified against upstream master at the pin: the zero-mid branch is still present.
  • All testing was done against a node I ran myself on 127.0.0.1. No third-party node was contacted.
  • No PR opened; happy to prepare one if the fix direction is acceptable.

Thread

fahriiri2062026-11-04 09:24 UTCgithub

Additional delta on the same endpoint, from an independent review (commit 02e9641b, PoCs executed against a repo copy): the 15 s attestation limit in allowAttestation (node/attestation.go:86-105) is keyed on source + ":" + identifier, where source is clientIP(r) — and clientIP (api/handler.go:375-393) returns the last X-Forwarded-For element verbatim whenever the TCP peer is loopback, which is the default --api-bind 127.0.0.1 deployment. Rotating the header therefore makes the limit non-binding (observed: 3/3 requests signed with rotating XFF vs the limit's intent), and the same string lands in logging.Warnf("Attestation request from %s rejected: ..."), so the audit trail is attacker-forgeable. Second vector: unbounded XFF length pins memory in node.attRateMap (swept every 15 s) — observed XFF len=900002 -> 200, source length 900002 bytes. Filed separately as the inverse-direction rate-limit issue; noting here so the #236 fix scope covers keying the limit on something the client cannot choose.

Joseph Denneteam2026-11-05 22:24 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0116, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, reply with what differs and we will look again.