Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Proposal: Add support for proxying p2p connections to/from LND

5 messages, Sep 1 to 3, 2022. Started by Alex Akselrod.

Pierre (2), Alex Akselrod, Olaoluwa Osuntokun, Antoine Riard

Permalink First message in the Wayback Machine

Alex Akselrod permalink original

At NYDIG, we're considering ways to harden large LND deployments. Joost and I discussed that currently, when external untrusted peers make inbound connections, LND must verify the identity of the peer during the noise handshake, and it must do this before enforcing any potential key-based allow lists. This is done in the same process as the node's other critical tasks, such as monitoring the chain.

To reduce the attack area of the main node process, we'd like to propose a means to optionally separate the peer communication into a separate process: something like CLN's connectd, running separately, and the connections would be multiplexed over a single network connection initiated from the node to the proxy. The core of our current idea is demonstrated in a draft PR: https://github.com/lightningnetwork/lnd/pull/6843

I'd love some early feedback on the general direction of this. If this would be interesting, I'll build it out into a fully working feature.

Thanks,

Alex Akselrod

Olaoluwa Osuntokun in reply to Alex Akselrod permalink original

Hi Alex,

This is a super cool project! I've shared some thoughts here in a comment on the draft PR: PR: https://github.com/lightningnetwork/lnd/pull/6843#issuecomment-1234933319

Also I cc'd the lnd mailing list on this reply, perhaps we can move the discussion over there (or in the issue) since this is more of an lnd specific thing. In the future, the lnd mailing list is also probably a better place for lnd architecture specific proposals/discussions.

-- Laolu

On Thu, Sep 1, 2022 at 10:56 AM Alex Akselrod via Lightning-dev < lightning-dev at lists.linuxfoundation.org> wrote:

Quoted text (25 lines)
> At NYDIG, we're considering ways to harden large LND deployments. Joost
> and I discussed that currently, when external untrusted peers make inbound
> connections, LND must verify the identity of the peer during the noise
> handshake, and it must do this before enforcing any potential key-based
> allow lists. This is done in the same process as the node's other critical
> tasks, such as monitoring the chain.
>
> To reduce the attack area of the main node process, we'd like to propose a
> means to optionally separate the peer communication into a separate
> process: something like CLN's connectd, running separately, and the
> connections would be multiplexed over a single network connection initiated
> from the node to the proxy. The core of our current idea is demonstrated in
> a draft PR: https://github.com/lightningnetwork/lnd/pull/6843
>
> I'd love some early feedback on the general direction of this. If this
> would be interesting, I'll build it out into a fully working feature.
>
> Thanks,
>
> Alex Akselrod
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Antoine Riard in reply to Alex Akselrod permalink original

Hi Alex,

Let's say the adversary targeting your high-value "LiFi" infrastructure is a nation-state sponsored hacking-group with strong capabilities (as we're seeing today in the cryptocurrencies DeFi space). This hacking group avails hundreds of bitcoins to fund channels, is able to setup thousands of sybil peers across the base-layer p2p network, has built a fine-grained knowledge of the miner mempools, controls few Internet ASNs and has bought second-hands mining chips on the market to own limited hashing capabilities.

As of today, they would have a marked embarrassment on which attack pickup to target your Lightning infrastructure. They could start with an "old known" jamming attack to permanently cut your channel links from the rest of the wider network topology [0]. Or they could launch time-dilation attacks by building on BGP disruptions, until your chain view is so far in the past from the network tip that your on-chain HTLC-claiming safety reaction timers are useless [1]. Or they could exercise pinning attacks to prevent you to claim back routed HTLC, as a malicious commitment transaction sleeps in the network mempools until it's too far [2]. Or they could target your pre-0.24 Bitcoin Core full-node to provoke a memory crash thanks to a long-chain of low-work headers [3].

And I would say that's only a subset of the attack surface of a Lightning node.

Considering all those factors, moving a LN implementation architecture from a single, monolithic process towards a collection of processes, where the critical components of the LN active defense security model are replicated and distributed, redundant access to the chain view guaranteed, sandboxing access between processes enforced and data flow monitored to react on anomalies, all things your #6843 would make easier, sounds a reasonable direction. I think it's needed if you aim for your infrastructure to survive strong attacks.

On the LDK-side, inheriting from the adversarial thinking and safety-first mindset development culture from Bitcoin Core, we've always considered that type of scenarii since the early days and designed our software in consequence. We have been working and we'll keep working on many security/safety hardening: external signing [4], replicated chain monitoring [5], dynamic fee-bumping of time-sensitive transactions, various attack vectors mitigations [6]. All that said, we're looking forward to collaborate with the wider Lightning community on reusable security modules across implementations (e.g jamming mitigations) and wished "fix-the-annoying-holes" changes in Bitcoin Core (e.g package relay).

Cheers, Antoine

[0] https://jamming-dev.github.io/book/ [1] https://arxiv.org/abs/2006.01418 [2] https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2020/pinning-the-good-the-bad-the-ugly#m-c840eb2c [3] https://github.com/bitcoin/bitcoin/pull/25717 [4] https://github.com/lightningdevkit/rust-lightning/pull/214 [5] https://github.com/lightningdevkit/rust-lightning/pull/679 [6] https://github.com/lightningdevkit/rust-lightning/pull/1009

Le jeu. 1 sept. 2022 à 13:56, Alex Akselrod via Lightning-dev < lightning-dev at lists.linuxfoundation.org> a écrit :

Quoted text (25 lines)
> At NYDIG, we're considering ways to harden large LND deployments. Joost
> and I discussed that currently, when external untrusted peers make inbound
> connections, LND must verify the identity of the peer during the noise
> handshake, and it must do this before enforcing any potential key-based
> allow lists. This is done in the same process as the node's other critical
> tasks, such as monitoring the chain.
>
> To reduce the attack area of the main node process, we'd like to propose a
> means to optionally separate the peer communication into a separate
> process: something like CLN's connectd, running separately, and the
> connections would be multiplexed over a single network connection initiated
> from the node to the proxy. The core of our current idea is demonstrated in
> a draft PR: https://github.com/lightningnetwork/lnd/pull/6843
>
> I'd love some early feedback on the general direction of this. If this
> would be interesting, I'll build it out into a fully working feature.
>
> Thanks,
>
> Alex Akselrod
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Pierre in reply to Alex Akselrod permalink original

Hi Alex,

This is quite similar to eclair's cluster mode [1] so I can definitely say it's a great idea :-)

Our rationale was as much reducing the attack surface (we didn't like our node being directly accessible from the internet) as improving scalability (handling the constant flow of connections/disconnections from mobile wallets, and a ton of gossip).

Some specific points on our implementation: - there can be N instances of proxy and their number can be adjusted without downtime - our proxy also does preprocessing for gossip (they keep an up-to-date copy of routing table and directly answer queries, and also dedup incoming announcements before forwarding to the backend, where the announcements are verified) - outgoing connections (initiated by an operator from the backend) are also initiated by the proxy. Even incoming connections from Tor are directed to the proxy. The backend node handles zero LN connections - since the front needs the node key for the secure handshake, this led us to introduce a separate key hierarchy for channel management [2] - we have considered, but not implemented, a "lockdown mode" where the front would only allow incoming connections from known peers that already have a channel - if your setup has a separate db server (e.g. postgres), and logs are properly rotated/streamed out, then the resources that typically run out when scaling up (file descriptors, disk space, etc.) should be really under control on your main node

Hope that helps,

Pierre

[1] https://github.com/ACINQ/eclair/blob/master/docs/Cluster.md
[2] https://github.com/ACINQ/eclair/pull/1584

Le jeu. 1 sept. 2022 à 19:56, Alex Akselrod via Lightning-dev < lightning-dev at lists.linuxfoundation.org> a écrit :

Quoted text (25 lines)
> At NYDIG, we're considering ways to harden large LND deployments. Joost
> and I discussed that currently, when external untrusted peers make inbound
> connections, LND must verify the identity of the peer during the noise
> handshake, and it must do this before enforcing any potential key-based
> allow lists. This is done in the same process as the node's other critical
> tasks, such as monitoring the chain.
>
> To reduce the attack area of the main node process, we'd like to propose a
> means to optionally separate the peer communication into a separate
> process: something like CLN's connectd, running separately, and the
> connections would be multiplexed over a single network connection initiated
> from the node to the proxy. The core of our current idea is demonstrated in
> a draft PR: https://github.com/lightningnetwork/lnd/pull/6843
>
> I'd love some early feedback on the general direction of this. If this
> would be interesting, I'll build it out into a fully working feature.
>
> Thanks,
>
> Alex Akselrod
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Pierre in reply to Alex Akselrod permalink original

Hi Alex,

This is quite similar to eclair's cluster mode [1] so I can definitely say it's a great idea :-)

Our rationale was as much reducing the attack surface (we didn't like our node being directly accessible from the internet) as improving scalability (handling the constant flow of connections/disconnections from mobile wallets, and a ton of gossip).

Some specific points on our implementation: - there can be N instances of proxy and their number can be adjusted without downtime - our proxy also does preprocessing for gossip (they keep an up-to-date copy of routing table and directly answer queries, and also dedup incoming announcements before forwarding to the backend, where the announcements are verified) - outgoing connections (initiated by an operator from the backend) are also initiated by the proxy. Even incoming connections from Tor are directed to the proxy. The backend node handles zero LN connections - since the front needs the node key for the secure handshake, this led us to introduce a separate key hierarchy for channel management [2] - we have considered, but not implemented, a "lockdown mode" where the front would only allow incoming connections from known peers that already have a channel - if your setup has a separate db server (e.g. postgres), and logs are properly rotated/streamed out, then the resources that typically run out when scaling up (file descriptors, disk space, etc.) should be really under control on your main node

Hope that helps,

Pierre

[1] https://github.com/ACINQ/eclair/blob/master/docs/Cluster.md
[2] https://github.com/ACINQ/eclair/pull/1584

Le jeu. 1 sept. 2022 à 19:56, Alex Akselrod via Lightning-dev < lightning-dev at lists.linuxfoundation.org> a écrit :

Quoted text (25 lines)
> At NYDIG, we're considering ways to harden large LND deployments. Joost
> and I discussed that currently, when external untrusted peers make inbound
> connections, LND must verify the identity of the peer during the noise
> handshake, and it must do this before enforcing any potential key-based
> allow lists. This is done in the same process as the node's other critical
> tasks, such as monitoring the chain.
>
> To reduce the attack area of the main node process, we'd like to propose a
> means to optionally separate the peer communication into a separate
> process: something like CLN's connectd, running separately, and the
> connections would be multiplexed over a single network connection initiated
> from the node to the proxy. The core of our current idea is demonstrated in
> a draft PR: https://github.com/lightningnetwork/lnd/pull/6843
>
> I'd love some early feedback on the general direction of this. If this
> would be interesting, I'll build it out into a fully working feature.
>
> Thanks,
>
> Alex Akselrod
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>