Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Preventing MITM - Providing new nodes with real pubkeys

14 messages, Oct 16 to 20, 2015. Started by Mats Jerratsch.

Mats Jerratsch (5), Rusty Russell (4), Anthony Towns (4), Peter Todd

Permalink First message in the Wayback Machine

Mats Jerratsch permalink original

So being done with encryption and authentication, the next layer for me now is to figure out how exactly nodes will broadcast their existence and open channels and everything.

The one problem that we have currently with the way encryption and authentication works, is that the encryption layer is not protecting against MITM attacks, such that an attacker could have a connection with both and establish different encryption with both and just reads and relays all the data.

This gets defeated with the agreed-on authentication layer, where both nodes sign a message with their real pubkey and the temp pubkey of the party they are talking to, where a MITM could not produce these signatures. However, this only holds true if the nodes actually know the pubkey of the node they want to talk to. Which raises the point of - how do we bring this information across securely? A new node joining the network and obtaining one/some IP of another network participant will want to get a list with nodes/pubkeys/IPs. Without a central authority that could provide trust into the data, an attacker could trick it into a fake network, even if just for vandalism. (Having peer discovery trust on some hardcoded nodes to obtain IP addresses is dangerous enough, we don't want to rely on that for pubkeys as well)

There are some possibilities how to mitigate the risk / make an attack expensive

(1) Have a snapshot of the data hashed and linked to the blockchain. Similar to the way 'Factom' works. It would provide the data with some integrity framework, but keeping track of the changes would require some overhead. Without a central service it would further be difficult to establish who should make these linking transactions to the blockchain...

(2)
As long as the malleability issue has not been fixed, the blockchain
can only used with additional techniques to obtain a map of the
channels from it. As the anchor transactions are P2SH, we need to
expose the script, such that others are able to verify we at least
have an anchor tx on the blockchain (associated with costs after all).
For the current form it would be enough to have
SecretAHash || KeyB' || KeyB || KeyA || TxID || SignatureB (L=231B)
with KeyB being the node pubkey (lots of key reusage...)
or
SecretAHash || KeyB' || KeyB || KeyA || TxID || nodePubKey ||
SignatureB (L=264B) with KeyB as a channel key that does not need to
be equal with the nodePubKey.

This is information everyone should store in case a new node joins a network, similar to the blockchain. New nodes can then check against the blockchain, whether this data is actually present there. An attacker can fake a complete network together with lots of transactions on the blockchain, but the incentive is low (vandalism) and the costs are high. For 100k nodes and 10 open channels per node, this adds up to 220MB. Not too bad, considering full nodes are highly incentivised to run full bitcoin nodes as well, it is actually rather negligible. This information is pretty static, however we want everyone to have a decently consistent view of the network, so we would probably do some rebroadcast of that every few days, just to ensure everyone knows about it.

(3) Similar to (2), but instead of broadcasting our script we add a OP_RETURN output to each anchor transaction. It is cheap to implement it, as we don't have to broadcast anything specific to this issue. It is more expensive to attack, but also more expensive to open up a new channel. And it doesn't help scaling either, so I tend to dislike this idea.

(4) Start with one node and just go through a lot of different IP addresses you get from that node and repeat over and over and compare what the different nodes are telling you about the system. We can always add this technique on top of the other 3, and add IP addresses as an additional cost vector for a successful attack. If most of the IP addresses the first node gave you are dead, you can assume he gave you wrong information about the network and start again with another node.

As I'm implementing broadcast messages anyways for other purposes (see other ML post), I tent to like (2) the most, it is the most expensive to attack as well I think.

Mats Jerratsch

Rusty Russell in reply to Mats Jerratsch permalink original

Mats Jerratsch <matsjj at gmail.com> writes:

Quoted text (3 lines)
> So being done with encryption and authentication, the next layer for
> me now is to figure out how exactly nodes will broadcast their
> existence and open channels and everything.

Hi Mats,

        Thanks for bringing this on-list!
Quoted text (6 lines)
> (2)
> As long as the malleability issue has not been fixed, the blockchain
> can only used with additional techniques to obtain a map of the
> channels from it. As the anchor transactions are P2SH, we need to
> expose the script, such that others are able to verify we at least
> have an anchor tx on the blockchain (associated with costs after all).

This makes some sense (though the anchor transactions don't need to be P2SH, it's nicer for bitcoin's UTXO if they are).

Quoted text (7 lines)
> For the current form it would be enough to have
> SecretAHash || KeyB' || KeyB || KeyA || TxID || SignatureB (L=231B)
> with KeyB being the node pubkey (lots of key reusage...)
> or
> SecretAHash || KeyB' || KeyB || KeyA || TxID || nodePubKey ||
> SignatureB (L=264B) with KeyB as a channel key that does not need to
> be equal with the nodePubKey.

Yes, I think avoiding key reuse is good. So, to be clear, the anchor TX output looks like:

        P2SH (2 KEYA KEYB 2 OP_CHECKMULTISIG)

To prove we control KEYA, we simply need to sign something with it (our nodePubKey):

        KEYA NODE-PUBKEY TXID SIGNATURE

I think we can do slightly better with Schnorr signatures (which you can simply do multisig by addition, if I understand correctly) where both parties cooperate to form:

        KEYA KEYB NODE-PUBKEYA NODE-PUBKEYB TXID DUAL-SIGNATURE

That's 33+33+33+33+32+64 = 228 bytes per channel.

Later on, we can send SPV proofs for TXID.

Quoted text (12 lines)
> This is information everyone should store in case a new node joins a
> network, similar to the blockchain. New nodes can then check against
> the blockchain, whether this data is actually present there. An
> attacker can fake a complete network together with lots of
> transactions on the blockchain, but the incentive is low (vandalism)
> and the costs are high. For 100k nodes and 10 open channels per node,
> this adds up to 220MB. Not too bad, considering full nodes are highly
> incentivised to run full bitcoin nodes as well, it is actually rather
> negligible. This information is pretty static, however we want
> everyone to have a decently consistent view of the network, so we
> would probably do some rebroadcast of that every few days, just to
> ensure everyone knows about it.

Also, once a node is live, I'm not sure how much of the map it will need to keep. It might be able to prune distant parts of the map randomly, and get it back from the rest of the network if needed? Requires more thought, though.

Quoted text (3 lines)
> As I'm implementing broadcast messages anyways for other purposes (see
> other ML post), I tent to like (2) the most, it is the most expensive
> to attack as well I think.

I agree. Least on-chain spam.

Thanks! Rusty.

Anthony Towns in reply to Mats Jerratsch permalink original

On Fri, Oct 16, 2015 at 02:22:25PM +0100, Mats Jerratsch wrote:

Quoted text (1 line)
> [...] an attacker could trick it into a fake network, [...]

How do you tell the difference between the "real" network and a "fake" one? (ie, what does a Turing test for the lightning network look like?)

I think there's two things:

 1) you can figure out a route to people you want to pay (and
    vice-versa)
 2) payments on those routes actually go through

Even better, you can test this! Get a couple of merchant ids you find interesting, and pay 1 satoshi to each of them, setting the R value as the (double) SHA256 of the decrypted onion message. [0]

If you spent 1 satoshi to each of 10 merchants every day for a year to verify connectivity, that'd still only amount to about $0.01 USD total at current exchange rates, so it seems pretty affordable. [1]

It only works if you actually setup a channel, though -- so you have to lock some money into the channel for however many confirmations until the channel activates, before you can test, plus the OP_CSV delay if the test fails.

But I think that would let people trustlessly avoid "fake" lightning networks, even with a sybil-esque attack; no extra infrastructure needed.

Cheers, aj

[0] If you're already on the lightning network, and you're establishing
    a new channel as backup, you can just pay yourself 1 satoshi to verify
    connectivity. If you have friends on lightning, you could pay them
    1 satoshi to verify connectivity rather than a random merchant too.
[1] Hmm, does forwarding 1 satoshi (2.6 10,000ths of a cent) make
    sense, or would the CPU cycles cost more than the fees you'd make?
    How much does it cost to forward a transaction? In python on my
    laptop, I get about 1000 ECDH operations per second in python, and
    290k AES ops over a 3kB onion per second, and about 77k SHA256 ops
    per second. So just counting elliptic ops, forwarding a transaction
    requires three ops: an ECDH on the onion message, and an ECDSA on
    the commitment transaction to add the HTLC, and another sometime
    later to remove it.  So say 1/350th of a CPU-second. My linode costs
    3c/hour and seems to be about half as fast on the SHA256 test, but
    gives me two CPUs which evens it out. So so 3/60/60/350 cents is
    about the cost of forwarding a single transaction, which is about
    2.4e-8 dollars, which is currently about 9.1e-11 bitcoin, which
    is 0.0091 satoshi. Conveniently lightning balances are denominated
    in millisatoshi, so as long as yours increases by 9 or 10, you're
    doing fine. 10 millisatoshi is 1% of 1 satoshi, so that seems like
    the right order of magnitude.
Anthony Towns in reply to Rusty Russell permalink original

On Sat, Oct 17, 2015 at 07:20:30AM +1030, Rusty Russell wrote:

Quoted text (1 line)
>         KEYA KEYB NODE-PUBKEYA NODE-PUBKEYB TXID DUAL-SIGNATURE

AFAICS, to have a lightning channel between NODE-A and NODE-B, you just have to have a way for those two people to be comfortable writing IOUs to each other. HTLCs and commitments spending anchor transactions on the blockchain is one way to do this, but you could also do it on a pegged sidechain, or, if the two parties trusted each other, you could do it with literal IOUs written on bits of paper. I'm not sure we want to block people from doing those things?

Also, if you're only doing dual-signature, not quad-signature, I think it's open to creating fake edges in the routing graph: ie, I make up to keys AJ1 and AJ2, and publish a multisig transaction in the blockchain, then claim there's a route between RUSTY and MATS by publishing

    AJ1 AJ2 RUSTY MATS TX <SIG:AJ1 AJ2>

Then when Alice wants to route to Bob, she decides to use that edge, and her transaction fails because it doesn't exist.

(If you just sign with RUSTY and MATS, obviously you can claim to have a route just by referencing any multisig transaction that you know the pubkeys of)

Quoted text (6 lines)
> > For 100k nodes and 10 open channels per node,
> > this adds up to 220MB. [...]
> Also, once a node is live, I'm not sure how much of the map it will need
> to keep.  It might be able to prune distant parts of the map randomly,
> and get it back from the rest of the network if needed?  Requires more
> thought, though.

Well, we could not worry about it until there are >10k nodes; and then we'd have actual data as well?

Cheers, aj

Mats Jerratsch in reply to Rusty Russell permalink original
Quoted text (2 lines)
> This makes some sense (though the anchor transactions don't need to be
> P2SH, it's nicer for bitcoin's UTXO if they are).

Well, currently there is no one working on a malleability fix, so we should probably work forwards the next available goal. ;)

Quoted text (12 lines)
>> For the current form it would be enough to have
>> SecretAHash || KeyB' || KeyB || KeyA || TxID || SignatureB (L=231B)
>> with KeyB being the node pubkey (lots of key reusage...)
>> or
>> SecretAHash || KeyB' || KeyB || KeyA || TxID || nodePubKey ||
>> SignatureB (L=264B) with KeyB as a channel key that does not need to
>> be equal with the nodePubKey.
>
> Yes, I think avoiding key reuse is good.  So, to be clear, the anchor TX
> output looks like:
>
>         P2SH (2 KEYA KEYB 2 OP_CHECKMULTISIG)

Having to deal with malleability, the only viable solution for anchor transactions are with escape and fast-escape?

Quoted text (7 lines)
> I think we can do slightly better with Schnorr signatures (which you can
> simply do multisig by addition, if I understand correctly) where both
> parties cooperate to form:
>
>         KEYA KEYB NODE-PUBKEYA NODE-PUBKEYB TXID DUAL-SIGNATURE
>
> That's 33+33+33+33+32+64 = 228 bytes per channel.

Interesting, I kinda feel uncomfortable with Schnorr though. It feels like some experimental method, and at least for Java, there are very few implementations around (and I don't feel comfortable implementing it on my own either..)

I like the idea of adding together one object for the channel to be sent by both nodes. Even without Schnorr it saves some bytes and the overhead of gossipping.. We can always switch the signature to Schnorr too..

Quoted text (10 lines)
> Also, once a node is live, I'm not sure how much of the map it will need
> to keep.  It might be able to prune distant parts of the map randomly,
> and get it back from the rest of the network if needed?  Requires more
> thought, though.
>
>> As I'm implementing broadcast messages anyways for other purposes (see
>> other ML post), I tent to like (2) the most, it is the most expensive
>> to attack as well I think.
>
> I agree.  Least on-chain spam.

Well, all nodes can always refuse to participate in the gossip network anyway by just never requesting data and never relaying anything either. For a lot of things, it is very similar to the whole blockchain. Important to keep at some points, most of it is throw-away for individual nodes already participating in the network though.. But I don't see this a problem anywhere soon..

Cheers, Mats

Mats Jerratsch in reply to Anthony Towns permalink original
Quoted text (4 lines)
> It only works if you actually setup a channel, though -- so you have to
> lock some money into the channel for however many confirmations until
> the channel activates, before you can test, plus the OP_CSV delay if
> the test fails.

And there's the catch. If an attacker achieves nodes opening up channels with him, he already succeeded in vandalism. Furthermore, an attacker can always play by the rules and forward all payments up to one point where he stops. And even worse, if everyone connect to his nodes, he can relay all payments, but he is able to distinctively identify payee and payers, even with onion routing.

Quoted text (17 lines)
> [1] Hmm, does forwarding 1 satoshi (2.6 10,000ths of a cent) make
>     sense, or would the CPU cycles cost more than the fees you'd make?
>     How much does it cost to forward a transaction? In python on my
>     laptop, I get about 1000 ECDH operations per second in python, and
>     290k AES ops over a 3kB onion per second, and about 77k SHA256 ops
>     per second. So just counting elliptic ops, forwarding a transaction
>     requires three ops: an ECDH on the onion message, and an ECDSA on
>     the commitment transaction to add the HTLC, and another sometime
>     later to remove it.  So say 1/350th of a CPU-second. My linode costs
>     3c/hour and seems to be about half as fast on the SHA256 test, but
>     gives me two CPUs which evens it out. So so 3/60/60/350 cents is
>     about the cost of forwarding a single transaction, which is about
>     2.4e-8 dollars, which is currently about 9.1e-11 bitcoin, which
>     is 0.0091 satoshi. Conveniently lightning balances are denominated
>     in millisatoshi, so as long as yours increases by 9 or 10, you're
>     doing fine. 10 millisatoshi is 1% of 1 satoshi, so that seems like
>     the right order of magnitude.

Interesting math, thank you for that!

Anthony Towns in reply to Mats Jerratsch permalink original

On Sun, Oct 18, 2015 at 01:25:29PM +0200, Mats Jerratsch wrote:

Quoted text (6 lines)
> > It only works if you actually setup a channel, though -- so you have to
> > lock some money into the channel for however many confirmations until
> > the channel activates, before you can test, plus the OP_CSV delay if
> > the test fails.
> And there's the catch. If an attacker achieves nodes opening up
> channels with him, he already succeeded in vandalism.

I'm not sure this is true? Supposing there are V vandals on the system, compared to T total nodes, so V/T is your probability of selecting a vandal. Then, to join the lightning network, you open up N channels with randomly chosen nodes at $1 each, committing $N in total, and (if they're all run by vandals and have to get closed) spending about 2*N*2c (so 4%?) in fees. If there are 1000 nodes (ie, lots), then the probability of finding at least one good node is about 1-(V/T)^N. If you want a probability of 99% of getting a good node on your first try, then:

  V/T = 10%: N = 2
  V/T = 20%: N = 3
  V/T = 30%: N = 4
  V/T = 40%: N = 6
  V/T = 50%: N = 7
  V/T = 60%: N = 9
  V/T = 70%: N = 13
  V/T = 80%: N = 21
  V/T = 90%: N = 43
  V/T = 95%: N = 86
  V/T = 99%: N = 368

So with 90% of nodes being hostile, that'd be getting expensive, but not completely implausible. If 40%-plus of the network is legit, though, just trying out 10 random nodes seems like it works fine, and only locks up $10 for a couple of days and costs about 40c in bitcoin fees...

Also, if you've got to run 2.5 times as many vandal nodes as there are legitimate nodes for people to even really be bothered, I don't think you'll see many vandals in the first place...

(Once you've got a node that actually works, you can expand your channel from $1 to $10 or $100, and/or open additional channels, and at that point (afaics) you're set.)

That's only necessary if you don't know anyone with a lightning account already, though. Since anyone can forward for you, you could start with someone you trust in real life -- eg, a friend, a bank, a government, etc. If Rusty tells me he'll route my payments (as long as they're made between 10am and 3pm Adelaide time on a weekday, maybe) then I can open a $5 channel with him, and use that to send 1 satoshi payments to test connectivity. So, if I'm wondering whether BOBSBANK is reliable, I work out a route:

  aj -> rusty -> a -> b -> c -> BOBSBANK -> x -> y -> z -> rusty -> aj

apply it as an onion so it can't get short-circuited, and see if it gets back to me, at a cost of maybe 10% of a satoshi (10 hops at 1% each)... If it does, BOBSBANK is connected and functional, and I can try opening a channel. If it doesn't, I can try a different route to BOBSBANK, or try someone else entirely.

Quoted text (3 lines)
> Furthermore, an
> attacker can always play by the rules and forward all payments up to
> one point where he stops.

(For example, he could happily route payments on $1 channels, but refuse to do likewise when the channel capacity was upped to $10)

In the general case though, does that even count as an attack? Isn't that just like a web site going down or being put behind a paywall? ie, annoying, but completely legitimate? I mean, if someone downloads the lightning software to try it out, runs it for a while, then decides it's no fun and stops, they'll be "playing by the rules up to one point where they stop"; but they're not trying to "attack" the system.

Coping with unreliability is definitely important, but running a node that works sometimes but is deliberately unreliable is a lot more effort than running a node that claims to work, but never does. It's also more work (and less profitable) than just running a node that actually work...

Quoted text (3 lines)
> And even worse, if everyone connect to his
> nodes, he can relay all payments, but he is able to distinctively
> identify payee and payers, even with onion routing.

That's a different attack isn't it? To get everyone to connect to your nodes, you'd have to be running the majority of nodes -- ie, there's 5000 different organisations running lightning nodes, but 4999 of them run one or two nodes each, but one of them runs 100,000 nodes.

But if it were cheap enough for one org to run 100k nodes, why wouldn't the others treat it as an arms race and end up running, say, 20-50 nodes each? They'd have an economic incentive to do so, in that it increases their odds of collecting fees... At that point the attacker's already reduced to 28%-50% of nodes. ie, I think that's likely to be self-correcting?

But! An arms race in nodes-per-person would probably cause a scaling problem for the network (depending on how routing actually works), and you'd have to address that by creating some cost to run (or at least register?) a node/channel. But if they're all legitimate nodes, I think that's just a scaling problem, rather than vandalism per se.

(An additional but: even if spamming the list of nodes doesn't work as an effective attack, if you can spam the list of *channels* with valid looking edges that won't actually route payments successfully, you can screw over the network pretty well)

Cheers, aj

Mats Jerratsch in reply to Anthony Towns permalink original

All of your assumptions have the premise though, that choosing a 'good' vs a 'bad' guy is pure probability, like picking the right ball out of a bag. There are other systematic attacks though, where an attacker can trick you into his network for practically zero costs, especially if there is no other solution in place (like checking the blockchain for all of the networks anchors).

Think about an attacker who is able to MITM your internet connection, like the hotspot you connect to at a Cafe (or your ISP if hijacked). They can build locally a gigantic network, all pointing to the same node. You can't tell, and they don't have to necessarily just block your payments. (see above)

I am mainly concerned over those. Especially since there is not really anything we can do about dishonest nodes joining our network, but it's encouraging to see your math. Since everything security-wise so far stands only with knowing pubkeys of nodes actually connected to the network, this should be the first thing to tackle. (that is, making it expensive to attack it this way)

Only nuisance is that it requires either SPV or full node to check the anchor, but I kinda like the idea of having all (or a good amount) of lightning nodes be full bitcoin nodes as well.

cheers Mats Jerratsch

2015-10-19 3:41 GMT+02:00 Anthony Towns <aj at erisian.com.au>:

Quoted text (112 lines)
> On Sun, Oct 18, 2015 at 01:25:29PM +0200, Mats Jerratsch wrote:
>> > It only works if you actually setup a channel, though -- so you have to
>> > lock some money into the channel for however many confirmations until
>> > the channel activates, before you can test, plus the OP_CSV delay if
>> > the test fails.
>> And there's the catch. If an attacker achieves nodes opening up
>> channels with him, he already succeeded in vandalism.
>
> I'm not sure this is true? Supposing there are V vandals on the system,
> compared to T total nodes, so V/T is your probability of selecting a
> vandal. Then, to join the lightning network, you open up N channels
> with randomly chosen nodes at $1 each, committing $N in total, and
> (if they're all run by vandals and have to get closed) spending about
> 2*N*2c (so 4%?) in fees. If there are 1000 nodes (ie, lots), then the
> probability of finding at least one good node is about 1-(V/T)^N.  If you
> want a probability of 99% of getting a good node on your first try, then:
>
>   V/T = 10%: N = 2
>   V/T = 20%: N = 3
>   V/T = 30%: N = 4
>   V/T = 40%: N = 6
>   V/T = 50%: N = 7
>   V/T = 60%: N = 9
>   V/T = 70%: N = 13
>   V/T = 80%: N = 21
>   V/T = 90%: N = 43
>   V/T = 95%: N = 86
>   V/T = 99%: N = 368
>
> So with 90% of nodes being hostile, that'd be getting expensive, but
> not completely implausible. If 40%-plus of the network is legit, though,
> just trying out 10 random nodes seems like it works fine, and only locks
> up $10 for a couple of days and costs about 40c in bitcoin fees...
>
> Also, if you've got to run 2.5 times as many vandal nodes as there are
> legitimate nodes for people to even really be bothered, I don't think
> you'll see many vandals in the first place...
>
> (Once you've got a node that actually works, you can expand your channel
> from $1 to $10 or $100, and/or open additional channels, and at that point
> (afaics) you're set.)
>
> That's only necessary if you don't know anyone with a lightning account
> already, though. Since anyone can forward for you, you could start with
> someone you trust in real life -- eg, a friend, a bank, a government,
> etc. If Rusty tells me he'll route my payments (as long as they're made
> between 10am and 3pm Adelaide time on a weekday, maybe) then I can open
> a $5 channel with him, and use that to send 1 satoshi payments to test
> connectivity. So, if I'm wondering whether BOBSBANK is reliable, I work
> out a route:
>
>   aj -> rusty -> a -> b -> c -> BOBSBANK -> x -> y -> z -> rusty -> aj
>
> apply it as an onion so it can't get short-circuited, and see if it gets
> back to me, at a cost of maybe 10% of a satoshi (10 hops at 1% each)...
> If it does, BOBSBANK is connected and functional, and I can try opening a
> channel. If it doesn't, I can try a different route to BOBSBANK, or try
> someone else entirely.
>
>> Furthermore, an
>> attacker can always play by the rules and forward all payments up to
>> one point where he stops.
>
> (For example, he could happily route payments on $1 channels, but refuse
> to do likewise when the channel capacity was upped to $10)
>
> In the general case though, does that even count as an attack? Isn't
> that just like a web site going down or being put behind a paywall? ie,
> annoying, but completely legitimate? I mean, if someone downloads the
> lightning software to try it out, runs it for a while, then decides it's
> no fun and stops, they'll be "playing by the rules up to one point where
> they stop"; but they're not trying to "attack" the system.
>
> Coping with unreliability is definitely important, but running a node that
> works sometimes but is deliberately unreliable is a lot more effort than
> running a node that claims to work, but never does. It's also more work
> (and less profitable) than just running a node that actually work...
>
>> And even worse, if everyone connect to his
>> nodes, he can relay all payments, but he is able to distinctively
>> identify payee and payers, even with onion routing.
>
> That's a different attack isn't it? To get everyone to connect to your
> nodes, you'd have to be running the majority of nodes -- ie, there's
> 5000 different organisations running lightning nodes, but 4999 of them
> run one or two nodes each, but one of them runs 100,000 nodes.
>
> But if it were cheap enough for one org to run 100k nodes, why wouldn't
> the others treat it as an arms race and end up running, say, 20-50
> nodes each?  They'd have an economic incentive to do so, in that it
> increases their odds of collecting fees... At that point the attacker's
> already reduced to 28%-50% of nodes.  ie, I think that's likely to be
> self-correcting?
>
> But! An arms race in nodes-per-person would probably cause a scaling
> problem for the network (depending on how routing actually works), and
> you'd have to address that by creating some cost to run (or at least
> register?) a node/channel. But if they're all legitimate nodes, I think
> that's just a scaling problem, rather than vandalism per se.
>
> (An additional but: even if spamming the list of nodes doesn't work as
> an effective attack, if you can spam the list of *channels* with valid
> looking edges that won't actually route payments successfully, you can
> screw over the network pretty well)
>
> Cheers,
> aj
>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Anthony Towns in reply to Mats Jerratsch permalink original

On Mon, Oct 19, 2015 at 09:45:34AM +0200, Mats Jerratsch wrote:

Quoted text (3 lines)
> All of your assumptions have the premise though, that choosing a
> 'good' vs a 'bad' guy is pure probability, like picking the right ball
> out of a bag. [...]

Three sorts of attack:

 - Vandals randomly join the lightning network with dysfunctional nodes.
   They don't have special powers to corrupt your network, and aren't
   targetting anyone in specific, just trying to damage things because
   they think lightning is a bad idea and want to stop it happening.
   This is just a denial of service attack. This is the class of attack
   that gives the "pure probability" of hitting a bad node.
 - Sybil attack, where someone is targetting you personally, and
   controlling all the nodes you connect to. This is the "compromised
   wifi or ISP" case, and afaics denial-of-service is trivial here,
   so all you can reasonably do is detect that you can't send funds to
   anyone usefully, and avoid locking up lots of funds while trying.
 - Pervasive attack, where everyone in some large group is
   simultaenously suffering from a sybil attack; eg the Chinese gov or an
   ISP blocks lightning connections unless they're to one of its nodes,
   so they always see both ends of payments between their victims. This
   seems very expensive to pull off to me (you have to do deep inspection
   of a whole bunch of people's internet connections), but I'm not sure
   it can be effectively defended against. "Oh i was just forwarding
   that to someone else" doesn't work if there wasn't any way you could
   make a channel with anyone else (or if secretly forwarding payments
   is criminal in itself).
Quoted text (5 lines)
> Think about an attacker who is able to MITM your internet connection,
> like the hotspot you connect to at a Cafe (or your ISP if hijacked).
> They can build locally a gigantic network, all pointing to the same
> node. You can't tell, and they don't have to necessarily just block
> your payments. (see above)

But you can tell, just by seeing whether a well-known third party's lightning address is routable? If every node on your network is an attacker's, then you won't see the third party's address.

If you do see a route to the third party (ie, Me -> Attacker -> Attacker -> Attacker -> Bob -> Carol -> Third party), then you could work backwards asking Carol and Bob to connect directly to you, which would get you a non-attacker node with reasonable probability, assuming there are any.

I guess there's two ways in which a node is "on the network" -- one is if it's reachable by p2p hopping ("Hey, what are your neighbours' network addresses?" "Okay, connect to them and repeat"), the other if it's routable over established channels. If you do a Sybil attack against p2p hopping; my argument is you can still use the payment channels as a way of connecting to other nodes. And if you do a Sybil attack against both p2p hopping /and/ the graph of channels, then that's detectable because well-known nodes simply won't appear in the graph.

Quoted text (3 lines)
> Only nuisance is that it requires either SPV or full node to check the
> anchor, but I kinda like the idea of having all (or a good amount) of
> lightning nodes be full bitcoin nodes as well.

You need to monitor the blockchain for spends of your own anchors anyway, so that doesn't seem like a big additional limitation to me.

Cheers, aj

Rusty Russell in reply to Mats Jerratsch permalink original

Mats Jerratsch <matsjj at gmail.com> writes:

Quoted text (5 lines)
>> This makes some sense (though the anchor transactions don't need to be
>> P2SH, it's nicer for bitcoin's UTXO if they are).
>
> Well, currently there is no one working on a malleability fix, so we
> should probably work forwards the next available goal. ;)

Oh, I'm pushing BIP 62, as well, in parallel with everything else :)

Quoted text (33 lines)
>>> For the current form it would be enough to have
>>> SecretAHash || KeyB' || KeyB || KeyA || TxID || SignatureB (L=231B)
>>> with KeyB being the node pubkey (lots of key reusage...)
>>> or
>>> SecretAHash || KeyB' || KeyB || KeyA || TxID || nodePubKey ||
>>> SignatureB (L=264B) with KeyB as a channel key that does not need to
>>> be equal with the nodePubKey.
>>
>> Yes, I think avoiding key reuse is good.  So, to be clear, the anchor TX
>> output looks like:
>>
>>         P2SH (2 KEYA KEYB 2 OP_CHECKMULTISIG)
>
> Having to deal with malleability, the only viable solution for anchor
> transactions are with escape and fast-escape?
>
>> I think we can do slightly better with Schnorr signatures (which you can
>> simply do multisig by addition, if I understand correctly) where both
>> parties cooperate to form:
>>
>>         KEYA KEYB NODE-PUBKEYA NODE-PUBKEYB TXID DUAL-SIGNATURE
>>
>> That's 33+33+33+33+32+64 = 228 bytes per channel.
>
> Interesting, I kinda feel uncomfortable with Schnorr though. It feels
> like some experimental method, and at least for Java, there are very
> few implementations around (and I don't feel comfortable implementing
> it on my own either..)
>
> I like the idea of adding together one object for the channel to be
> sent by both nodes. Even without Schnorr it saves some bytes and the
> overhead of gossipping.. We can always switch the signature to Schnorr
> too..

Yes, we've not as bound to consensus, which is nice. Schnorr is something we can decide on later, for sure.

Cheers, Rusty.

Rusty Russell in reply to Mats Jerratsch permalink original

Mats Jerratsch <matsjj at gmail.com> writes:

Quoted text (12 lines)
> Think about an attacker who is able to MITM your internet connection,
> like the hotspot you connect to at a Cafe (or your ISP if hijacked).
> They can build locally a gigantic network, all pointing to the same
> node. You can't tell, and they don't have to necessarily just block
> your payments. (see above)
>
> I am mainly concerned over those. Especially since there is not really
> anything we can do about dishonest nodes joining our network, but it's
> encouraging to see your math. Since everything security-wise so far
> stands only with knowing pubkeys of nodes actually connected to the
> network, this should be the first thing to tackle. (that is, making it
> expensive to attack it this way)

Well, bitcoin protects from this using checkpoints, which are centralized. Because AFAICT there's no really good way of doing it.

If we use beacons, this does become a bit easier: beacons indicate the size of the network (statistically), so you can embed that estimate in how large you expect the network to be.

Quoted text (3 lines)
> Only nuisance is that it requires either SPV or full node to check the
> anchor, but I kinda like the idea of having all (or a good amount) of
> lightning nodes be full bitcoin nodes as well.

We're going to need to support both, but for the moment I expect they'll be full nodes.

Cheers, Rusty.

Mats Jerratsch in reply to Anthony Towns permalink original
Quoted text (8 lines)
> But you can tell, just by seeing whether a well-known third party's
> lightning address is routable? If every node on your network is an
> attacker's, then you won't see the third party's address.
>
> If you do see a route to the third party (ie, Me -> Attacker -> Attacker
> -> Attacker -> Bob -> Carol -> Third party), then you could work backwards
> asking Carol and Bob to connect directly to you, which would get you a
> non-attacker node with reasonable probability, assuming there are any.

No you can't, that's the whole point. ;) Just because they are attacking you personally does not mean they do not have a working link to the rest of the network. They can still route all your payment and (1) monitor all your activity (2) gain some profit by charging some high fees off of you.

Maybe I am missing something though..

Peter Todd in reply to Rusty Russell permalink original

On Tue, Oct 20, 2015 at 04:55:04PM +1030, Rusty Russell wrote:

Quoted text (16 lines)
> Mats Jerratsch <matsjj at gmail.com> writes:
> > Think about an attacker who is able to MITM your internet connection,
> > like the hotspot you connect to at a Cafe (or your ISP if hijacked).
> > They can build locally a gigantic network, all pointing to the same
> > node. You can't tell, and they don't have to necessarily just block
> > your payments. (see above)
> >
> > I am mainly concerned over those. Especially since there is not really
> > anything we can do about dishonest nodes joining our network, but it's
> > encouraging to see your math. Since everything security-wise so far
> > stands only with knowing pubkeys of nodes actually connected to the
> > network, this should be the first thing to tackle. (that is, making it
> > expensive to attack it this way)
>
> Well, bitcoin protects from this using checkpoints, which are
> centralized.  Because AFAICT there's no really good way of doing it.

Actually, I'd point out that checkpoints aren't as centralized as you'd think! Checkpoints are set sufficiently far back in the past that if they come into play for any reason other than initial bootstrapping, an active attacker exists that has sufficient hashing power to destroy Bitcoin anyway. Thus, checkpoints do *not* need consensus between different implementations; my Bitcoin implementation can set a different checkpoint than yours and both will work fine, except in the case of massive attacks that Bitcoin can't survive anyway.

I probably should release a Bitcoin implementation with different checkpoints than Bitcoin Core to make this point more clearly...

Rusty Russell in reply to Peter Todd permalink original

Peter Todd <pete at petertodd.org> writes:

Quoted text (26 lines)
> On Tue, Oct 20, 2015 at 04:55:04PM +1030, Rusty Russell wrote:
>> Mats Jerratsch <matsjj at gmail.com> writes:
>> > Think about an attacker who is able to MITM your internet connection,
>> > like the hotspot you connect to at a Cafe (or your ISP if hijacked).
>> > They can build locally a gigantic network, all pointing to the same
>> > node. You can't tell, and they don't have to necessarily just block
>> > your payments. (see above)
>> >
>> > I am mainly concerned over those. Especially since there is not really
>> > anything we can do about dishonest nodes joining our network, but it's
>> > encouraging to see your math. Since everything security-wise so far
>> > stands only with knowing pubkeys of nodes actually connected to the
>> > network, this should be the first thing to tackle. (that is, making it
>> > expensive to attack it this way)
>>
>> Well, bitcoin protects from this using checkpoints, which are
>> centralized.  Because AFAICT there's no really good way of doing it.
>
> Actually, I'd point out that checkpoints aren't as centralized as you'd
> think! Checkpoints are set sufficiently far back in the past that if
> they come into play for any reason other than initial bootstrapping, an
> active attacker exists that has sufficient hashing power to destroy
> Bitcoin anyway. Thus, checkpoints do *not* need consensus between
> different implementations; my Bitcoin implementation can set a different
> checkpoint than yours and both will work fine, except in the case of
> massive attacks that Bitcoin can't survive anyway.

Bitcoin implementations could remove the confusion by simply specifying how much total work there is expected to be, but that still allows nuisance attacks with alternate chains.

My point was more that "it's good enough for bitcoin" so don't feel too bad if we end up with clients hardcoding details about the lightning network they expect to connect to (at the very least, its size).

Thanks, Rusty.