Lightning for Builders Security and next steps

Security and privacy of the Lightning Network

What an attacker can learn or break: probe a route's hidden balance yourself, then survey jamming, fee attacks and the defences.

45 minIntermediate16 / 17

Draft: this lesson is still waiting for review.

What you'll learn

  • Explain how probing reveals channel balances that gossip keeps private
  • Find a route's limit by binary search with fake payments
  • Describe channel jamming and other attacks, and the main defences

Key terms

probing (kupima kwa majaribio)
Sending payments that cannot complete to learn whether a route has enough liquidity.
HTLC
Hash time-locked contract: a payment that unlocks only with the right secret before a deadline.
liquidity (ukwasi)
How much can be sent (outbound) or received (inbound) over a channel.

Lightning is private by design: balances aren't gossiped, and onions hide senders and receivers. But privacy here is a matter of degree, and a curious or hostile node has tricks.

Probing

Alice can send Dina a payment with a random payment hash. It can never settle, because nobody knows the preimage. Look at how it fails:

  • If it reaches Dina, she says "I don't know this payment" (incorrect_payment_details).
  • If a channel on the way is too small, a node says so earlier.

So each failure answers a yes-or-no question: can this amount get through? Ask enough questions and you learn a channel's balance. That is probing.

Probe a route's balance

These exercises need a laptop with the lab running. You can read the lesson on your phone.

Your binary search should land within 20,000 sats of the route's real limit, without ever paying a sat.

Other attacks

  • Channel jamming. An attacker sends many payments to themselves and never settles them, filling channels' HTLC slots (483 per side) or locking up liquidity until the time locks expire. Proposed defences include upfront fees and reputation for peers.
  • Fee and timelock manipulation. An attacker can try to make an HTLC expire before it can be claimed on-chain when fees are high. Anchor outputs let nodes raise fees on their closing transactions.
  • Privacy leaks. Your node's public channels, aliases and on-chain funding outputs can be linked to you. Private channels, onion services (Tor) and careful coin selection help.
  • Eclipse attacks. A node fed only by attacker-controlled peers can be shown a false view of the chain. Connect to several honest Bitcoin nodes.

Reflect

Write your answer down, or talk it over with a friend or your chama.

  1. If anyone can probe your balances, what does that mean for a shop's privacy?
  2. Why are jamming attacks hard to stop without making honest payments cost more?

Check yourself

Question 1 of 4Why can a probe payment never complete?

Further reading

Adapted from Mastering the Lightning Network. Andreas M. Antonopoulos, Olaoluwa Osuntokun and René Pickhardt. Licence: CC BY-SA 4.0.