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

plugin: nwc: improved budget accounting

Public commit record

What the developer wrote

Authored by f321x

68/100 · Adequate
plugin: nwc: improved budget accounting

Increase the payment budget before attempting the payment
and decrease again if the payment fails. This prevents a race
where multiple concurrent payments could pass the budget check
before the budget is incremented through any of the other payments.

A lock around the budget is not suitable either as then one long
stuck payment (hold invoice) would render the budget inaccessible for
all other payment attempts.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a race condition in Electrum's NWC (Nostr Wallet Connect) plugin that could let a user spend more than their daily budget. Previously, the plugin checked the budget before each payment but only recorded the spend after a payment succeeded. If several payments were started at the same time, they could all pass the budget check and collectively exceed the limit. The fix records the spend before attempting the payment and refunds it only if the payment fails. The commit message explicitly describes this as preventing a race condition.

Recommended action

Treat this as a security fix for the NWC plugin and include it in the next release. Users relying on NWC daily spending limits should upgrade. Review whether other asynchronous spend paths (e.g., other plugins, API endpoints) use similar check-then-record budget patterns and apply the same debit-first/refund-on-fail pattern if needed.

Security signals we found

01

Race condition in budget enforcement (check-then-act)

02

TOCTOU between budget check and budget recording

03

Concurrent payments could exceed configured daily spending limit

04

Fix moves budget debit before payment attempt and refunds on failure

05

Commit message explicitly describes the race and its security/financial consequence

Risk score

Why this scored 55/100

Our methodology →
Potential impact 12/30
Exploitability 14/25
Stealth signal 10/15
Affected reach 8/15
Confidence 7/10
Evidence quality 4/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.