{"id":"XE-0030","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"54","source_url":"https://github.com/xeprotocol/xe/issues/54","reporter_id":13,"title":"node: timekeeper attestation rate limit is check-then-act; concurrent requests all get signed (Medium)","area":"node-api","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:16.707047+00:00","updated_at":"2026-11-10T11:38:16.528132+00:00","source_created_at":"2026-10-25T11:12:36+00:00","told_at":"2026-11-10T00:15:24+00:00","status_changed_at":"2026-10-29T14:04:12.180566+00:00","url":"https://bounty.xe.network/XE-0030","body":"## Summary\nThe 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.\n\n## Affected component\nnode/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.\n\n## Impact\nParallel 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.\n\nSuggested severity: Medium (TOCTOU / rate-limit hole). Confirmed by read-only source review with an in-process harness.\n\n## PoC\n## PoC\n\nSetup (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:\n\n```\nGOTOOLCHAIN=auto go test -count=1 -v -run TestPoC_F20 ./node\n```\n\n**Test file** (`node/poc_f20_test.go`):\n\n```go\npackage node\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"sync\"\n\t\"sync/atomic\"\n\t\"testing\"\n)\n\n// TestPoC_F20 shows allowAttestation is check-then-act: two concurrent\n// callers for the same source:identifier both pass before recordAttestation.\nfunc TestPoC_F20(t *testing.T) {\n\tpass, detail := runF20()\n\tif pass {\n\t\tfmt.Println(\"PASS: F20 two concurrent allowAttestation calls both passed before recordAttestation\")\n\t\tfmt.Println(detail)\n\t\treturn\n\t}\n\tfmt.Println(\"FAIL: F20 expected both concurrent allows to succeed\")\n\tfmt.Println(detail)\n\tos.Exit(0)\n}\n\nfunc runF20() (bool, string) {\n\tn := &Node{}\n\tident := \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n\tsource := \"http-client\"\n\n\tstart := make(chan struct{})\n\tvar wg sync.WaitGroup\n\tvar passed atomic.Int32\n\terrs := make([]error, 2)\n\twg.Add(2)\n\tfor i := 0; i < 2; i++ {\n\t\ti := i\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\t<-start\n\t\t\terrs[i] = n.allowAttestation(source, ident)\n\t\t\tif errs[i] == nil {\n\t\t\t\tpassed.Add(1)\n\t\t\t}\n\t\t}()\n\t}\n\tclose(start)\n\twg.Wait()\n\n\tn.recordAttestation(source, ident)\n\tafter := n.allowAttestation(source, ident)\n\n\tdetail := fmt.Sprintf(\n\t\t\"AttestationRateLimit=%s key=%s:%s\\n\"+\n\t\t\t\"concurrent allow[0]=%v allow[1]=%v passed=%d\\n\"+\n\t\t\t\"after recordAttestation, third allow err=%v\",\n\t\tAttestationRateLimit, source, ident[:16],\n\t\terrs[0], errs[1], passed.Load(), after,\n\t)\n\tok := passed.Load() == 2 && after != nil\n\treturn ok, detail\n}\n```\n\n**Run** (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):\n\n```\n=== RUN   TestPoC_F20\nPASS: F20 two concurrent allowAttestation calls both passed before recordAttestation\nAttestationRateLimit=15s key=http-client:aaaaaaaaaaaaaaaa\nconcurrent allow[0]=<nil> allow[1]=<nil> passed=2\nafter recordAttestation, third allow err=rate limited: retry after 14.999897366s\n--- PASS: TestPoC_F20 (0.00s)\nPASS\nok  \tgithub.com/xeprotocol/xe/node\t0.017s\n```\n\n## Fix suggestion\nRecord the rate-limit entry inside the same critical section as the check (single mutex-held check-and-set before any signing).","patch_refs":[{"id":149,"repo":"xeprotocol/xe","kind":"pr","ref":"127","title":"fix(node): atomic check-and-reserve for timekeeper attestation rate limiting (#54)","url":"https://github.com/xeprotocol/xe/pull/127","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1554,"source":"github","source_ref":"6755087166","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0030.","created_at":"2026-11-10T00:15:24+00:00"}]}