<!-- XE-13372 · `pendingOffers` flood + offer displacement: unauthenticated offers block legitimate leases and steer a victim's lease to an attacker-chosen provider · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13372>. The page is the record; this is the same page for reading.*

XE-13372 · Bounty

# \`pendingOffers\` flood \+ offer displacement: unauthenticated offers block legitimate leases and steer a victim's lease to an attacker-chosen provider

Closed · duplicate
—claimed Medium
[xe#526](https://github.com/xeprotocol/xe/issues/526)
filed 2026-11-13 03:17 UTC
by AIRDROP TREASURESS

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   Node / API

Duplicate of
:   [XE-0106](https://bounty.xe.network/XE-0106) triaging

Tracked
:   —

Updated
:   2026-11-20 00:51 UTC

Told
:   2026-11-20 00:50 UTC

### Patches

- [xe#913](https://github.com/xeprotocol/xe/pull/913) open by tipprb
  fix(xe): pendingoffers--flood---offer (fixes #526)

### History

- [559635](https://bounty.xe.network/log/559635) 2026-11-20 00:51 UTC github.state\_pushed
- [559634](https://bounty.xe.network/log/559634) 2026-11-20 00:51 UTC github.labels
- [559562](https://bounty.xe.network/log/559562) 2026-11-20 00:50 UTC reply.mirrored
- [559010](https://bounty.xe.network/log/559010) 2026-11-20 00:50 UTC proposal.adopted
- [559009](https://bounty.xe.network/log/559009) 2026-11-20 00:50 UTC reply.sent
- [559008](https://bounty.xe.network/log/559008) 2026-11-20 00:50 UTC ticket.status new → closed
- [558060](https://bounty.xe.network/log/558060) 2026-11-20 00:49 UTC proposal.adopted
- [558059](https://bounty.xe.network/log/558059) 2026-11-20 00:49 UTC ticket.facts area
- [558058](https://bounty.xe.network/log/558058) 2026-11-20 00:49 UTC proposal.adopted
- [558057](https://bounty.xe.network/log/558057) 2026-11-20 00:49 UTC ticket.facts
- [558056](https://bounty.xe.network/log/558056) 2026-11-20 00:49 UTC proposal.adopted
- [558055](https://bounty.xe.network/log/558055) 2026-11-20 00:49 UTC ticket.facts

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

### Report

**Suggested tier:** Medium

**XE address (reward destination):** 9b663fdac108be34a3b715ef78a9f9bd878af6ef8142f388c6514918e6852dd7

## Summary

`node/node.go`, `handleMarketplace` (offer case, \~l.1404–1425) stores an incoming marketplace offer after verifying only its signature — with three missing checks, all in one place:

1. **No request-ownership check.** Offers are stored for *any* `RequestID`, including IDs this node never issued. There is no record of outgoing requests to compare against.
2. **Single slot per RequestID, last-write-wins.** No timestamp comparison, no price/dimension check, no first-seen-wins. Any later offer for the same RequestID silently displaces the earlier one.
3. **Hard cap of 1000 with silent drop.** Once the map is full, every further offer is dropped (`len < 1000` gate) — including legitimate ones. The 60 s prune only runs on ingest of another offer, and only evicts pre-existing entries.

There is no barrier to entry: `core.VerifyPayloadKey` (used by `VerifyOffer`) only checks that the pubkey derives the claimed account address — it never checks that the account exists on the ledger, holds any balance, or has stake. A fresh throwaway keypair can sign valid offers.

## Impact

Honestly bounded — no direct theft. The lease block the consumer builds is still validated by the ledger (`validateAndAddLease` re-checks cost vs. the pinned certificate, cert ownership and expiry), and an unaccepted lease is refundable via cancel, so the victim's funds are locked/delayed, not stolen. What the attacker gains is:

- (a) **Network-wide denial of lease creation** while the flood runs. Sustaining it costs \~17 fresh offers/s (one 1000-offer refill per 60 s prune window) — trivial — and it hits *every* node, because gossip propagates the offers network-wide and every node runs the same handler. Gossip peer-scoring does not mitigate: valid messages incur no `InvalidMessageDeliveries` penalty, and there is no per-topic rate limit in `gossipOptions`.
- (b) **Steering a victim's lease to a provider of the attacker's choosing** (including themselves, with no stake — `LeaseStake` returns 0 while `LeaseStakeDivisor == 0` — and, per #392, a self-issued certificate). The attacker's offer is freshly signed (new timestamp/signature), so gossipsub's 120 s duplicate-suppression does not apply.
- A consumer asking for 8 vCPUs can also silently receive fewer: `RequestAndCreateLease` never checks `offer.VCPUs/MemoryMB/DiskGB/Duration` against the request (honest providers copy the request dims, but nothing enforces it).

## Steps to reproduce

Unit tests against the real node code (`github.com/xeprotocol/xe`, testnet-0005, commit `89a542e`):

```
git clone https://github.com/xeprotocol/xe
cd xe
cp market-node_test.go node/
cp market-net_test.go net/
go test ./node -run TestMarket -v -count=1
go test ./net -run TestMarket -v -count=1
```

Note: `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.

**PoC 1a — flood blocks a legitimate offer** (`TestMarketPendingOffers_FloodBlocksLegit`, in `market-node_test.go`): feed 1000 distinct self-signed offers (fresh keypair, random RequestIDs) through the real `handleMarketplace`, then a legitimate offer for `victim-request`.

**Expected:** the legitimate offer is stored.
**Actual (reproduced 2026-11-13):** the map holds 1000 attacker offers; the legitimate offer is **not stored**. The victim consumer's `RequestLease` polls for 30 s and returns `no offer received within 30s`.

```
CONFIRMED: 1000 attacker offers fill pendingOffers cap; legitimate offer for a real request is dropped (RequestLease would time out after 30s)
```

**PoC 1b — targeted displacement / lease steering** (`TestMarketPendingOffers_LastWriteWinsAndStaleStored`): a legitimate offer (provider L, `TotalCost` 517\) for request `req-R` is stored; then an attacker's offer for the same `req-R` (different provider, `TotalCost` 9999, *older* timestamp) is fed — it **overwrites** the legitimate offer. `RequestLease` polls every 500 ms and returns whatever is in the map, so the consumer's `RequestAndCreateLease` builds the lease against the attacker's offer instead. The same test shows a 1-hour-old offer is stored for a fresh request ID — incoming offers are never freshness-checked.

```
CONFIRMED: later offer (different provider, 9999 vs 517, older ts) overwrote legit offer for same RequestID — single-slot map, no timestamp/price/matching check; RequestLease polls first-seen and would take the attacker's offer
CONFIRMED: offer with 1-hour-old timestamp is stored in pendingOffers (incoming offers are never freshness-checked)
```

**Supporting PoC — no account needed** (`TestMarketFlood_AttackerNeedsNoAccount`, in `market-net_test.go`, `go test ./net -run TestMarket -v -count=1` → PASS 6/6): 1000/1000 self-signed offers from a fresh, never-funded keypair all verify.

```
CONFIRMED: 1000/1000 self-signed offers from a fresh, never-funded keypair all verify — flood needs no account, stake, or prior request
```

## Root cause

`node/node.go`, `handleMarketplace` (offer case):

```
n.pendingOffersMu.Lock()
    cutoff := time.Now().Add(-60 * time.Second).UnixNano()
    for id, o := range n.pendingOffers {
        if o.Timestamp < cutoff { delete(n.pendingOffers, id) }  // prunes OLD entries only
    }
    if len(n.pendingOffers) < 1000 {
        n.pendingOffers[msg.Offer.RequestID] = msg.Offer   // unconditional overwrite
    }
n.pendingOffersMu.Unlock()
```

No outgoing-request tracking, no per-RequestID offer set or first-seen-wins, no freshness check on the incoming offer, and a hard cap that drops legitimate offers once full. The gossip entry (`net/gossip_validate.go`, `marketplaceValidator`) likewise applies no freshness or request-ownership check.

## Suggested fix

Track outgoing request IDs with an expiry; store offers only for requests this node issued; keep *all* offers per RequestID (or first-seen-wins) and let `RequestLease` pick (e.g. cheapest valid, or explicit provider choice); enforce a freshness window on `offer.Timestamp` (e.g. 60 s, matching the prune); rate-limit / per-provider cap on `pendingOffers` inserts; validate offer dims against the request before returning it.

## Controls verified (same PoC files, all PASS)

- 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`).
- `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).
- 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.
- Directory impersonation / registration replay is neutralised (monotonicity \+ 30 min TTL, `TestMarketDir_MonotonicityRejectsOldReplay`, `market-dir_test.go`).

[market-node\_test.txt](https://github.com/user-attachments/files/34781488/market-node_test.txt)
[market-net\_test.txt](https://github.com/user-attachments/files/34781486/market-net_test.txt)
[market-dir\_test.txt](https://github.com/user-attachments/files/34781487/market-dir_test.txt)

### Thread

**Joseph Denne**team2026-11-20 00:50 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0106, 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, file a new report that links https://bounty.xe.network/XE-13372 and says what differs; it is read like any other.
