{"id":"XE-13375","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"529","source_url":"https://github.com/xeprotocol/xe/issues/529","reporter_id":2252,"title":"Provider advertisements are replayable and never expire: a stale or revoked ad is accepted as current","area":"p2p-sync","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0009","tracked":true,"internal_ref":"#1100","internal_url":"https://github.com/xeprotocol/core/issues/1100","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:13.465593+00:00","updated_at":"2026-11-20T00:53:17.559481+00:00","source_created_at":"2026-11-13T03:20:55+00:00","told_at":"2026-11-20T00:51:02+00:00","status_changed_at":"2026-11-20T00:50:06.199795+00:00","url":"https://bounty.xe.network/XE-13375","body":"**Suggested tier:** Low\n\n**XE address (reward destination):** 9b663fdac108be34a3b715ef78a9f9bd878af6ef8142f388c6514918e6852dd7\n\n## Summary\n\n`net/gossip_validate.go`, `marketplaceValidator`, ad case (~l.41–44): the ONLY checks on an incoming provider advertisement are (a) `ad.Signature` valid over `ad.PubKey`, and (b) timestamp not in the future (`ad.Timestamp > now+1m`). There is NO freshness check on old timestamps, NO nonce, NO expiry (30 min TTL exists in the directory, but `Advertisement` in `types/types.go` has no TTL field and the advertisement TTL is never checked in `net/gossip_validate.go`).\n\nSo a captured signed ad can be replayed later — same signature, same timestamp, still valid — including after the provider rotated its price/capacity or removed the ad entirely. An old ad is accepted as current.\n\n## Impact\n\nAn old ad can lure a consumer into requesting a lease from a provider that no longer offers those terms (e.g. price or vCPU), causing the consumer to commit funds to a lease that won't match their expectation (though the lease's cost is re-verified by the ledger — `validateAndAddLease` recomputes `LeaseCost` from the pinned certificate, so the monetary damage is bounded; the consumer is also stuck waiting for the lease to settle or cancelling it).\n\nSeverity is Low because (a) the ad's content (price/dims) is pinned by the certificate, so a replayed ad cannot create a fraudulent lease with a different price, and (b) the consumer can cancel an unaccepted lease and get refunded.\n\n## Steps to reproduce\n\nUnit test against the real node code (`github.com/xeprotocol/xe`, testnet-0005, commit `89a542e`):\n\n```\ngit clone https://github.com/xeprotocol/xe\ncd xe\ncp market-node_test.go node/\ncp market-net_test.go net/\ngo test ./node -run TestMarket -v -count=1\ngo test ./net -run TestMarket -v -count=1\n```\n\nNote: `market-node_test.go` / `market-net_test.go` are NOT in the public repository — the PoC test files are attached to this issue; without them, the XE team cannot run this reproduction.\n\n**PoC 2a — stale ad accepted** (`TestMarketAdvertisement_StaleAndReplayAccepted`, in `market-node_test.go`): feed an ad with `Timestamp` 1 hour in the past through the real `handleMarketplace`.\n\n**Expected:** the stale ad is rejected.\n**Actual (reproduced 2026-11-13):** the ad is stored and served to `RequestLease`.\n```\nCONFIRMED: stale advertisement (1h old) accepted and stored\n```\n\n**PoC 2b — replayed ad accepted** (`TestMarketAdvertisement_StaleAndReplayAccepted`, second half): the same signed ad is replayed later — the signature is still valid, so it is accepted again (no nonce / dedup).\n\n**Expected:** a replayed ad is rejected.\n**Actual:** accepted.\n```\nCONFIRMED: replayed advertisement accepted again (no nonce / dedup on ad)\n```\n\n## Root cause\n\n`net/gossip_validate.go`, `marketplaceValidator`, ad case: no lower-bound timestamp check, no nonce, no expiry; `types/types.go`, `Advertisement` has no TTL field; the 30 min directory TTL (`net/directory.go`, `DirectoryEntry`) is never consulted by the advertisement validator.\n\n## Suggested fix\n\nAdd a freshness window for ads (e.g. 60 s, matching the pendingOffers prune), a monotonically increasing nonce per provider, and an expiry field in `Advertisement` that is checked on ingest.\n\n## Controls verified (same PoC files, all PASS)\n\n- Cross-context signature reuse (ad ↔ request ↔ offer) is rejected — distinct domain tags (`xe/marketplace-advertisement/v1`, `-request/v1`, `-offer/v1`) plus different field sets (`TestMarketCrossContext_SignatureReuseRejected`).\n- `TotalCost` / `Timestamp` forgery is rejected — both fields are signature-covered; only exact replays pass (`TestMarketTamper_TotalCostAndTimestampSigned`). Even a tampered cost could not create a bad lease (ledger recomputes `LeaseCost` from the pinned cert).\n- Stale-price lease via a replayed offer is not reachable through the honest consumer flow: `RequestLease` generates a fresh `RequestID` per call and only accepts offers for it, and the ledger re-verifies cost against the pinned certificate.\n- Directory impersonation / registration replay is neutralised (monotonicity + 30 min TTL, `TestMarketDir_MonotonicityRejectsOldReplay`, `market-dir_test.go`).\n\n[market-node_test.txt](https://github.com/user-attachments/files/34781612/market-node_test.txt)\n[market-net_test.txt](https://github.com/user-attachments/files/34781614/market-net_test.txt)\n[market-dir_test.txt](https://github.com/user-attachments/files/34781613/market-dir_test.txt)","patch_refs":[{"id":576,"repo":"xeprotocol/xe","kind":"pr","ref":"542","title":"fix(net): add timestamp freshness and expiry validation to provider advertisements (fixes #529)","url":"https://github.com/xeprotocol/xe/pull/542","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-14T20:42:20.288328+00:00"}],"thread":[{"id":13549,"source":"github","source_ref":"7026824749","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0009, 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-13375 and says what differs; it is read like any other.","created_at":"2026-11-20T00:51:02+00:00"}]}