Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8227177

INetAddress#isAnyLocalAddress() returns false for 0177.1

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      uname -a
      Linux david-thinkpad 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
      Java Version 1.8.0_162 (64 Bit)


      A DESCRIPTION OF THE PROBLEM :
      When you get the INetAddress of 0177.1 isAnyLocalAddress() and isLoopbackAddress() both return false.
      I Also checked localhost, [::], [0:0:0:0:0:0:0:0], 0.0.0.0, 127.0.0.2, 127.0.0.1, 0177.1 (DOES NOT WORK), 0x7f.1, 127.1, [::1], 017700000001, 0x7f.1, 0x7f.0.0.1, 0x7f000001, 2130706433, 127.000.000.001, 127.0.1, [0:0:0:0:0:ffff:0.0.0.0], [::ffff:0.0.0.0], [::ffff:0:0], [0:0:0:0:0:ffff:127.0.0.1], [::ffff:127.0.0.1], [::ffff:7f00:1], [0:0:0:0:0:ffff:127.0.0.2], [::ffff:127.0.0.2], [::ffff:7f00:2] all this addresses return true for isAnyLocalAddress().
      0177.1 seems the only localhost address that i came up with that returns fasle in isAnyLocalAddress().

      Ping on 0177.1 works totally fine. This could actually could be a more trivial bug than it might look. Imagine software that downloads an Url that can be controlled by a user to not connect to local services you check if the host of the URL is the localhost. With 0177.1 you can trick the application into thinking it is a remote host.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Get an INetAddress with name 0177.1 and check isAnyLocalAddress() and isLoopbackAddress()

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      0177.1 is a local address and therefore should return true.
      ACTUAL -
      isAnyLocalAddress() and isLoopbackAddress() both return false

      ---------- BEGIN SOURCE ----------
      public class Test {
          public static void main(String[] args) throws Exception {
              assert InetAddress.getByName("0177.1").isAnyLocalAddress():
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: