Skip to content

fix(net): reject unknown inventory type in P2P inv/fetch-inv handling#6851

Open
xxo1shine wants to merge 1 commit into
tronprotocol:release_v4.8.2from
xxo1shine:fix/p2p-reject-unknown-inventory-type
Open

fix(net): reject unknown inventory type in P2P inv/fetch-inv handling#6851
xxo1shine wants to merge 1 commit into
tronprotocol:release_v4.8.2from
xxo1shine:fix/p2p-reject-unknown-inventory-type

Conversation

@xxo1shine

Copy link
Copy Markdown
Collaborator

What does this PR do?
Validate the inventory type at the inbound entry points and reject any value other than TRX or BLOCK with P2pException(BAD_MESSAGE), before the type is used for cache insertion or outbound fetch construction:

  • P2pEventHandlerImpl.checkInvRateLimit: add else branch for unknown type
  • InventoryMsgHandler.check: add type allowlist check
  • FetchInvDataMsgHandler.check: validate raw getInventoryType() instead of getInvMessageType() (which mapped non-BLOCK types to TRX)

Use getTypeValue() when building the error message to avoid calling getNumber() on an UNRECOGNIZED enum value. Add regression tests for all three entry points.

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

Validate the inventory type at the inbound entry points and reject any value
other than TRX or BLOCK with P2pException(BAD_MESSAGE), before the type is
used for cache insertion or outbound fetch construction:
- P2pEventHandlerImpl.checkInvRateLimit: add else branch for unknown type
- InventoryMsgHandler.check: add type allowlist check
- FetchInvDataMsgHandler.check: validate raw getInventoryType() instead of
  getInvMessageType() (which mapped non-BLOCK types to TRX)

Use getTypeValue() when building the error message to avoid calling
getNumber() on an UNRECOGNIZED enum value. Add regression tests for all
three entry points.
@github-actions github-actions Bot requested a review from 317787106 June 22, 2026 11:23
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