Skip to content

Commit 4b85b28

Browse files
committed
Add support for network message padding (option_message_padding)
Previous research [1], [2] has shown that the Lightning Network is susceptible to passive network-layer attacks on privacy that can exploit metadata leaking from transmitted network messages. While other factors such as timing come into play, the most severe information leakage is due to the fact that a passive adversary monitoring the Noise-encrypted network traffic can still observe clearly distinguished network message sizes, which allows them to reliably classify messages by type, and therefore in turn allows them to draw conclusions on node behavior. In the worst case, this allows a purely passive off-path adversary able to monitor traffic of multiple nodes on a payment path to not only observe *that* a payment took place, but also to identify the payment's endpoints. To mitigate the information leakage coming from observable network message sizes, we here propose the introduction of `option_message_padding`, a simple protocol that allows Lightning counterparties to opt into padding network messages to fixed size thresholds large enough to cover `update_add_htlc` messages by including suitably sized TLV records in all sent TLV stream `extension`s. This approach will lead to uniform message size distribution for 'normal' day-to-day operations. Note however that messages beyond the chosen size threshold will still stand out and leak some amount of information. Moreover, note that we abstained from including padding for custom messages, as it's not guaranteed that all application-layer protocols are able to handle TLV streams according to 'it's-okay-to-be-odd' rules (see [3] for some questions around that). [1]: https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/611970/paper.pdf [2]: https://drops.dagstuhl.de/storage/00lipics/lipics-vol316-aft2024/LIPIcs.AFT.2024.12/LIPIcs.AFT.2024.12.pdf [3]: #1302
1 parent 0cf2151 commit 4b85b28

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

01-messaging.md

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ All data fields are unsigned big-endian unless otherwise specified.
2626
* [The `error` and `warning` Messages](#the-error-and-warning-messages)
2727
* [Control Messages](#control-messages)
2828
* [The `ping` and `pong` Messages](#the-ping-and-pong-messages)
29+
* [Network Message Padding](#network-message-padding)
2930
* [Peer Storage](#peer-storage)
3031
* [The `peer_storage` and `peer_storage_retrieval` Messages](#the-peer_storage-and-peer_storage_retrieval-messages)
3132
* [Appendix A: BigSize Test Vectors](#appendix-a-bigsize-test-vectors)
@@ -130,10 +131,11 @@ messages, a `tlv_stream` is typically placed after all currently defined fields.
130131
The `type` is encoded using the BigSize format. It functions as a
131132
message-specific, 64-bit identifier for the `tlv_record` determining how the
132133
contents of `value` should be decoded. `type` identifiers below 2^16 are
133-
reserved for use in this specification. `type` identifiers greater than or equal
134-
to 2^16 are available for custom records. Any record not defined in this
135-
specification is considered a custom record. This includes experimental and
136-
application-specific messages.
134+
reserved for use in this specification. `type` identifiers greater than or
135+
equal to 2^16 are available for custom records (except 2^64-1, which is
136+
reserved for message padding). Any record not defined in this specification is
137+
considered a custom record. This includes experimental and application-specific
138+
messages.
137139

138140
The `length` is encoded using the BigSize format signaling the size of
139141
`value` in bytes.
@@ -504,6 +506,64 @@ every message maximally).
504506
Finally, the usage of periodic `ping` messages serves to promote frequent key
505507
rotations as specified within [BOLT #8](08-transport.md).
506508

509+
## Network Message Padding
510+
511+
Peers that negotiate `option_message_padding` agree to pad transmitted network
512+
message sizes to obfuscate the length of the original payload.
513+
514+
To this end, they append a TLV record with type `18446744073709551615`
515+
(BigSize/`u64` maximum value) in the `extension` [TLV
516+
stream](#type-length-value-format) of all messages following `Init`.
517+
518+
1. `tlv_stream`: `padding_tlvs`
519+
2. types:
520+
1. type: `18446744073709551615` (`padding_type`)
521+
2. data:
522+
* [`length*bytes`:`padding_bytes`]
523+
524+
### Requirements:
525+
526+
A sending node that negotiated `option_provide_storage`:
527+
528+
- SHOULD append a TLV record of `padding_type` in all sent Lightning messages if their type is less than `32768`.
529+
- MUST NOT apply padding to custom messages (i.e., any with types `32768`-`65535`).
530+
- SHOULD choose the size of `padding_bytes` so that all sent messages have a fixed payload size >= 1452 bytes pre-encryption (1486 bytes post).
531+
532+
A receiving node that negotiated `option_provide_storage`:
533+
534+
- SHOULD ignore and discard the `padding_bytes` data.
535+
536+
### Rationale:
537+
Unpadded network messages might, even though Noise-encrypted, leak information
538+
about their contents to observing third parties. Therefore, it's in order to
539+
minimize the information leakage by padding any transmitted network messages to
540+
the same target size, reaching a uniform distribution of network message sizes.
541+
542+
The `padding_type` was chosen to be odd to allow receivers to trivially ignore
543+
and discard them according to 'it's-okay-to-be-odd' rules in a
544+
backwards-compatible manner. It was furthermore chosen to be the BigSize/`u64`
545+
maximum value to allow senders to append the padding TLV record as a last step
546+
without infringing on the `tlv_stream` ordering requirements Note that the
547+
padding MUST NOT be applied to custom messages as it's not guaranteed that all
548+
application layer protocols are able to handle a TLV `extension` and apply
549+
'it's-okay-to-be-odd' rules.
550+
551+
While the specific padding strategies/thresholds employed are left to
552+
implementations, they SHOULD pad all messages sizes to fixed values that cover
553+
the largest message sizes during payment activity: In the base case, a
554+
serialized `update_add_htlc` message is 1452 bytes: 2 (`type`) + 32
555+
(`channel_id`) + 8 (`htlc_id`) + 8 (`amount_msat`) + 32 (`payment_hash`) + 4
556+
(`cltv_expiry`) + 1366 (`onion_routing_packet`). The Noise encryption step then
557+
adds 2 (encrypted message length) + 16 (encrypted message length MAC) bytes +
558+
16 (encrypted message MAC), resulting in 1486 bytes TCP payload. Therefore
559+
implementations SHOULD pad all messages resulting in uniform message sizes of
560+
of 1452 bytes pre- or 1486 post-encryption.
561+
562+
Note however that this base case doesn't take into account any of the optional
563+
fields on `update_add_htlc`, so implementations might choose to set larger
564+
padding threshold to have `update_add_htlc` messages not stand out if any of
565+
these fields are included.
566+
507567
## Peer storage
508568

509569
### The `peer_storage` and `peer_storage_retrieval` Messages

09-features.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The Context column decodes as follows:
5555
| 48/49 | `option_payment_metadata` | Payment metadata in tlv record | 9 | | [BOLT #11](11-payment-encoding.md#tagged-fields) |
5656
| 50/51 | `option_zeroconf` | Understands zeroconf channel types | INT | `option_scid_alias` | [BOLT #2][bolt02-channel-ready] |
5757
| 60/61 | `option_simple_close` | Simplified closing negotiation | IN | `option_shutdown_anysegwit` | [BOLT #2][bolt02-simple-close] |
58+
| 64/65 | `option_message_padding` | Network message padding | I | | [BOLT #1][bolt01-network-message-padding] |
5859

5960
## Requirements
6061

@@ -97,6 +98,7 @@ known to be set, and do not need to be validated at every feature gate.
9798
<br>
9899
This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).
99100

101+
[bolt01-network-message-padding]: 01-messaging.md#network-message-padding
100102
[bolt02-retransmit]: 02-peer-protocol.md#message-retransmission
101103
[bolt02-open]: 02-peer-protocol.md#the-open_channel-message
102104
[bolt02-simple-close]: 02-peer-protocol.md#closing-negotiation-closing_complete-and-closing_sig

0 commit comments

Comments
 (0)