Skip to content

Commit 5485d1b

Browse files
committed
Don't apply NetworkUpdate from failed paths to NetworkGraph
If updates returned from failed paths are permanently applied to our graph in a manner observable to the rest of the network, malicious intermediaries may be able to fail HTLCs and infer the payment origin. Here, we therefore avoid permanent application of network updates and will rather switch to consider them temporarily for payment retries in the next step.
1 parent c86cacd commit 5485d1b

File tree

2 files changed

+9
-22
lines changed
  • lightning/src/events
  • lightning-background-processor/src

2 files changed

+9
-22
lines changed

lightning-background-processor/src/lib.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use lightning::chain;
2626
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
2727
use lightning::chain::chainmonitor::{ChainMonitor, Persist};
2828
use lightning::sign::{EntropySource, NodeSigner, SignerProvider};
29-
use lightning::events::{Event, PathFailure};
29+
use lightning::events::Event;
3030
#[cfg(feature = "std")]
3131
use lightning::events::{EventHandler, EventsProvider};
3232
use lightning::ln::channelmanager::ChannelManager;
@@ -226,16 +226,6 @@ where
226226
}
227227
}
228228

229-
fn handle_network_graph_update<L: Deref>(
230-
network_graph: &NetworkGraph<L>, event: &Event
231-
) where L::Target: Logger {
232-
if let Event::PaymentPathFailed {
233-
failure: PathFailure::OnPath { network_update: Some(ref upd) }, .. } = event
234-
{
235-
network_graph.handle_network_update(upd);
236-
}
237-
}
238-
239229
/// Updates scorer based on event and returns whether an update occurred so we can decide whether
240230
/// to persist.
241231
fn update_scorer<'a, S: 'static + Deref<Target = SC> + Send + Sync, SC: 'a + WriteableScore<'a>>(
@@ -636,9 +626,6 @@ where
636626
let logger = &logger;
637627
let persister = &persister;
638628
async move {
639-
if let Some(network_graph) = network_graph {
640-
handle_network_graph_update(network_graph, &event)
641-
}
642629
if let Some(ref scorer) = scorer {
643630
if update_scorer(scorer, &event) {
644631
log_trace!(logger, "Persisting scorer after update");
@@ -768,10 +755,6 @@ impl BackgroundProcessor {
768755
let stop_thread_clone = stop_thread.clone();
769756
let handle = thread::spawn(move || -> Result<(), std::io::Error> {
770757
let event_handler = |event| {
771-
let network_graph = gossip_sync.network_graph();
772-
if let Some(network_graph) = network_graph {
773-
handle_network_graph_update(network_graph, &event)
774-
}
775758
if let Some(ref scorer) = scorer {
776759
if update_scorer(scorer, &event) {
777760
log_trace!(logger, "Persisting scorer after update");

lightning/src/events/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,12 @@ pub enum PathFailure {
125125
},
126126
/// A hop on the path failed to forward our payment.
127127
OnPath {
128-
/// If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing
129-
/// decisions can take into account the update.
128+
/// If present, this [`NetworkUpdate`] can be applied to a [`NetworkGraph`] so that
129+
/// routing decisions can permanently take the update into account.
130+
///
131+
/// However, note that if applying the update is obversable to the rest of the network
132+
/// (e.g., through public gossip), it can introduce a privacy leak as malicious
133+
/// intermediaries may fail HTLCs and try to infer the payment's origin.
130134
///
131135
/// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
132136
/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
@@ -624,8 +628,8 @@ pub enum Event {
624628
/// the payment has failed, not just the route in question. If this is not set, the payment may
625629
/// be retried via a different route.
626630
payment_failed_permanently: bool,
627-
/// Extra error details based on the failure type. May contain an update that needs to be
628-
/// applied to the [`NetworkGraph`].
631+
/// Extra error details based on the failure type. May contain an update that can be
632+
/// applied to a [`NetworkGraph`].
629633
///
630634
/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
631635
failure: PathFailure,

0 commit comments

Comments
 (0)