<oembed><type>rich</type><version>1.0</version><author_name>npub17fjkngg0s0mfx4uhhz6n4puhflwvrhn2h5c78vdr5xda4mvqx89swntr0s</author_name><author_url>https://nostr.ae/npub17fjkngg0s0mfx4uhhz6n4puhflwvrhn2h5c78vdr5xda4mvqx89swntr0s</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-02-04&#xA;📝 Original message:&#xA;Hey again,&#xA;&#xA;Otherwise Mallory gets two invoices, and wants to know if they&#39;re&#xA;&gt; actually the same node.  Inv1 has nodeid N1, routehint Bob-&gt;C1, Inv2 has&#xA;&gt; nodeid N2, routehint Bob-&gt;C2.&#xA;&gt;&#xA;&#xA;I think this attack is interesting. AFAICT my proposal defends against this&#xA;because of the way&#xA;`payment_secret` and `decoy_key` are both used to derive the `decoy_scid`&#xA;(but don&#39;t trust me, do&#xA;verify that I&#39;m not missing something).&#xA;&#xA;If Mallory doesn&#39;t use both the right `decoy_node_id` and `payment_secret`&#xA;to compute `P_I`, Bob&#xA;will not decode that to a valid real `scid` and will return an&#xA;`unknown_next_peer` which is good&#xA;for privacy.&#xA;&#xA;It seems to me that&#xA;https://github.com/lightningnetwork/lightning-rfc/pull/681 cannot defend&#xA;against this attack. If both invoices are currently valid, Bob will forward&#xA;an HTLC that uses N1&#xA;with C2 (because Bob has no way of knowing N1 from the onion, for privacy&#xA;reasons).&#xA;The only way I&#39;d see to avoid is would be that Alice needs to share her&#xA;`decoy_node_id`s with&#xA;Bob (and the mapping to a `decoy_scid`) which means more state to&#xA;manage...but maybe I&#39;m just&#xA;missing a better mitigation?&#xA;&#xA;Cheers,&#xA;Bastien&#xA;&#xA;Le mar. 4 févr. 2020 à 15:09, Bastien TEINTURIER &lt;bastien at acinq.fr&gt; a&#xA;écrit :&#xA;&#xA;&gt; I&#39;m a bit confused, I don&#39;t know if the implementation work you&#39;re&#xA;&gt; mentioning refers to my proposal&#xA;&gt; or yours :).&#xA;&gt;&#xA;&gt; When you say `temporary id`, could you clarify whether you mean a&#xA;&gt; temporary `node_id` or `scid`?&#xA;&gt;&#xA;&gt; Firstly, need to brute-force the onion against your N keys.&#xA;&gt;&#xA;&gt;&#xA;&gt; This is probably the part that confuses me. Are you talking about Bob or&#xA;&gt; Alice there?&#xA;&gt; Alice can easily have her `decoy_node_id` be derived from her real&#xA;&gt; `node_id`&#39;s privacy key and the&#xA;&gt; `payment_hash` or `payment_preimage`. When she receives a payment, she&#xA;&gt; knows which `decoy_node_id`&#xA;&gt; should have been used so she doesn&#39;t need to brute-force.&#xA;&gt;&#xA;&gt; That means Alice doesn&#39;t even have to change how she stores invoices. When&#xA;&gt; Alice retrieves the&#xA;&gt; invoice from her DB, if it has the `decoy_node_id` feature bit set, she&#xA;&gt; knows she needs to derive&#xA;&gt; the correct `node_id`. If it doesn&#39;t have that feature bit set, it&#39;s a&#xA;&gt; &#34;legacy&#34; invoice and she has&#xA;&gt; to use her real `node_id`.&#xA;&gt;&#xA;&gt; Now Mallory uses Bob-&gt;C2 to pay to N1 for Inv1. If it works, he knows it&#39;s&#xA;&gt;&gt; the same node issuing both invoices.&#xA;&gt;&#xA;&gt;&#xA;&gt; Same, that wouldn&#39;t work because Alice can easily detect the mismatch and&#xA;&gt; pretend she can&#39;t decrypt&#xA;&gt; the onion (the code doesn&#39;t even have to pretend: it will use the expected&#xA;&gt; `node_id` and use the&#xA;&gt; existing error paths).&#xA;&gt;&#xA;&gt; Actually, that was too hasty.&#xA;&gt;&#xA;&gt;&#xA;&gt; Ok I think your second email came to the same conclusions and clarifies it&#xA;&gt; a bit :).&#xA;&gt;&#xA;&gt; It&#39;s true that this is code where the developer may easily get confused&#xA;&gt; between keys (but it&#39;s a&#xA;&gt; lot simpler than the Sphinx or Noise implementation).&#xA;&gt;&#xA;&gt; However in my opinion it&#39;s still simpler than the `scid` state management&#xA;&gt; that needs to happen at&#xA;&gt; Alice and Bob in&#xA;&gt; https://github.com/lightningnetwork/lightning-rfc/pull/681 (but I would&#xA;&gt; need to&#xA;&gt; implement both E2E to be able to fairly judge that).&#xA;&gt;&#xA;&gt; Thanks for the feedback, I&#39;ll keep working on improving the proposal.&#xA;&gt; Bastien&#xA;&gt;&#xA;&gt; Le mar. 4 févr. 2020 à 05:29, Rusty Russell &lt;rusty at rustcorp.com.au&gt; a&#xA;&gt; écrit :&#xA;&gt; &gt;&#xA;&gt; &gt; Rusty Russell &lt;rusty at rustcorp.com.au&gt; writes:&#xA;&gt; &gt; &gt; Bastien TEINTURIER &lt;bastien at acinq.fr&gt; writes:&#xA;&gt; &gt; &gt;&gt; That&#39;s of course a solution as well. Even with that though, if Alice&#xA;&gt; opens&#xA;&gt; &gt; &gt;&gt; multiple channels to each of her Bobs,&#xA;&gt; &gt; &gt;&gt; she should use Tor and a different node_id each time for better&#xA;&gt; privacy.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; There are two uses for this feature (both of which I started&#xA;&gt; implementing):&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; 1. Simply always use a temporary id when you have a private channel, to&#xA;&gt; &gt; &gt;    obscure your onchain footprint.  This is a nobrainer.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; 2. For an extra layer of transience, apply a new temporary id and new&#xA;&gt; &gt; &gt;    nodeid on every invoice *which applies only for that invoice*.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; But implementing the latter securely is fraught!&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; Firstly, need to brute-force the onion against your N keys.  Secondly,&#xA;&gt; &gt; &gt; if you use a temporary key, then you *don&#39;t* end up using the HTLC to&#xA;&gt; &gt; &gt; pay an invoice matching that key, you *MUST* pretend you couldn&#39;t&#xA;&gt; &gt; &gt; decrypt the onion!  This applies to all code paths between the two,&#xA;&gt; &gt; &gt; including parsing the TLV, etc: they must ALL return&#xA;&gt; &gt; &gt; WIRE_INVALID_ONION_HMAC.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; Otherwise, Mallory can get an invoice, then send malformed payments to&#xA;&gt; &gt; &gt; Alice using the transient key in the invoice and see if she decrypts&#xA;&gt; it.&#xA;&gt; &gt;&#xA;&gt; &gt; Actually, that was too hasty.  You can use the payment_hash as a&#xA;&gt; &gt; fastpath:&#xA;&gt; &gt;&#xA;&gt; &gt; 1. Look up invoice using payment_hash.&#xA;&gt; &gt;&#xA;&gt; &gt; 2. If there is an invoice, and it has a temporary id associated with it,&#xA;&gt; &gt;    try using that to decrypt the onion.  If that works, and the onion is&#xA;&gt; &gt;    on the final hop, and the TLV decodes, and the payment_secret is&#xA;&gt; &gt;    correct, you can go back and use this temporary key to decrypt the&#xA;&gt; onion.&#xA;&gt; &gt;    Otherwise, go back and use the normal node key.&#xA;&gt; &gt;&#xA;&gt; &gt; That&#39;s still quite a bit of tricky code though...&#xA;&gt; &gt;&#xA;&gt; &gt; Cheers,&#xA;&gt; &gt; Rusty.&#xA;&gt;&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20200204/41cc31da/attachment-0001.html&gt;</html></oembed>