Skip to content
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

fix(log): Stop logging peer IP addresses, to protect user privacy #6662

Merged
merged 18 commits into from
May 14, 2023

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented May 10, 2023

Motivation

We don't want to log peer IP addresses, because lists of peers are privacy and security sensitive.

Close #3320.

Complex Code or Requirements

This PR modifies some canonical IP address code, but these changes shouldn't impact network compatibility. (If they do, we'll see it in the integration tests.)

Solution

New types and functions:

Privacy fixes:

Related fixes:

Testing

See my manual log check below in the comments.

Review

This is a large change, so we might not want to schedule any other zebra-network work until it's merged. (@mpguerra I've checked the existing zebra-network tickets in this sprint and they seem fine.)

We might also want to make it a high priority for review, I'll leave that up to Pili.

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

Follow Up Work

Check for IP addresses of peers that are logged in other ways: going forward this should be considered a bug.

@teor2345 teor2345 added C-bug Category: This is a bug P-Medium ⚡ C-security Category: Security issues I-privacy Zebra discloses private information A-network Area: Network protocol updates or fixes A-diagnostics Area: Diagnosing issues or monitoring performance labels May 10, 2023
@teor2345 teor2345 requested a review from a team as a code owner May 10, 2023 23:34
@teor2345 teor2345 self-assigned this May 10, 2023
@teor2345 teor2345 requested review from oxarbitrage and removed request for a team May 10, 2023 23:34
@github-actions github-actions bot added the C-feature Category: New features label May 10, 2023
@teor2345 teor2345 requested a review from a team as a code owner May 10, 2023 23:42
@teor2345
Copy link
Contributor Author

I manually ran zebrad start, and I got this output:

...
2023-05-10T23:44:31.201494Z  INFO {zebrad="513fb74" net="Test"}:add_initial_peers: zebra_network::config: resolved seed peer IP addresses seed="192.168.215.106:38233" remote_ip_count=1
2023-05-10T23:44:31.201746Z  INFO {zebrad="513fb74" net="Test"}:add_initial_peers: zebra_network::config: resolved seed peer IP addresses seed="testnet.is.yolo.money:18233" remote_ip_count=1
2023-05-10T23:44:31.201782Z  INFO {zebrad="513fb74" net="Test"}:add_initial_peers: zebra_network::config: resolved seed peer IP addresses seed="dnsseed.testnet.z.cash:18233" remote_ip_count=2
2023-05-10T23:44:31.201789Z  INFO {zebrad="513fb74" net="Test"}:add_initial_peers: zebra_network::config: resolved seed peer IP addresses seed="testnet.seeder.zfnd.org:18233" remote_ip_count=3
2023-05-10T23:44:31.201804Z  INFO {zebrad="513fb74" net="Test"}:add_initial_peers: zebra_network::peer_set::initialize: connecting to initial peer set initial_peer_count=10 initial_peers={v4redacted:5823
3, v4redacted:18233, v4redacted:18233, v4redacted:18233, v4redacted:58233, v4redacted:58233, v4redacted:18233, v4redacted:18233, v4redacted:38233, v4redacted:38233}
2023-05-10T23:44:31.651242Z  INFO {zebrad="513fb74" net="Test"}:add_initial_peers: zebra_network::peer_set::initialize: an initial peer connection failed successes=1 errors=1 addr=v4redacted:18233 e=Connection refused (os error 111)

So this change seems to be working as expected for initial peers. I haven't seen any ongoing peer logs yet.

Configured seed peer DNS and IP addresses are ok to log, because they are stored on the disk already in zebrad.toml. But we don't log the results of the DNS query any more.

@teor2345
Copy link
Contributor Author

I also checked that ongoing peer logs don't show IP addresses any more, here are some debug logs:

2023-05-10T23:50:41.982150Z DEBUG {zebrad="513fb74" net="Test"}:{peer=Out("v4redacted:18233")}: zebra_network::peer::connection: finished receiving peer response to Zebra request response=Block { height: 55372, hash: 00131228c15343594ad4a539f132c846961718f7d5231be4cdae1f271cac941f }
2023-05-10T23:50:41.982174Z DEBUG {zebrad="513fb74" net="Test"}:sync:try_to_sync:extend_tips: zebra_network::peer::connection: sending request from Zebra to peer state=AwaitingRequest request=BlocksByHash(1)
2023-05-10T23:50:41.982250Z DEBUG {zebrad="513fb74" net="Test"}:sync:try_to_sync:extend_tips: zebra_network::peer::connection: sending request from Zebra to peer state=AwaitingRequest request=BlocksByHash(1)
2023-05-10T23:50:42.076474Z DEBUG {zebrad="513fb74" net="Test"}:sync:try_to_sync:extend_tips: zebra_network::peer::connection: received peer response to Zebra request handler=BlocksByHash { pending_hashes: 1, blocks: 0 } msg=block { height: 55373, hash: 00129132a7cea26d690ae01b0d14c4a65ef9fe381d3fb87ce89e85fb23168d41 }
2023-05-10T23:50:42.076511Z DEBUG {zebrad="513fb74" net="Test"}:{peer=Out("v4redacted:30835")}: zebra_network::peer::connection: finished receiving peer response to Zebra request response=Block { height: 55373, hash: 00129132a7cea26d690ae01b0d14c4a65ef9fe381d3fb87ce89e85fb23168d41 }
2023-05-10T23:50:42.076540Z DEBUG {zebrad="513fb74" net="Test"}:sync:try_to_sync:extend_tips: zebra_network::peer::connection: sending request from Zebra to peer state=AwaitingRequest request=BlocksByHash(1)
2023-05-10T23:50:42.076713Z DEBUG {zebrad="513fb74" net="Test"}:sync:try_to_sync:extend_tips: zebra_network::peer::connection: sending request from Zebra to peer state=AwaitingRequest request=BlocksByHash(1)
2023-05-10T23:50:42.108654Z DEBUG {zebrad="513fb74" net="Test"}:sync:try_to_sync:extend_tips: zebra_network::peer::connection: received peer response to Zebra request handler=BlocksByHash { pending_hashes: 1, blocks: 0 } msg=block { height: 55373, hash: 00129132a7cea26d690ae01b0d14c4a65ef9fe381d3fb87ce89e85fb23168d41 }
2023-05-10T23:50:42.108699Z DEBUG {zebrad="513fb74" net="Test"}:{peer=Out("v4redacted:18233")}:msg_as_req{msg="block"}: zebra_network::peer::connection: received inbound peer message state=AwaitingResponse(BlocksByHash { pending_hashes: 1, blocks: 0 }) msg=block { height: 55373, hash: 00129132a7cea26d690ae01b0d14c4a65ef9fe381d3fb87ce89e85fb23168d41 }
2023-05-10T23:50:42.108721Z DEBUG {zebrad="513fb74" net="Test"}:{peer=Out("v4redacted:18233")}:msg_as_req{msg="block"}: zebra_network::peer::connection: got block message unsolicited or from canceled request msg=block { height: 55373, hash: 00129132a7cea26d690ae01b0d14c4a65ef9fe381d3fb87ce89e85fb23168d41 }
2023-05-10T23:50:42.108739Z DEBUG {zebrad="513fb74" net="Test"}:{peer=Out("v4redacted:18233")}: zebra_network::peer::connection: ignoring peer message: not a response or a request unused_msg=block { height: 55373, hash: 00129132a7cea26d690ae01b0d14c4a65ef9fe381d3fb87ce89e85fb23168d41 } self.state=AwaitingResponse(BlocksByHash { pending_hashes: 1, blocks: 0 })
2023-05-10T23:50:42.143668Z DEBUG {zebrad="513fb74" net="Test"}:sync:try_to_sync:extend_tips: zebra_network::peer::connection: received peer response to Zebra request handler=BlocksByHash { pending_hashes: 1, blocks: 0 } msg=block { height: 55374, hash: 00a0bb9c9e5d9f91198f8c8cafe189cd93a5c29a2de436d365a240336cc5bd40 }
2023-05-10T23:50:42.143700Z DEBUG {zebrad="513fb74" net="Test"}:{peer=Out("v4redacted:18233")}: zebra_network::peer::connection: finished receiving peer response to Zebra request response=Block { height: 55374, hash: 00a0bb9c9e5d9f91198f8c8cafe189cd93a5c29a2de436d365a240336cc5bd40 }

@teor2345
Copy link
Contributor Author

The address redactions also work on peer errors and block gossips:

2023-05-11T00:47:37.447952Z  INFO {zebrad="513fb74" net="Main"}:{peer=Out("v4redacted:8233")}:msg_as_req{msg="inv"}:inbound:download_and_verify{hash=0000000000451cab4c0aeeeec094e9a0dda9a33e1adfe83e322a54a9fbf04ab6}: zebrad::components::inbound::downloads: downloaded and verified gossiped block height=Height(2081747)
2023-05-11T00:47:39.631909Z  INFO {zebrad="513fb74" net="Test"}:crawl_and_dial{new_peer_interval=61s}: zebra_network::peer_set::candidate_set: timeout waiting for peer service readiness or peer responses
2023-05-11T00:48:35.634620Z  INFO {zebrad="513fb74" net="Main"}:{peer=Out("v4redacted:8233")}:msg_as_req{msg="inv"}: zebra_network::peer::connection: inbound service is overloaded, closing connection remote_user_agent="/MagicBean:5.4.0/" negotiated_version=Version(170100) peer="v4redacted:8233" last_peer_state=Some("AwaitingRequest::In::Req::AdvertiseTransactionIds") remote_height=Height(2081735) cached_addrs=1 connection_state=AwaitingRequest
2023-05-11T00:48:35.634604Z  INFO {zebrad="513fb74" net="Main"}:{peer=Out("v4redacted:2838")}:msg_as_req{msg="inv"}: zebra_network::peer::connection: inbound service is overloaded, closing connection remote_user_agent="/MagicBean:5.4.1/" negotiated_version=Version(170100) peer="v4redacted:2838" last_peer_state=Some("AwaitingRequest::In::Req::AdvertiseTransactionIds") remote_height=Height(2081724) cached_addrs=1 connection_state=AwaitingRequest

@teor2345
Copy link
Contributor Author

@oxarbitrage I'm happy to do a video review on this PR if that would help. But it's a lower priority than the release and security fixes.

@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Merging #6662 (f2228af) into main (0190882) will increase coverage by 0.14%.
The diff coverage is 89.74%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6662      +/-   ##
==========================================
+ Coverage   77.87%   78.02%   +0.14%     
==========================================
  Files         309      310       +1     
  Lines       40665    40687      +22     
==========================================
+ Hits        31669    31745      +76     
+ Misses       8996     8942      -54     

@teor2345
Copy link
Contributor Author

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented May 11, 2023

update

✅ Branch has been successfully updated

@teor2345
Copy link
Contributor Author

Failed due to #6667

Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

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

We went through this PR on a video call. The number of changes are huge but tedious but we have good test coverage for this. The number of file changed is big too so i think we need to merge fast before starting to conflict.

mergify bot added a commit that referenced this pull request May 14, 2023
@mergify mergify bot merged commit b0d9471 into main May 14, 2023
@mergify mergify bot deleted the stop-logging-peer-ips branch May 14, 2023 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Diagnosing issues or monitoring performance A-network Area: Network protocol updates or fixes C-bug Category: This is a bug C-feature Category: New features C-security Category: Security issues I-privacy Zebra discloses private information
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop logging IP addresses and mempool transaction IDs by default, to protect user privacy
2 participants