Skip to content

multi: autopilot firewall and privacy map interceptors #487

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 47 commits into from
Feb 15, 2023

Conversation

ellemouton
Copy link
Member

This PR makes extensive use of LNDs RPC middleware interceptors in order to implement a macaroon firewall.

Calls made with a macaroon containing the lnd-custom privacy caveat will be intercepted and any private info (such as pub keys, outpoints etc) will be mapped out to random values for requests and mapped back to real values for responses.

Calls made with a macaroon containing the lnd-custom lit-mac-fwcaveat will be intercepted and the call will be validated agains various rules that the caveat specifies. The current set of defined rules are: Channel restrictions, peer restrictions, channel policy bounds, history limit, rate limit.

An Autopilot client is also added which handles registering an LNC session with the Autopilot server. The access given to the autopilot server is restricted using the above mentioned macaroon caveats.

ellemouton and others added 30 commits January 27, 2023 06:47
This commit adds an ID to the Session struct. The ID is not persisted
but is instead derived from the macaroon used for the session.
In this commit we add all the proto methods and messages that we will
need for the initial autopilot implementation.
This commit adds a new Action type to the firewalldb package along with
Serialization and Deserialization methods for it. It also adds
ListAction and ListSessionAction methods to the DB which can be used to
paginate through the actions. Various interfaces are also added that
will be used by `rules` to access certain RuleActions.
This commit adds a Lit grpc service and uses it to expose a ListActions
method. Litcli is also updated to make use of this method.
Add a client for the autopilot server along with a mock server that can
be used in tests.
ellemouton and others added 16 commits January 27, 2023 06:47
Adds helper functions to randomize amounts, timestamps, and booleans.
Amounts are randomized based on a percentage and timestamps based on an
absolute scale.
Adds amount, timestamp, and channel initiator obfuscation to the two
response handlers `handleFwdHistoryResponse` and
`handleListChannelsResponse`.

In order to preserve privacy and still ensure functioning of algorithms
that rely on the randomized data, a trade-off between randomization and
accuracy needs to be found.

We choose ten minutes for forwarding timestamps as this breaks time
correlation of payments.

The amount obfuscation is chosen to be 5% and applies to the forwarding
amount and channel details to hide balances. We also remove details of
pending HTLCs in channels. Random obfuscation for amounts is chosen here
instead of rounding to have non-deterministic alteration of amounts,
which is especially important for forwardings to also break amount
correlation. Randomly varying around a certain value will statistically
skew averages less than rounding for algorithms that rely on
aggregation of individual data.

The privacy mapper is chosen to accept a randomness input in order to
ensure deterministic testing even when other handlers are changed in the
future.
Also includes an itest to assert that sessions work with very large
headers.
In this commit, in the response handlers of the privacy mapper, we
construct new response messages instead of overwriting existing messages
in order to minimize the chances of private data slipping through
accidentally.
Bump the tlv version to the version that supports uncapped tlv streams.
Create LNC account sessions through litcli
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

We reviewed and tested this code internally for many weeks, so I can give my thumbs up rather quickly.
Amazing work on this, kudos to everyone involved 💯

Copy link
Member

@jamaljsr jamaljsr left a comment

Choose a reason for hiding this comment

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

tACK. Did a test run just to sanity check. Everything still works as expected. Awesome job on this feature @ellemouton 🔥

Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

tACK 🚀 Awesome work!

@ellemouton ellemouton merged commit 46a1d7e into lightninglabs:master Feb 15, 2023
@ellemouton ellemouton deleted the autopilotFirewall branch February 15, 2023 07:06
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.

4 participants