Skip to content

Conversation

@zk-bits
Copy link

@zk-bits zk-bits commented Dec 21, 2025

Summary

The expiry check in mint() was using > instead of <, causing the mint to:

  • Reject valid quotes (where expiry is in the future)
  • Accept expired quotes (where expiry is in the past)

The Bug

quote.expiry is a Unix timestamp representing when the quote expires (set as invoice.date + invoice.expiry).

Previous (buggy) code:

if quote.expiry and quote.expiry > int(time.time()):
    raise TransactionError("quote expired")

This raises "quote expired" when quote.expiry > now, meaning when the expiry is in the future (quote is still valid).

Fixed code:

if quote.expiry and quote.expiry < int(time.time()):
    raise TransactionError("quote expired")

This correctly raises "quote expired" when quote.expiry < now, meaning when the expiry is in the past (quote has actually expired).

Impact

  • Severity: Denial of Service for mint operations
  • Not exploitable for fund theft because the quote.paid check at line 497 happens first, ensuring the Lightning invoice was actually paid before reaching the expiry check
  • Any mint with expiry set on quotes would reject all valid mint attempts

Test

Simple proof that the logic was inverted:

import time

# Quote created now with 1 hour expiry
quote_expiry = int(time.time()) + 3600
now = int(time.time())

# Buggy: quote_expiry > now = True → raises "quote expired" (WRONG - quote is valid!)
# Fixed: quote_expiry < now = False → quote is valid (CORRECT)

The expiry check was using > instead of <, which caused the mint to reject
valid quotes (expiry in the future) and accept expired quotes (expiry in
the past).

quote.expiry is a Unix timestamp representing when the quote expires.
The previous check `quote.expiry > int(time.time())` would evaluate to True
for valid quotes where expiry is in the future, incorrectly raising
"quote expired".

Changed to `quote.expiry < int(time.time())` which correctly identifies
expired quotes where the expiry timestamp is in the past.
@cloudsupper cloudsupper added the bug Something isn't working label Dec 22, 2025
@TheRealCheebs
Copy link
Contributor

Good find! I would include now as also an expired time, so update < to <= .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants