Skip to content

Randomize initial onion packet data. #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

TheBlueMatt
Copy link
Collaborator

This avoids at least the trivial hop count discovery attack, though
other obvious ones remain and are slightly harder to avoid.

See lightning/bolts#697

@ariard
Copy link

ariard commented Nov 29, 2019

Okay would go tomorrow through the whole issue+ml announcement to double-check the fix is right.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the paper : "The exit node hence can learn the length of the chosen path
with the following attack: The adversarial exit node observes
(after XORing) where the first 1 bit after the identifier is.
It knows that the filler string starts there or earlier and can
determine by the length of the filler string a lower bound on
the length of the path used."

If I understand correctly the heuristic lies on given a filler starting in the packet, I can deduce the previous size allocated for message headers (in LN the hops_payload), but assuming message headers size is known (at least in v0 onion) isn't the whole length of the path leaked ?

@@ -224,6 +224,7 @@ mod real_chacha {
self.offset = 0;
}

#[inline] // Useful cause input may be 0s on stack that should be optimized out
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A warn against too smart compiler which would align stack after function jump?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm? Not sure what you're asking.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't asking anything, just wanted to be sure that inline was to prevent compiler alignement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by "alignment", but, in any case, afaiu, #[inline] has two meanings:

  • for pub fns it allows inlining across crates, which is normally only possible with lto,
  • for regular fns its just a hint to the compiler that it should try inlining, which it is free to completely ignore if it likes.

This avoids at least the trivial hop count discovery attack, though
other obvious ones remain and are slightly harder to avoid.

See lightning/bolts#697
@ariard
Copy link

ariard commented Dec 3, 2019

ACK fd1d5fd, that's okay for now but let's not abuse conditional compilation for testing.

@TheBlueMatt
Copy link
Collaborator Author

Ehh, we do it in a number of places already for fuzztarget, and exposing the onion data just for testing is grosser than just throwing test code in...

@TheBlueMatt TheBlueMatt merged commit 9f30b30 into lightningdevkit:master Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants