Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fee limits for LND and LDK, isolated balance calculation #937

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

rolznz
Copy link
Contributor

@rolznz rolznz commented Jan 5, 2025

There are two isolated app (subwallet) vulnerabilities fixed in this PR:

  • use signed integers in isolated app balance calculation to prevent integer overflow
  • enforce fee limits when making payments

TESTING:

  • LDK: I made 3 nodes, and could pay from A -> C through B, when B sets the routing fee for channel A->B at 10 sats, but fails when B sets the routing fee for channel A->B at 11 sats. Changing back to 10 sats works again. Max fee calculation uses the same code as the transaction service (which is used for isolated apps and budgets).

11 sats:

2025-01-05 08:33:37 TRACE [lightning::routing::router:3230] Ignored 0 candidate hops due to insufficient value contribution, 0 due to path length limit, 0 due to CLTV delta limit, 0 due to previous payment failure, 0 due to htlc_minimum_msat limit, 0 to avoid overpaying, 2 due to maximum total fee limit. Total: 2 ignored candidates.
2025-01-05 08:33:37 ERROR [lightning::ln::outbound_payment:997] Failed to find route for payment with id 8a5ecf53b069559f9c6e318a64fc2984d2f0931101170e60f581e7a1161521e6 and hash 8a5ecf53b069559f9c6e318a64fc2984d2f0931101170e60f581e7a1161521e6
2025-01-05 08:33:37 ERROR [ldk_node::payment::bolt11:160] Failed to send payment: RouteNotFound

10 sats:

2025-01-05 08:35:25 INFO  [lightning::routing::router:3391] Got route: path 0:
 node_id: 0314565c4af998c238a1d286e1feac4e4cd76bc416084096b26d8611f0546e6727, short_channel_id: 1918308041376202752, fee_msat: 10000, cltv_expiry_delta: 72
 node_id: 028052a3659267de42e7e127925594cd5a0cfb2f39563599aff3dc97fc07783d86, short_channel_id: 1918339927213408257, fee_msat: 1000, cltv_expiry_delta: 24
 blinded_tail: None
  • LND (same as above, with polar, using lncli updatechanpolicy --base_fee_msat 11000 --chan_point ccd6e82c4d55c0be3a6ff4622a7b213b4aa01f 7ce504b44c1dbce5b306dd5f3a:0 --fee_rate 0 --time_lock_delta 18 the payment cannot be sent, but with lncli updatechanpolicy --base_fee_msat 10000 --chan_point ccd6e82c4d55c0be3a6ff4622a7b213b4aa01f 7ce504b44c1dbce5b306dd5f3a:0 --fee_rate 0 --time_lock_delta 18 the payment can be sent)

  • Balances: I manually edited one of my sent transactions on an isolated app to have a huge fee. I correctly see a negative balance and cannot make payments. nwc get_balance and HTTP API return correct value for negative balances.

@rolznz rolznz added this to the v1.12.1 milestone Jan 5, 2025
@rolznz rolznz merged commit 188e7c6 into master Jan 6, 2025
9 checks passed
@rolznz rolznz deleted the fix/fee-limits branch January 6, 2025 16:08
@rolznz rolznz modified the milestones: v1.12.1, v1.13.0 Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant