<!-- XE-0030 · node: timekeeper attestation rate limit is check-then-act; concurrent requests all get signed (Medium) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0030>. The page is the record; this is the same page for reading.*

XE-0030 · Bounty

# node: timekeeper attestation rate limit is check-then-act; concurrent requests all get signed (Medium)

Accepted
claimed Medium
[xe#54](https://github.com/xeprotocol/xe/issues/54)
filed 2026-10-25 11:12 UTC
by byfor8

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   Node / API

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

- [xe#127](https://github.com/xeprotocol/xe/pull/127) open by arturbarszcz78
  fix(node): atomic check-and-reserve for timekeeper attestation rate limiting (#54)

### History

- [61377](https://bounty.xe.network/log/61377) 2026-11-10 00:15 UTC reply.mirrored
- [61334](https://bounty.xe.network/log/61334) 2026-11-10 00:15 UTC reply.sent
- [17798](https://bounty.xe.network/log/17798) 2026-11-07 16:06 UTC proposal.adopted
- [17797](https://bounty.xe.network/log/17797) 2026-11-07 16:06 UTC ticket.award
- [17796](https://bounty.xe.network/log/17796) 2026-11-07 16:06 UTC proposal.rejected
- [6876](https://bounty.xe.network/log/6876) 2026-11-05 13:45 UTC proposal.created
- [1800](https://bounty.xe.network/log/1800) 2026-11-02 19:16 UTC proposal.created
- [1455](https://bounty.xe.network/log/1455) 2026-11-02 10:11 UTC note.added
- [724](https://bounty.xe.network/log/724) 2026-10-29 14:22 UTC note.added
- [723](https://bounty.xe.network/log/723) 2026-10-29 14:22 UTC ticket.facts area
- [618](https://bounty.xe.network/log/618) 2026-10-29 14:05 UTC github.labels
- [348](https://bounty.xe.network/log/348) 2026-10-29 14:04 UTC ticket.status triaging → accepted

[Full history](https://bounty.xe.network/log?ref=XE-0030) · [JSON](https://bounty.xe.network/v1/tickets/XE-0030) · [markdown](https://bounty.xe.network/XE-0030.md)

### Report

## Summary

The attestation rate limiter checks the per-source limit and records the request in two separate steps, so N concurrent requests for the same lease identifier all pass the check before any of them records. Each accepted request produces a real timekeeper signature over the current clock, burning timekeeper signing CPU and bloating attestation history on every live lease.

## Affected component

node/node.go, RequestAttestation at lines 2218 to 2234 (allowAttestation then canAttest then recordAttestation); node/attestation.go, allowAttestation at lines 86 to 104 and recordAttestation at lines 107 to 114, at commit 978785929bc17a2f4ab30c383e5fc9cf4d634512.

## Impact

Parallel POSTs against a timekeeper's HTTP API for each public live lease hash produce unbounded extra signatures per 15 second window. Timestamps come from the node's own clock, so this is not attestation forgery and not escrow theft: the cost is signing CPU and storage amplification on timekeepers.

Suggested severity: Medium (TOCTOU / rate-limit hole). Confirmed by read-only source review with an in-process harness.

## PoC

## PoC

Setup (from a fresh clone of xeprotocol/xe at the pin): save the test file below at `node/poc_f20_test.go` (it joins the package's own test build), then:

```
GOTOOLCHAIN=auto go test -count=1 -v -run TestPoC_F20 ./node
```

**Test file** (`node/poc_f20_test.go`):

```
package node

import (
	"fmt"
	"os"
	"sync"
	"sync/atomic"
	"testing"
)

// TestPoC_F20 shows allowAttestation is check-then-act: two concurrent
// callers for the same source:identifier both pass before recordAttestation.
func TestPoC_F20(t *testing.T) {
	pass, detail := runF20()
	if pass {
		fmt.Println("PASS: F20 two concurrent allowAttestation calls both passed before recordAttestation")
		fmt.Println(detail)
		return
	}
	fmt.Println("FAIL: F20 expected both concurrent allows to succeed")
	fmt.Println(detail)
	os.Exit(0)
}

func runF20() (bool, string) {
	n := &Node{}
	ident := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	source := "http-client"

	start := make(chan struct{})
	var wg sync.WaitGroup
	var passed atomic.Int32
	errs := make([]error, 2)
	wg.Add(2)
	for i := 0; i < 2; i++ {
		i := i
		go func() {
			defer wg.Done()
			<-start
			errs[i] = n.allowAttestation(source, ident)
			if errs[i] == nil {
				passed.Add(1)
			}
		}()
	}
	close(start)
	wg.Wait()

	n.recordAttestation(source, ident)
	after := n.allowAttestation(source, ident)

	detail := fmt.Sprintf(
		"AttestationRateLimit=%s key=%s:%s\n"+
			"concurrent allow[0]=%v allow[1]=%v passed=%d\n"+
			"after recordAttestation, third allow err=%v",
		AttestationRateLimit, source, ident[:16],
		errs[0], errs[1], passed.Load(), after,
	)
	ok := passed.Load() == 2 && after != nil
	return ok, detail
}
```

**Run** (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):

```
=== RUN   TestPoC_F20
PASS: F20 two concurrent allowAttestation calls both passed before recordAttestation
AttestationRateLimit=15s key=http-client:aaaaaaaaaaaaaaaa
concurrent allow[0]=<nil> allow[1]=<nil> passed=2
after recordAttestation, third allow err=rate limited: retry after 14.999897366s
--- PASS: TestPoC_F20 (0.00s)
PASS
ok  	github.com/xeprotocol/xe/node	0.017s
```

## Fix suggestion

Record the rate-limit entry inside the same critical section as the check (single mutex-held check-and-set before any signing).

### Thread

**XE desk**team2026-11-10 00:15 UTCgithub

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-0030.
