AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 40 Bitcoin

submarine_swaps: use dict instead of defaultdict for dm_replies

Public commit record

What the developer wrote

Authored by ThomasV

50/100 · Thin
submarine_swaps: use dict instead of defaultdict for dm_replies
✓ Specific, descriptive subject✓ Names a concrete action or component! No meaningful explanatory body
The short version

What changed, and why it matters

This commit changes how Electrum's submarine swap feature tracks expected direct-message replies from Nostr relays. Previously, accessing any unknown reply ID would automatically create a placeholder 'Future' object. Now, only the client creates a Future for a specific request it sent, and only the client resolves replies, with checks that the reply ID is known. This prevents a potential issue where a malicious or buggy relay/server could create or manipulate placeholder reply entries by sending crafted messages.

Recommended action

Review whether any other defaultdict(asyncio.Future) patterns exist in the codebase that could allow implicit object creation from untrusted input. Consider adding regression tests for malformed reply_to handling in NostrTransport. No immediate emergency action is indicated by the diff alone.

Security signals we found

01

Change from defaultdict to plain dict prevents implicit object creation on arbitrary keys

02

Adds is_server guard so only clients process reply_to responses

03

Adds membership check before setting Future result, avoiding KeyError and unintended entry creation

04

Client explicitly creates Future for its own request before awaiting, tying lifecycle to outbound request

Risk score

Why this scored 40/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 6/15
Affected reach 5/15
Confidence 6/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.