Workaround for the JVM Double parsing vulnerability

298 views
Skip to first unread message

David Pollak

unread,
Feb 1, 2011, 12:44:36 PM2/1/11
to liftweb
Folks,

There was a vulnerability identified on the JVM where a certain String, when parsed to a Double, would cause the current thread to hang.

To mitigate this issue, all direct calls to java.lang.Double.parseDouble and all calls to that method indirectly through Scala's .toDouble method have been replaced by calls to net.liftweb.common.ParseDouble.apply

ParseDouble throws an exception if the bad magic number is passed as a String.

This code is currently part of master and will be rolled into Lift 2.3-M1.

If you are a user of a prior version of Lift and need this patch applied to a prior version of Lift, please contact me privately with your application/URL so I can gauge the number of folks who cannot upgrade to 2.3-M1.

Thanks,

David

--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

CM Lubinski

unread,
Feb 1, 2011, 1:08:37 PM2/1/11
to lif...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is helpful, but will still fail if one moves the decimal around:
22.250738585072012e-309
222.50738585072012e-310
etc.

Perhaps check for those digits and an appropriate negative exponent?

Thanks,
CM Lubinski

On 02/01/2011 11:44 AM, David Pollak wrote:
> Folks,
>
> There was a vulnerability identified on the JVM where a certain String, when
> parsed to a Double, would cause the current thread to hang.
>
> To mitigate this issue, all direct calls to java.lang.Double.parseDouble and
> all calls to that method indirectly through Scala's .toDouble method have
> been replaced by calls to net.liftweb.common.ParseDouble.apply
>
> ParseDouble throws an exception if the bad magic number is passed as a
> String.
>
> This code is currently part of master and will be rolled into Lift 2.3-M1.
>
> If you are a user of a prior version of Lift and need this patch applied to
> a prior version of Lift, please contact me privately with your
> application/URL so I can gauge the number of folks who cannot upgrade to
> 2.3-M1.
>
> Thanks,
>
> David
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk1ITCQACgkQfzi1OiZiJLCi6wCfWN6hqeCnzGyMEGDHt0gGy9b5
0x4An2O0P7xQbq+4hc6V2AJvb0+Fp75X
=CG4x
-----END PGP SIGNATURE-----

Sander Mak

unread,
Feb 1, 2011, 1:55:28 PM2/1/11
to Lift
On Tue, Feb 1, 2011 at 6:44 PM, David Pollak
<feeder.of...@gmail.com> wrote:

> ParseDouble throws an exception if the bad magic number is passed as a
> String.

Or you could return the correct value (scala.Double.MinValue) rather
than throwing an exception?

Sander Mak

unread,
Feb 1, 2011, 1:17:57 PM2/1/11
to lif...@googlegroups.com
On Tue, Feb 1, 2011 at 6:44 PM, David Pollak
<feeder.of...@gmail.com> wrote:

> ParseDouble throws an exception if the bad magic number is passed as a
> String.

Or you could return the correct value (scala.Double.MinValue) rather
than throwing an exception?

Debilski

unread,
Feb 1, 2011, 2:06:23 PM2/1/11
to Lift


On 1 Feb., 19:17, Sander Mak <sander...@gmail.com> wrote:
> On Tue, Feb 1, 2011 at 6:44 PM, David Pollak
>
> <feeder.of.the.be...@gmail.com> wrote:
> > ParseDouble throws an exception if the bad magic number is passed as a
> > String.
>
> Or you could return the correct value (scala.Double.MinValue) rather
> than throwing an exception?

scala.Double.MinValue is something else entirely.

Sander Mak

unread,
Feb 1, 2011, 2:18:12 PM2/1/11
to lif...@googlegroups.com
On Tue, Feb 1, 2011 at 8:06 PM, Debilski
<rikebenjami...@googlemail.com> wrote:
>
> scala.Double.MinValue is something else entirely.

Oh? I was looking for the Scala equivalent of
java.lang.Double.MIN_VALUE, found this:

scala.math.MIN_DOUBLE: The smallest possible value for scala.Double.
deprecated: Use scala.Double.MinValue instead

Hence my suggestion. But I looked up the ScalaDoc for
scala.Double,MinValue and found:

deprecated: use Double.MinNegativeValue instead

nice, chained deprecation. And that's when I found out the values
differ as well (and that's probably what you meant). Interesting.

Sander Mak

unread,
Feb 1, 2011, 2:45:32 PM2/1/11
to lif...@googlegroups.com
On Tue, Feb 1, 2011 at 8:06 PM, Debilski
<rikebenjami...@googlemail.com> wrote:

> scala.Double.MinValue is something else entirely.

Yeah, I misread DBL_MIN (which is apparently the smallest normalized
positive floating-point double) to mean the MIN_VALUE of the Double
type, which is indeed an entirely different number. Still, my point
stands that there *is* a correct value that can be returned for the
'magic double of death'.

Debilski

unread,
Feb 1, 2011, 3:27:46 PM2/1/11
to Lift


On 1 Feb., 20:45, Sander Mak <sander...@gmail.com> wrote:
> On Tue, Feb 1, 2011 at 8:06 PM, Debilski
>
> <rikebenjamin.schupp...@googlemail.com> wrote:
> > scala.Double.MinValue is something else entirely.
>
> Yeah, I misread DBL_MIN (which is apparently the smallest normalized
> positive floating-point double) to mean the MIN_VALUE of the Double
> type, which is indeed an entirely different number. Still, my point
> stands that there *is* a correct value that can be returned for the
> 'magic double of death'.

From reading some articles, I guess the number should be rounded(?) to
math.pow(2, -1022) (or even math.pow(2, -1022) - math.pow(2, -1074)).
But on the other hand, I don’t know enough about IEEE numbers on the
JVM… (And also, is the smallest normalised double the same on all
JVMs?)

Sander Mak

unread,
Feb 2, 2011, 3:24:19 PM2/2/11
to lif...@googlegroups.com
Charlie Nutter from JRuby explains their workaround:
http://blog.headius.com/2011/02/working-around-java-doubleparsedouble.html

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>

David Pollak

unread,
Feb 3, 2011, 6:19:46 PM2/3/11
to lif...@googlegroups.com
On Wed, Feb 2, 2011 at 12:24 PM, Sander Mak <sand...@gmail.com> wrote:
Charlie Nutter from JRuby explains their workaround:
http://blog.headius.com/2011/02/working-around-java-doubleparsedouble.html


I'm going to re-open the ticket and let the dust settle on the best solution to the issue before updating Lift.
 

Indrajit Raychaudhuri

unread,
Jul 18, 2011, 10:38:40 AM7/18/11
to lif...@googlegroups.com
Ever since, Oracle has released a security alert [1], a patch to deal
with this in older JVMs [2].
Further Oracle (Apple in case of OS X) have pushed out newer
maintenance versions of JVM for the platforms on which Lift runs.

So unless there is any strong reason for the contrary, I'm proposing
deprecation and eventual removal of ParseDouble.

Thoughts/Opinions?

- Indrajit

[1] http://blogs.oracle.com/security/entry/security_alert_for_cve-2010-44
[2] http://www.oracle.com/technetwork/java/javase/fpupdater-tool-readme-305936.html


On Friday 4 February 2011 at 4:49 AM, David Pollak wrote:

>
>
> On Wed, Feb 2, 2011 at 12:24 PM, Sander Mak <sand...@gmail.com (mailto:sand...@gmail.com)> wrote:
> > Charlie Nutter from JRuby explains their workaround:
> > http://blog.headius.com/2011/02/working-around-java-doubleparsedouble.html
>
> I'm going to re-open the ticket and let the dust settle on the best solution to the issue before updating Lift.
> > On Tue, Feb 1, 2011 at 9:27 PM, Debilski

> > <rikebenjami...@googlemail.com (mailto:rikebenjami...@googlemail.com)> wrote:


> > >
> > >
> > > On 1 Feb., 20:45, Sander Mak <sander...@gmail.com (mailto:sander...@gmail.com)> wrote:
> > > > On Tue, Feb 1, 2011 at 8:06 PM, Debilski
> > > >
> > > > <rikebenjamin.schupp...@googlemail.com (mailto:rikebenjamin.schupp...@googlemail.com)> wrote:
> > > > > scala.Double.MinValue is something else entirely.
> > > >
> > > > Yeah, I misread DBL_MIN (which is apparently the smallest normalized
> > > > positive floating-point double) to mean the MIN_VALUE of the Double
> > > > type, which is indeed an entirely different number. Still, my point
> > > > stands that there *is* a correct value that can be returned for the
> > > > 'magic double of death'.
> > >
> > > From reading some articles, I guess the number should be rounded(?) to
> > > math.pow(2, -1022) (or even math.pow(2, -1022) - math.pow(2, -1074)).
> > > But on the other hand, I don’t know enough about IEEE numbers on the
> > > JVM… (And also, is the smallest normalised double the same on all
> > > JVMs?)
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups "Lift" group.

> > > To post to this group, send email to lif...@googlegroups.com (mailto:lif...@googlegroups.com).
> > > To unsubscribe from this group, send email to liftweb+u...@googlegroups.com (mailto:liftweb%2Bunsu...@googlegroups.com).


> > > For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Lift" group.

> > To post to this group, send email to lif...@googlegroups.com (mailto:lif...@googlegroups.com).
> > To unsubscribe from this group, send email to liftweb+u...@googlegroups.com (mailto:liftweb%2Bunsu...@googlegroups.com).


> > For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Blog: http://goodstuff.im
> Surf the harmonics

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.

> To post to this group, send email to lif...@googlegroups.com (mailto:lif...@googlegroups.com).
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com (mailto:liftweb+u...@googlegroups.com).

Peter Robinett

unread,
Jul 18, 2011, 2:51:49 PM7/18/11
to lif...@googlegroups.com
I guess the question is, what JVMs and versions does Lift support? I'm not sure...

Peter

Indrajit Raychaudhuri

unread,
Jul 18, 2011, 4:13:19 PM7/18/11
to lif...@googlegroups.com
Per the Getting Started page Java 5 or higher with servlet container supporting servlet API 2.5 [1].

Assuming a modern hosting or dev environment that support those conditions, it's almost certainly going to be a variant of Linux, Windows or OS X. I'd imagine one wouldn't purposely want to host an application on a JVM with documented security issue when an upgrade is available :)

[1] http://www.assembla.com/spaces/liftweb/wiki/Getting_Started

- Indrajit


On Tuesday 19 July 2011 at 12:21 AM, Peter Robinett wrote:

> I guess the question is, what JVMs and versions does Lift support? I'm not sure...
>
> Peter
>

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/Hc4O798rHkYJ.

Peter Robinett

unread,
Jul 19, 2011, 11:53:35 AM7/19/11
to lif...@googlegroups.com
Ok, good to know. Given that no one seems to be piping up that they're stuck on an old, non-patched JVM I guess there's no problem with deprecation.

Peter
Reply all
Reply to author
Forward
0 new messages