Re:Please do not put IP addresses into DNS MX records
by deathanatos on Sunday February 21, 2021 @03:22PM
(#26216791)
> If JSON is specified to only represent numbers that fit within a JavaScript double,
It isn't / doesn't make that restriction. For example,
10000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000
is a valid JSON value. Python will decode it to an integer with the equivalent value; JavaScript will decode it to "Infinity", as it exceeds the limits of Number. (Despite nowadays having a bigint type that could represent it.)It is possible to write a JSON parser in JavaScript that would handle decoding large numbers to BigInts. Most people just don't bother, as it's pretty rare to need to go above the 2 * 53 limit of JS's number.
Re:Please do not put IP addresses into DNS MX records
by woodruffw on Sunday February 21, 2021 @03:34PM
(#26216900)
You're absolutely right about that, and that's even worse than I had remembered! Not only can two parsers not be trusted to have equivalent acceptance contracts (in the absence of bugs), but they can correctly disagree on the acceptance of a single input!
The actual RFC language[1]:
> This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754-2008 binary64 (double precision) numbers [IEEE754] is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision.
Re:Please do not put IP addresses into DNS MX records
by dang on Sunday February 21, 2021 @04:45PM
(#26217560)
I added some newlines to your number because it was borking the page layout. Sorry; it's our bug.
Re:Please do not put IP addresses into DNS MX records
by DonHopkins on Sunday February 21, 2021 @06:12PM
(#26218320)
Not so liberal about what you accept, ehe? ;)
Re:Please do not put IP addresses into DNS MX records
by dang on Sunday February 21, 2021 @06:38PM
(#26218510)
We try to make up for it in the extreme narrowness of what we produce.
Re:Please do not put IP addresses into DNS MX records
by DaiPlusPlus on Tuesday February 23, 2021 @07:51AM
(#26236699)
Are you hiring? <_<
This is a great example of "paving over bad behavior with worse behavior."
If JSON is specified to only represent numbers that fit within a JavaScript double, then a correct parser must fail on numeric literals that don't fit into that type. It's up to me as a consumer to interpret strings that represent larger numbers.
I've had this exact kind of "helpful" behavior cause potentially exploitable bugs in programs before: a complex system was using more than one JSON parser, and parser Foo would accept numeric inputs that parser Bar would silently fail on (mangling large numbers into garbage). The result was a potential arbitrary read primitive.