Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-419

Invalid IPv6 addresses that are IPv4-mapped pass InetAddressValidator validation

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.6
    • Component/s: Routines
    • Labels:
      None

      Description

      1) InetAddressValidator.getInstance().isValidInet6Address(String inet6Address) returns true for value 0::ffff:192.168.1.1:192.168.1.1

      I believe this is due to wrong comparison operand in line #166 of InetAddressValidator:

      if (index > octets.length - 1 || index > 6) {  // CHECKSTYLE IGNORE MagicNumber
          // IPV4 occupies last two octets
          return false;
      }
      

      index > octets.length - 1 expression will never be true inside cycle

      for (int index = 0; index < octets.length; index++)

      2) According to https://tools.ietf.org/html/rfc4291 IPv6 address that is IPv4-mapped must start with five zero octets followed by one ffff octet. Current implementation of InetAddressValidator does not check this. E.g. 1::2:192.168.1.1 is considered valid.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Denis Iskhakov Denis Iskhakov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: