Re: ipv6 bug in jcifs.netbios.NbtAddress

"Christopher R. Hertel" <[email protected]> Tue, 25 Aug 2015 14:10:33 -0500
Newsgroups gmane.network.samba.java
Message-ID <CAPa6gr+0SGpMkvM6BnSgvc6PSPdMgPTHg+-4wSWwg67AeWwnwA@mail.gmail.com>
--001a11c22a2806db2c051e277d21
Content-Type: text/plain; charset=UTF-8

See RFC1001/1002.  The NBT protocol has IPv4 address fields hard-coded.
You can't map an IPv6 address to/from an NBT Address.

Chris -)-----

On Tue, Aug 25, 2015 at 5:07 AM, Pascal Rigaux <[email protected]
> wrote:

> Hi,
>
> We've been wondering why our server was doing weird accesses to Poland.
> The culprit is in
> https://jcifs.samba.org/src/src/jcifs/netbios/NbtAddress.java, hashCode
> is used on a InetAddress:
>
>   localhost = new NbtAddress(localName, localInetAddress.hashCode(), ...)
>
> In ipv4, it's ok (
> https://github.com/samskivert/ikvm-openjdk/blob/master/jdk/src/share/classes/java/net/Inet4Address.java#L330-L332
> )
> but not in ipv6 (
> https://github.com/samskivert/ikvm-openjdk/blob/master/jdk/src/share/classes/java/net/Inet6Address.java#L642
> )
>
> Context:
> - SPNEGO implemented in CAS server (
> https://wiki.jasig.org/display/CASUM/SPNEGO)
> - NTLM unused but somehow some firefox are sending NTLMSSP instead of
> Kerberos, which caused accesses to weird servers which drops the request,
> blocking our server :-(
> I hope it's clear enough... I unfortunately had to look at things i really
> do not master...
>
> cu,
> Pascal Rigaux.
>
>
> Test case:
>
> import java.net.InetAddress;
> class Test {
>    static int fromHex(String s, int offset) {
>         return Integer.parseInt(s.substring(offset, offset + 2), 16);
>    }
>    public static void main(String[] args) throws
> java.net.UnknownHostException {
>        InetAddress i = InetAddress.getLocalHost();
>        String s = Integer.toHexString(i.hashCode());
>        System.out.println(fromHex(s, 0) + "." + fromHex(s, 2) + "." +
> fromHex(s, 4) + "." + fromHex(s, 6));
>    }
> }
>
> % javac Test.java
> % java Test
> 83.6.6.183
> % java -Djava.net.preferIPv4Stack=true Test
> 193.55.96.57
>
> (precision: the server has ipv6 2001:660:3305::57)
>
> --
> Ce message a ete verifie par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a ete trouve.
>
>
>


-- 
"Implementing CIFS - the Common Internet FileSystem" ISBN: 013047116X
Samba Team -- http://www.samba.org/     -)-----   Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/   -)-----   ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/     -)-----   [email protected]
OnLineBook -- http://ubiqx.org/cifs/    -)-----   [email protected]

--001a11c22a2806db2c051e277d21
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>See RFC1001/1002.=C2=A0 The NBT protocol has IPv4 add=
ress fields hard-coded.=C2=A0 You can&#39;t map an IPv6 address to/from an =
NBT Address.<br><br></div>Chris -)-----<br></div><div class=3D"gmail_extra"=
><br><div class=3D"gmail_quote">On Tue, Aug 25, 2015 at 5:07 AM, Pascal Rig=
aux <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" t=
arget=3D"_blank">[email protected]</a>&gt;</span> wrote:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex">Hi,<br>
<br>
We&#39;ve been wondering why our server was doing weird accesses to Poland.=
<br>
The culprit is in <a href=3D"https://jcifs.samba.org/src/src/jcifs/netbios/=
NbtAddress.java" rel=3D"noreferrer" target=3D"_blank">https://jcifs.samba.o=
rg/src/src/jcifs/netbios/NbtAddress.java</a>, hashCode is used on a InetAdd=
ress:<br>
<br>
=C2=A0 localhost =3D new NbtAddress(localName, localInetAddress.hashCode(),=
 ...)<br>
<br>
In ipv4, it&#39;s ok ( <a href=3D"https://github.com/samskivert/ikvm-openjd=
k/blob/master/jdk/src/share/classes/java/net/Inet4Address.java#L330-L332" r=
el=3D"noreferrer" target=3D"_blank">https://github.com/samskivert/ikvm-open=
jdk/blob/master/jdk/src/share/classes/java/net/Inet4Address.java#L330-L332<=
/a> )<br>
but not in ipv6 ( <a href=3D"https://github.com/samskivert/ikvm-openjdk/blo=
b/master/jdk/src/share/classes/java/net/Inet6Address.java#L642" rel=3D"nore=
ferrer" target=3D"_blank">https://github.com/samskivert/ikvm-openjdk/blob/m=
aster/jdk/src/share/classes/java/net/Inet6Address.java#L642</a> )<br>
<br>
Context:<br>
- SPNEGO implemented in CAS server (<a href=3D"https://wiki.jasig.org/displ=
ay/CASUM/SPNEGO" rel=3D"noreferrer" target=3D"_blank">https://wiki.jasig.or=
g/display/CASUM/SPNEGO</a>)<br>
- NTLM unused but somehow some firefox are sending NTLMSSP instead of Kerbe=
ros, which caused accesses to weird servers which drops the request, blocki=
ng our server :-(<br>
I hope it&#39;s clear enough... I unfortunately had to look at things i rea=
lly do not master...<br>
<br>
cu,<br>
Pascal Rigaux.<br>
<br>
<br>
Test case:<br>
<br>
import java.net.InetAddress;<br>
class Test {<br>
=C2=A0 =C2=A0static int fromHex(String s, int offset) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return Integer.parseInt(s.substring(offset, off=
set + 2), 16);<br>
=C2=A0 =C2=A0}<br>
=C2=A0 =C2=A0public static void main(String[] args) throws java.net.Unknown=
HostException {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0InetAddress i =3D InetAddress.getLocalHost();<br=
>
=C2=A0 =C2=A0 =C2=A0 =C2=A0String s =3D Integer.toHexString(i.hashCode());<=
br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0System.out.println(fromHex(s, 0) + &quot;.&quot;=
 + fromHex(s, 2) + &quot;.&quot; + fromHex(s, 4) + &quot;.&quot; + fromHex(=
s, 6));<br>
=C2=A0 =C2=A0}<br>
}<br>
<br>
% javac Test.java<br>
% java Test<br>
83.6.6.183<br>
% java -Djava.net.preferIPv4Stack=3Dtrue Test<br>
193.55.96.57<br>
<br>
(precision: the server has ipv6 2001:660:3305::57)<span class=3D"HOEnZb"><f=
ont color=3D"#888888"><br>
<br>
-- <br>
Ce message a ete verifie par MailScanner<br>
pour des virus ou des polluriels et rien de<br>
suspect n&#39;a ete trouve.<br>
<br>
<br>
</font></span></blockquote></div><br><br clear=3D"all"><br>-- <br><div clas=
s=3D"gmail_signature"><div dir=3D"ltr"><span style=3D"font-family:courier n=
ew,monospace">&quot;Implementing CIFS - the Common Internet FileSystem&quot=
; ISBN: 013047116X<br>Samba Team -- <a href=3D"http://www.samba.org/" targe=
t=3D"_blank">http://www.samba.org/</a>=C2=A0=C2=A0=C2=A0=C2=A0 -)-----=C2=
=A0=C2=A0 Christopher R. Hertel<br>jCIFS Team -- <a href=3D"http://jcifs.sa=
mba.org/" target=3D"_blank">http://jcifs.samba.org/</a>=C2=A0=C2=A0 -)-----=
=C2=A0=C2=A0 ubiqx development, uninq.<br>ubiqx Team -- <a href=3D"http://w=
ww.ubiqx.org/" target=3D"_blank">http://www.ubiqx.org/</a>=C2=A0=C2=A0=C2=
=A0=C2=A0 -)-----=C2=A0=C2=A0 <a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a><br>OnLineBook -- <a href=3D"http://ubiqx.org/=
cifs/" target=3D"_blank">http://ubiqx.org/cifs/</a>=C2=A0=C2=A0=C2=A0 -)---=
--=C2=A0=C2=A0 <a href=3D"mailto:[email protected]" target=3D"_blank">crh@ubiqx=
.org</a><br><br></span></div></div>
</div>

--001a11c22a2806db2c051e277d21--