Skip to content

[BUG] IPv6 upstream addresses are parsed incorrectly by colon splitting #6442

Open

Description

@Aias00

Current Behavior

Several admin/common runtime paths parse upstream URLs by splitting on :. This breaks valid IPv6 upstream addresses.

Evidence:

  • shenyu-common/src/main/java/org/apache/shenyu/common/utils/UpstreamCheckUtils.java:67-73
  • shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/LoadServiceDocEntryImpl.java:153-158
  • shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java:352-361

Examples:

hostPort = StringUtils.split(http[1], Constants.COLONS);
...
String[] upstreamUrlArr = discoveryUpstreamData.getUrl().split(":");
...
.map(url -> url.split(":", 2))

For valid IPv6 literals such as [2001:db8::1]:8080 or http://[2001:db8::1]:8080, colon splitting truncates the host and/or attempts to parse part of the IPv6 literal as a port. That can produce a failed health check, wrong discovery upstream data, or NumberFormatException.

Expected Behavior

Valid IPv6 upstream addresses should be parsed with URI/host-port aware logic and should work in health checks, discovery conversion, and API document loading.

Steps To Reproduce

Use an upstream URL such as:

[2001:db8::1]:8080
http://[2001:db8::1]:8080

Then trigger one of these paths:

  • upstream health check via UpstreamCheckUtils.checkUrl(...)
  • discovery upstream conversion via DiscoveryTransfer.mapToDiscoveryUpstreamData(...)
  • API document instance loading via LoadServiceDocEntryImpl.getInstances2(...)

Suggested Fix

Use java.net.URI or a host-port parser that supports bracketed IPv6 literals. Avoid raw split(":") for URLs or host:port strings.

Activity

  1. github-actions commented on Jul 23, 2026

    @github-actions
    Contributor

    👋 Hello @yuluo-yx

    A new issue has been opened by @Aias00:

    Please review when you have time. Thank you! 🙏

  2. wy471x commented on Jul 24, 2026

    @wy471x
    Contributor

    /assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions