{"id":"XE-1081","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"287","source_url":"https://github.com/xeprotocol/xe/issues/287","reporter_id":314,"title":"Undeduplicated netcheck features and uint64 overflow in GetReadiness let a 1% representative forge >=90% DAO activation readiness","area":"p2p-sync","claimed_tier":"high","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-07T14:14:49.276524+00:00","updated_at":"2026-11-14T22:55:19.307219+00:00","source_created_at":"2026-11-07T14:13:49+00:00","told_at":"2026-11-14T22:53:47+00:00","status_changed_at":"2026-11-08T20:32:07.765711+00:00","url":"https://bounty.xe.network/XE-1081","body":"Suggested severity tier: High\n\nArea: `node/activations.go`, `net/netcheck.go`, `net/features.go`, `node/node.go`\n\nRepository state checked: `xeprotocol/xe` HEAD `02e9641`\n\n## Summary\n\n`GET /network/readiness` (`(*Node).GetReadiness` in `node/activations.go:151-208`) is the delegated-weight readiness gate that the DAO checks before signing a `sys.activations` transaction (`docs/activations.md:126-166`, `api/handler.go:151`). Two bugs in how advertised peer features are ingested and aggregated allow any minor representative with non-zero delegated weight to forge arbitrary `feature_weight` and `feature_ready_milli` values, and cause large micro-XE weights to silently wrap around modulo $2^{64}$:\n\n1. **Unvalidated and undeduplicated `netcheckMsg.Features` amplifies a single representative's weight $K\\times$ (`net/netcheck.go:354-389, 415, 471`, `net/features.go:37-49`, `node/activations.go:185-187`)**:\n   - `maxAdvertisedFeatures = 8` (`net/netcheck.go:36`) is only applied to outgoing `LocalFeatures()` (`net/features.go:68-74`) and is never enforced on inbound `netcheckMsg.Features` in `checkPeer`, `handleNetcheckInbound`, `verifyPeer`, or `RecordPeerCapabilities`. Nor are incoming feature strings validated against `featureNameRegex` (`^[a-z][a-z0-9_]{0,31}$`) or deduplicated.\n   - In `(*Node).GetReadiness` (`node/activations.go:185-187`), the loop:\n     ```go\n     for _, f := range c.Features {\n         info.FeatureWeight[f] += w\n     }\n     ```\n     adds the representative's full delegated weight `w` once per element in `c.Features` without deduplication.\n   - Within the 1,024-byte `maxNetcheckBytes` handshake frame (`net/netcheck.go:34`), a peer can repeat a feature name ~95–130 times in `Features`. A representative holding just **1% of delegated weight** (`w = 100`, `TotalWeight = 10,000`) repeating `\"messaging\"` 95 times inflates `FeatureWeight[\"messaging\"]` from `100` to `9,500` and `FeatureReadyMilli[\"messaging\"]` from `10` (1.0%) to **`950` (95.0%)**, crossing both the 67% finality quorum (`670`) and the 90% (`900`) DAO activation gate (`docs/activations.md:145-166`) while 99% of representative weight does not support the feature.\n\n2. **`uint64` multiplication overflow in `w * 1000 / info.TotalWeight` (`node/activations.go:196`)**:\n   - Delegated weights are denominated in micro-XE (`10^-6` XE) as `uint64` values (`core/ledger.go:2680-2687`).\n   - At `node/activations.go:196`, `info.FeatureReadyMilli[f] = w * 1000 / info.TotalWeight` evaluates `w * 1000` in 64-bit unsigned arithmetic before dividing by `info.TotalWeight`.\n   - Whenever `w > math.MaxUint64 / 1000` (`18,446,744,073,709,551` micro-XE, or at a fraction of that when amplified by duplicate feature entries), `w * 1000` overflows `uint64` and wraps modulo $2^{64}$. For example, at `w = TotalWeight = 20_000_000_000_000_000` micro-XE (100% actual readiness), `FeatureReadyMilli` reports **`77` (7.7%)** instead of **`1000` (100.0%)**.\n\n## Root Cause\n\n- `net/netcheck.go:354-389` (`checkPeer`): checks `NetworkID`, `GenesisHash`, and `Version`, but performs zero validation on `msg.Features` (no `maxAdvertisedFeatures` bound, no `ValidateFeatureName` check, and no duplicate check).\n- `net/features.go:37-49` (`(*peerCapTable).record`): stores `c.Features` verbatim without sanitizing, deduplicating, or capping at `maxAdvertisedFeatures`.\n- `node/activations.go:185-197` (`(*Node).GetReadiness`):\n  ```go\n  for _, f := range c.Features {\n      info.FeatureWeight[f] += w\n  }\n  ...\n  info.FeatureReadyMilli[f] = w * 1000 / info.TotalWeight\n  ```\n  iterates over `c.Features` without per-representative deduplication, uses unchecked `+=` instead of saturating addition (`addSat`), and computes `w * 1000 / info.TotalWeight` using 64-bit multiplication that overflows for `w > math.MaxUint64 / 1000`.\n\n## Reproduction\n\nRun the in-process regression tests against unpatched `HEAD` (`02e9641`):\n","patch_refs":[{"id":321,"repo":"xeprotocol/xe","kind":"pr","ref":"288","title":"net, node, statechain: deduplicate and validate advertised features and prevent uint64 overflow in GetReadiness","url":"https://github.com/xeprotocol/xe/pull/288","note":"","state":"open","author":"pa-khan","added_by":"desk","created_at":"2026-11-07T14:14:50.692157+00:00"},{"id":325,"repo":"xeprotocol/xe","kind":"pr","ref":"294","title":"net, node, statechain: deduplicate and validate advertised features and prevent uint64 overflow in GetReadiness","url":"https://github.com/xeprotocol/xe/pull/294","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-07T19:30:37.728762+00:00"}],"thread":[{"id":3745,"source":"github","source_ref":"6885487501","author":"XE desk","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-1081 and says what differs; it is read like any other.","created_at":"2026-11-14T22:53:47+00:00"}]}