fix(eth,p2p): use truncated names #21698#2441
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce log-spam / log-injection potential from remote-controlled devp2p peer names by truncating names in common logging paths while keeping full names available for peer metadata (e.g., RPC/admin peer info).
Changes:
- Move name truncation into
(*p2p.Peer).Name()and introduce a full-name accessor (Fullname) for consumers that need the raw advertised name. - Update
Peer.Info()to return the full advertised name instead of the abbreviated one. - Remove the local
truncateNamehelper fromp2p/server.goand usep.Name()when logging peer additions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| p2p/server.go | Switch peer-add debug logging to use Peer.Name() and remove the local truncation helper. |
| p2p/peer.go | Implement abbreviated Name(), add a full-name accessor, and ensure Peer.Info() returns the full advertised name. |
* peer: return localAddr instead of name to prevent spam We currently use the name (which can be freely set by the peer) in several log messages. This enables malicious actors to write spam into your geth log. This commit returns the localAddr instead of the freely settable name. * p2p: reduce usage of peer.Name in warn messages * eth, p2p: use truncated names * Update peer.go Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: Felix Lange <fjl@twurst.com>
Proposed changes
We currently use the name (which can be freely set by the peer) in several log messages. This enables malicious actors to write spam into your geth log. This commit returns the localAddr instead of the freely settable name.
p2p: reduce usage of peer.Name in warn messages
eth, p2p: use truncated names
Update peer.go
Ref: ethereum#21698
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that