Closed Bug 1357330 Opened 7 years ago Closed 7 years ago

Frozen NaN-valued property can be overwritten with different NaN value

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox-esr45 --- wontfix
firefox-esr52 --- wontfix
firefox53 --- wontfix
firefox54 --- wontfix
firefox55 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

(Keywords: sec-other, Whiteboard: [adv-main55-][post-critsmash-triage])

Attachments

(2 files, 1 obsolete file)

Test case:
---
function byteValue(value) {
  var isLittleEndian = new Uint8Array(new Uint16Array([1]).buffer)[0] !== 0;
  var ui8 = new Uint8Array(new Float64Array([value]).buffer);

  var hex = "0123456789ABCDEF";
  var s = "";
  for (var i = 0; i < 8; ++i) {
    var v = ui8[isLittleEndian ? 7 - i : i];
    s += hex[(v >> 4) & 0xf] + hex[v & 0xf];
  }
  return s;
}

var obj = {};
Object.defineProperty(obj, "prop", {value: NaN});
Object.defineProperty(obj, "prop", {value: -NaN});

assertEq(byteValue(obj.prop), byteValue(NaN));
---

Expected: Test passes
Actual: Assertion failed: got "FFF8000000000000", expected "7FF8000000000000"
Attached patch bug1357330.patchSplinter Review
Adds the missing step 7.a.i.3. from ES2018 9.1.6.3 ValidateAndApplyPropertyDescriptor. Also updates a couple of outdated comments and replaces manual bit-testing for shape attributes with the existing IsXXX helpers.
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8859285 - Flags: review?(shu)
Comment on attachment 8859285 [details] [diff] [review]
bug1357330.patch

Review of attachment 8859285 [details] [diff] [review]:
-----------------------------------------------------------------

Nice find, could you commit a test for this as well?

Out of curiosity, was this observable some other way than distinct NaNs before, like Proxy traps?
Attachment #8859285 - Flags: review?(shu) → review+
What's the severity of this and how far back does it go?
Flags: needinfo?(andrebargull)
Is this the immediately exploitable kind of security-sensitive or is it the leaking information kind of security-sensitive?
(In reply to [Out of Office Until 24-April] Ryan VanderMeulen [:RyanVM] from comment #3)
> What's the severity of this and how far back does it go?

I think it goes back to bug 1125624 and bug 1148750. For the severity I'd probably go with sec-other, because this issue is limited to different NaN values and when similar issues happened in the past (search for "non-configurable" or "frozen"), most of the time we didn't even treat them as sec-bugs.
Flags: needinfo?(andrebargull)
Attached patch bug1357330-testcase.patch (obsolete) — Splinter Review
Test case from comment #0. 

We'll get more thorough coverage through test262 as soon as I fix (and extend) [1].

[1] https://github.com/tc39/test262/blob/master/test/built-ins/Object/internals/DefineOwnProperty/nan-equivalence.js
Attachment #8859497 - Flags: review?(shu)
(In reply to Shu-yu Guo [:shu] from comment #2)
> Nice find, could you commit a test for this as well?

Added.

> Out of curiosity, was this observable some other way than distinct NaNs
> before, like Proxy traps?

No, I don't think so. This should only be reproducible with native objects.
Comment on attachment 8859497 [details] [diff] [review]
bug1357330-testcase.patch

Forgot to qref, will add the proper patch later. :-/
Attachment #8859497 - Attachment is obsolete: true
Attachment #8859497 - Flags: review?(shu)
Attachment #8859570 - Flags: review?(shu)
Attachment #8859570 - Flags: review?(shu) → review+
Keywords: sec-other
Group: core-security → javascript-core-security
Keywords: checkin-needed
https://hg.mozilla.org/integration/mozilla-inbound/rev/76bff2cde94c44b7bd1c3d2ce847db095175577f
https://hg.mozilla.org/integration/mozilla-inbound/rev/da5a14ae4ce3084aa63a502e96af1a4c6ef76853

Doesn't sound like it's worth backporting to ESR52 (and Fx54 RC build is this week, so won't be going there either), but feel free to set the status back to affected and argue for it if you feel otherwise.
https://hg.mozilla.org/mozilla-central/rev/76bff2cde94c
https://hg.mozilla.org/mozilla-central/rev/da5a14ae4ce3
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Group: javascript-core-security → core-security-release
Whiteboard: [adv-main55-]
Flags: qe-verify-
Whiteboard: [adv-main55-] → [adv-main55-][post-critsmash-triage]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: