Skip to content

[ZSvirt] bug: IPv6 security-group ranges are compared lexicographically #30

Description

@tllovesxs

Component

securityGroup

Problem description

IPv6 range validation compares the textual forms of the start and end addresses with String.compareTo instead of comparing parsed IPv6 values.

Relevant code:
https://github.com/ZSvirt/zsvirt/blob/main/plugin/securityGroup/src/main/java/org/zstack/network/securitygroup/SecurityGroupApiInterceptor.java#L809

For example, 2001:db8::2-2001:db8::10 is a valid ascending range numerically, but the string comparison sees "2" as greater than "1" and rejects it. Conversely, some reversed ranges can pass this check.

Steps to reproduce

  1. Create an IPv6 security group.
  2. Add a rule whose IPv6 source or destination range is 2001:db8::2-2001:db8::10.
  3. Observe that the rule is rejected as an invalid range.

Expected behavior

IPv6 range ordering should be evaluated numerically after parsing both addresses.

Proposed fix

Reuse IPv6NetworkUtils.isValidIpRange or compare parsed IPv6Address values, and add regression cases for multi-digit host portions and reversed ranges.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions