Skip to content

Commit 59b771d

Browse files
committed
Add a MessageContext::DNSResolution to protect against probing
When we make a DNSSEC query with a reply path, we don't want to allow the DNS resolver to attempt to respond to various nodes to try to detect (through timining or other analysis) whether we were the one who made the query. Thus, we need to include a nonce in the context in our reply path, which we set up here by creating a new context type for DNS resolutions.
1 parent a661c92 commit 59b771d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ pub enum MessageContext {
284284
///
285285
/// [`AsyncPaymentsMessage`]: crate::onion_message::async_payments::AsyncPaymentsMessage
286286
AsyncPayments(AsyncPaymentsContext),
287+
/// Represents a context for a blinded path used in a reply path when requesting a DNSSEC proof
288+
/// in a [`DNSResolverMessage`].
289+
///
290+
/// [`DNSResolverMessage`]: crate::onion_message::dns_resolution::DNSResolverMessage
291+
DNSResolver(DNSResolverContext),
287292
/// Context specific to a [`CustomOnionMessageHandler::CustomMessage`].
288293
///
289294
/// [`CustomOnionMessageHandler::CustomMessage`]: crate::onion_message::messenger::CustomOnionMessageHandler::CustomMessage
@@ -402,6 +407,7 @@ impl_writeable_tlv_based_enum!(MessageContext,
402407
{0, Offers} => (),
403408
{1, Custom} => (),
404409
{2, AsyncPayments} => (),
410+
{3, DNSResolver} => (),
405411
);
406412

407413
impl_writeable_tlv_based_enum!(OffersContext,
@@ -428,6 +434,24 @@ impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
428434
},
429435
);
430436

437+
/// Contains a simple nonce for use in a blinded path's context.
438+
///
439+
/// Such a context is required when receiving a [`DNSSECProof`] message.
440+
///
441+
/// [`DNSSECProof`]: crate::onion_message::dns_resolution::DNSSECProof
442+
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
443+
pub struct DNSResolverContext {
444+
/// A nonce which uniquely describes a DNS resolution.
445+
///
446+
/// When we receive a DNSSEC proof message, we should check that it was sent over the blinded
447+
/// path we included in the request by comparing a stored nonce with this one.
448+
pub nonce: [u8; 16],
449+
}
450+
451+
impl_writeable_tlv_based!(DNSResolverContext, {
452+
(0, nonce, required),
453+
});
454+
431455
/// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`.
432456
pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
433457
secp_ctx: &Secp256k1<T>, intermediate_nodes: &[MessageForwardNode],

0 commit comments

Comments
 (0)