Skip to content

fix(nameserver): reject structurally invalid IPv6 address literals - #2869

Open
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-nameserver-ipv6-literals
Open

fix(nameserver): reject structurally invalid IPv6 address literals#2869
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-nameserver-ipv6-literals

Conversation

@yyqdbngt

Copy link
Copy Markdown

Summary

  • NamesrvAddrParser.isValidIpv6Literal now performs a full address-literal parse
    (InetAddress.getByName, after the existing character-set pre-filter that prevents
    any DNS lookup) in addition to the character/colon checks.
  • Added regression tests: literals with too few groups ([1:2:3], [ffff:0]) are
    rejected, and full-form literals are accepted and lowercased.

Why

The old check only validated the character set and required at least two colons, so
[1:2:3] — three groups, not a valid IPv6 address — was accepted into the registry
and only failed much later when the probe connected through the RocketMQ client. The
pre-filtered character set guarantees getByName treats the value as a literal (no
hostname, no DNS), so the parse adds full structural validation without the
unbounded-resolution risk the parser was designed to avoid.

Testing

  • cd server && mvn -Dtest=NamesrvAddrParserTest test — Tests run: 17, Failures: 0, Errors: 0
  • cd server && mvn -Dtest=NameserverRegistryServiceTest,NameServerControllerTest test
    — Tests run: 36, Failures: 0, Errors: 0

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

Solid fix — the old validation only checked character set + colon count, so [1:2:3] was incorrectly accepted. Using InetAddress.getByName after the character pre-filter is safe (no DNS risk) and provides full structural validation. Good regression tests.

LGTM.


Automated review by github-manager-bot

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

Defensive fix that improves input validation and error handling. Code looks clean and follows existing patterns.

LGTM


Automated review by "github-manager-bot"

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — defensive fix improving input validation and error handling.


Automated review by "github-manager-bot"

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.

3 participants