Commit message · auto-pr-botLSPS2: Release pruned pending requests from the total limit
The LSPS2 service counts unanswered `get_info`/`buy` requests in a global
`total_pending_requests` counter and refuses new requests from any peer
once it reaches `MAX_TOTAL_PENDING_REQUESTS`. When a peer disconnected,
its pending requests were dropped from the per-peer map by
`prune_pending_requests` without lowering the counter, so every request
still unanswered at disconnect permanently consumed one of the 1,000
global slots until the process restarted. A peer with throw-away node
keys could thus pin an LSP at the limit and refuse `lsps2.get_info` and
`lsps2.buy` to all clients, and ordinary clients that lost their
connection before being answered drifted the counter upward, too.
Have `prune_pending_requests` return how many entries it removed (the
same shape LSPS1's already has) and subtract that from the counter in
`peer_disconnected`, using the same saturating `fetch_update` and
out-of-sync `debug_assert!` idiom as `remove_pending_request`.
`peer_disconnected` is the only caller of `prune_pending_requests`, and
together with `remove_pending_request` this covers every removal from
`pending_requests`, so the counter stays in sync with the per-peer maps
as `verify_pending_request_counter` asserts.
Reported by Anthropic's OSS Scanner as ANT-2026-S58419MV and
independently by Erick Cestari.
@tnull asked:
> @auto-pr-bot please fix this, including in the commit message that
> this was reported by Anthropic's OSS Scanner, as ANT-2026-S58419MV.
>
> Release requests pruned in peer_disconnected from
> total_pending_requests, keeping the counter in sync with what
> prune_pending_requests removes. Add a regression test that fails
> without the fix.
Requested-by: @tnull
Authored-By: matt/GLM-5.3-Flash-GGUF:Q4_K_XL <goose@users.noreply.local>
83/100 · StrongMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
Why it was queuedaccess controlfuzzing or regression evidence
AI analysis · High 76/100This commit fixes a denial-of-service bug in the LSPS2 (Lightning Service Provider Specification 2) service code. The service tracks how many unanswered client requests it has globally and stops accepting new ones after 1,000. When a client disconnected before being answered, the per-client request list was cleaned up, but the global counter was not reduced. That meant every such request permanently consumed one of the 1,000 slots until the program restarted. An attacker could repeatedly connect, send a request, and disconnect to exhaust the slot limit, blocking legitimate clients from using the service. The fix makes the cleanup routine report how many requests it removed and subtracts that from the global counter when a peer disconnects. A regression test is included.