Skip to content

Update localhost and private IP validations#5126

Open
neatzsche wants to merge 1 commit intostellar:masterfrom
neatzsche:fix/peer-localhost-and-linklocal-validation
Open

Update localhost and private IP validations#5126
neatzsche wants to merge 1 commit intostellar:masterfrom
neatzsche:fix/peer-localhost-and-linklocal-validation

Conversation

@neatzsche
Copy link

@neatzsche neatzsche commented Feb 5, 2026

Description

Prevents a node from accepting localhost peers from another peer that provides a peer address that is in the loopback address range that isn't just 127.0.0.1. Also extends isPrivate() validation to prevent accepting a link-local peer.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copilot AI review requested due to automatic review settings February 5, 2026 21:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the security of peer address validation by expanding localhost detection and adding link-local address filtering. The changes prevent nodes from accepting peer addresses in the full loopback range (127.x.y.z) instead of just 127.0.0.1, and also reject link-local addresses (169.254.x.y) as private addresses that should not be advertised across the network.

Changes:

  • Expanded isLocalhost() to detect the entire 127.x.y.z loopback range using bit-shift validation
  • Added link-local address range (169.254.x.y) to isPrivate() validation

@neatzsche neatzsche force-pushed the fix/peer-localhost-and-linklocal-validation branch from 6876b88 to 0f21898 Compare February 5, 2026 22:14
@neatzsche neatzsche force-pushed the fix/peer-localhost-and-linklocal-validation branch from 0f21898 to bb354c2 Compare February 5, 2026 22:15
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.

1 participant