Commit Graph

60 Commits

Author SHA1 Message Date
Chris Peterson
948e0e2be2 Bug 1511763 - Part 2: Make GetSpoofedUserAgent() infallible. r=tjr
Differential Revision: https://phabricator.services.mozilla.com/D13658
2018-12-02 21:24:16 -08:00
Chris Peterson
3da3dc8afc Bug 1511763 - Part 1: Fix spoofed ESR version calculation for Firefox 52+. r=tjr
The ESR release cadence changed from every 7 Firefox releases to 8.

Also, move strcmp() instead #ifdef DEBUG because it does nothing in release builds.

Differential Revision: https://phabricator.services.mozilla.com/D13657
2018-12-02 21:13:37 -08:00
Tom Ritter
264fe08c09 Bug 1509829 - Spoof OS in HTTP User-Agent header for desktop platforms r=timhuang,baku
In 1404608, the OS was revealed in both the HTTP User-Agent
header and to JavaScript code via navigator.userAgent. To avoid
leaking the OS inside each HTTP request (which many web servers
log), always use the Windows 7 OS value in the desktop User-Agent
header. We continue to allow access to the actual OS via JavaScript,
since doing so improves compatibility with web applications such
as GitHub and Google Docs.

This is an uplift of Tor's 26146
2019-01-09 12:53:30 -06:00
Emilio Cobos Álvarez
dc336a73ba Bug 1517241 - Rename nsIDocument to mozilla::dom::Document. r=smaug
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.

Overall it's not a very interesting patch I think.

nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.

I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.

While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.
2019-01-03 17:48:33 +01:00
Sylvestre Ledru
e5a134f73a Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset
2018-11-30 11:46:48 +01:00
Ehsan Akhgari
b614d2046a Bug 1508472 - Part 5: Fifth batch of comment fix-ups in preparation for the tree reformat r=sylvestre
This is a best effort attempt at ensuring that the adverse impact of
reformatting the entire tree over the comments would be minimal. I've used a
combination of strategies including disabling of formatting, some manual
formatting and some changes to formatting to work around some clang-format
limitations.

Differential Revision: https://phabricator.services.mozilla.com/D13371
2018-11-29 10:30:46 +00:00
Chris Peterson
5f40e8b4e4 Bug 583181 - Part 2: Add separate definitions for LEGACY_BUILD_ID and LEGACY_UA_GECKO_TRAIL. r=hsivonen
"Gecko trail" is the term used by MDN [1] for the YYYMMDD build date in the UA string's "Gecko/" token. Build ID is a YYYYMMDDHHMMSS build timestamp. Use LEGACY_BUILD_ID to spoof navigator.buildID. Use LEGACY_UA_GECKO_TRAIL to construct the UA string.

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox

Differential Revision: https://phabricator.services.mozilla.com/D7983
2018-10-01 21:27:34 -07:00
Andrea Marchesini
9574aec169 Bug 1489844 - Port DOMPrefs to StaticPrefs - part 18 - privacy.resistFingerprinting, r=ehsan 2018-09-10 20:36:17 +02:00
André Bargull
c89e9bba1c Bug 1346211 - Part 2: Split JS::ResetTimeZone into an external and internal implementation. r=Waldo 2018-08-16 09:13:18 -07:00
Kris Maglione
4a769c6113 Bug 1473631: Part 5 - Replace pref observers with callbacks in RFPService. r=njn
MozReview-Commit-ID: 6rzZNyY8cun
2018-07-05 13:49:22 -07:00
Jeff Gilbert
70a22b2878 Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot
MozReview-Commit-ID: JtTcLL5OPF0
2018-06-26 17:05:01 -07:00
Xidorn Quan
b755665128 Bug 1461933 - Remove ServoBindings.h from ComputedStyleInline.h. r=emilio
For doing this, ServoComputedData is split into separate files, so that
files don't need to include ServoBindings.h just for accessing style
structs from ComputedStyles.

MozReview-Commit-ID: DPAd7PUUCl9
2018-05-16 15:35:59 +10:00
Tom Ritter
e7bb3fcfd7 Bug 1418162 Use a build constant to determine update channel, and update ESR equation for 60 r=froydnj,Gijs
Previously we used Services.appinfo.defaultUpdateChannel to determine if we were on ESR
and if so, we would assert to make sure the ESR equation hadn't changed. But that method
is a footgun.  We could use UpdateUtils.getUpdateChannel, but for our purposes here, the
compile-time constant will work just as well.

If it's set correctly, for Mozilla, we will perform our assert check. If it's not set to
esr (e.g. for Tor), they'll skip the assert. They probably want to control their user agent
themselves anyway.

MozReview-Commit-ID: DLnWSEpCVJ6
2018-02-19 09:43:27 -06:00
Tom Ritter
76b8b19c27 Bug 1446346 Do not clamp or jitter the AudioContext's CurrentTime if its interval is larger than our precision. r=jib
MozReview-Commit-ID: Bc1cto3pBKL
2018-04-17 15:35:51 -05:00
Tom Ritter
a475d0314e Bug 1451790 Set Time Precision to 1ms with Jitter r=baku
MozReview-Commit-ID: 1uvEK2We4OQ
2018-04-05 11:37:36 -05:00
Tom Ritter
25bea2b0d3 Bug 1448869 Set Timer Precision to 100 us (with Jitter) r=baku
MozReview-Commit-ID: HV1rG4Kzg9k
2018-03-26 11:41:59 -05:00
Tom Ritter
4ed0b7896d Bug 1447685 Move nsIRandomGenerator creation out of a lock to avoid a deadlock r=keeler
do_GetService("@mozilla.org/security/random-generator;1" may initialize NSS.
NSS Initialization occurs on Main Thread only.

If we lock on a subthread, then try to initialize NSS, it _might_ be the case
that the main thread is blocked on the same lock (same location or a different
one.) NSS can't initialize on Main Thread - deadlock.

Move do_GetService out of the lock. Now if NSS tries to initialize on a
subthread, the main thead can't be blocked (because the subthread hasn't locked
anything.)

Now, the only statements that occur in locks are pointer asignment, new, memcpy,
and randomGenerator->GenerateRandomBytes.

MozReview-Commit-ID: 9C1Ok910A11
2018-03-22 13:09:23 -05:00
Tom Ritter
532570e6c4 Bug 1440195 Do not check for NSS Initialization before performing jitter r=keeler
Previously we needed this check because we were jittering before NSS was initialized
and this was causing tests to fail (primarily xpcshell and Marionette) because
NSS was being initialied before there was a profile directory.

In Bug 1443943 we only jitter non-System Principal calls and that reduces the early
jitter causes. Ultimately we got to a place where everything was looking okay whether
or not NSS was initialized by the time we got here, so we can simply this code and
simply always perform jittering (if it's enabled and we're not in System Principal
code.)

MozReview-Commit-ID: Dgfi8Z1hHfB
2018-03-09 21:27:44 -06:00
Tom Ritter
48710009ce Bug 1440195 Actually integrate the context mix-in into the hash function calculation r=baku
MozReview-Commit-ID: 4k7w683UJOY
2018-03-09 16:26:56 -06:00
Tom Ritter
5660579449 Bug 1440195 For timestamps that are absolute, specify a null context pointer r=baku
Note that by not using the same context pointer for all timestamps within a single
'communication group' (that is, all things that can communication to each other
in JavaScript), it's possible to observe time going backwards.

Imagine comparing
  performance.timeOrigin + performance.now() < new File([], "").lastModified

In theory this should always be true. However, if performance.now() was jittered
up (using one context pointer, because it is a relative timestamp) and File was
jittered down (using a null context pointer, because it is an absolute timestamp)
then this may evaluate to False.

I think this is okay.

MozReview-Commit-ID: BfgbmGS8XdD
2018-02-28 15:37:26 -06:00
Tom Ritter
b401d95a03 Bug 1440195 Add a per-context mix-in value for our Timer Precision Reduction Functions r=baku
We need to include a seed for each context (origin, iframe, worker, etc) we reduce
the time precision of. This prevents a replay attack of the random midpoint sequence.

MozReview-Commit-ID: EFoHev1SrTM
2018-03-09 16:22:37 -06:00
Tom Ritter
a6d21369b8 Bug 1444588 - Move LRUCache Initialization to startup rather than lazily. r=baku
Before, we would initialize LRUCache on the first instance of
calling the Timer Precision Reduction functions. We would both
allocate and initialize it, and call ClearOnShutdown.

ClearOnShutdown can only be called on the Main Thread, but it
just so happened that we always did that, so there was no
problem. Now that we are not calling precision reduction for
system callers, we were initializing on a non-main-thread and
we need to avoid that.

In the future, we could reduce memory use IF we are not using
the timer precision reduction functions by figuring out how
to initialize this lazily but still on the main thread. For
now, because we are using the timer precision reduction
functions, doing so would not save us any memory.

MozReview-Commit-ID: 6YGeAlCPReZ
2018-03-13 10:58:59 -07:00
Tom Ritter
2ca81ee9b6 Bug 1442515 Turn MOZ_LOG's in Timer Reduction on in non-debug builds also r=baku
MozReview-Commit-ID: C3JkX8RogeW
2018-03-06 10:15:39 -06:00
Arthur Edelstein
a22084bcd9 Bug 1433592 - Don't spoof ctrl key modifier for privacy.resistFingerprinting=true r=masayuki 2018-03-05 23:23:00 +02:00
Tom Ritter
bca6b1713d Bug 1442984 - Correct pointer math in timer fuzzing. r=baku
Negative input times would carry a negative sign all the way
through to where we do pointer math. That's bad, and embaressing.

As far as I know, there was no way to have the resulting value be
outside [-32, 28]. We coerce it down to [0, 28] to always stay in
bounds.
2018-03-05 13:04:32 -06:00
Tom Ritter
f9cbb711c3 Bug 1425462 Do not use crypto functions if NSS is not initialized. r=nwgh
Doing so caused nearly every xpcshell test to fail, as well as Marionette.
This is safe, because we're not going to be doing any web context stuff before NSS is
initialized, so anything that winds up here won't be exposed to content so we don't
really need to worry about fuzzing its value.

MozReview-Commit-ID: KiFSIbjQnN3
2018-03-02 10:05:19 -06:00
Tom Ritter
06b8824cf7 Bug 1425462 Refactor the static members into static globals to avoid leakchecks. r=ckerschb
MozReview-Commit-ID: 2lm1Skf3KEH
2018-03-01 05:24:36 -06:00
Tom Ritter
9ad1286f49 Bug 1425462 Turn jitter on by default. r=luke
MozReview-Commit-ID: 9u0rJ8FoteG
2018-02-15 15:35:42 -06:00
Tom Ritter
3e18680de3 Bug 1425462 Sprinkle some thread safety on the LRU Cache. r=handyman
We use a mozilla:Mutex to avoid race conditions in the LRU Cache

MozReview-Commit-ID: DyeK4RUnGhP
2018-02-24 08:21:15 -06:00
Tom Ritter
19af16408f Bug 1425462 Normalize the JavaScript Engine behavior by adding a callback r=luke
Time Precision Reduction in the JS Engine was handled by a small bit of
duplicated logic. With Time Jittering, and general improvements to the
logic due to float fuzziness, we want to unify the logic for the JS Engine
and the browser into one location. This patch does that.

Note that this will leave the JS Shell without a time jittering implementation.
It currently has a time clamping implementation - but I'm not actually sure if
the shell is doing anything with it, because it's probably not calling
SetTimeResolutionUsec to set it up.  In Bug 1440539 we will add a jitter
implementation for the shell. (And probably turn time rounding and jittering on
for it too.)

MozReview-Commit-ID: 2BTIMzE8MjW
2018-02-22 16:05:50 -06:00
Tom Ritter
53dda3e590 Bug 1425462 When reducing the precision of timestamps, also apply fuzzytime to them r=bkelly
Fuzzytime deterministically generates a random midpoint between two clamped values,
and if the unreduced timestamp is above the midpoint, the time is rounded upwards.
This allows safe time jittering to occur, as time will never go backwards on a given
timeline.

It _is_ possible for time to go backwards when comparing different (but related)
timelines, such as a relative timeline in one page (with its own
performance.timeOrigin) and a relative timeline in an iframe or Worker (which
also has its own performance.timeOrigin). This is the same behavior as the 2ms timer
reduction we previously landed; jitter doesn't make this any better or worse.

MozReview-Commit-ID: IdRLxcWDQBZ
2018-03-01 00:07:03 -06:00
Andreea Pavel
8314a3f558 Backed out changeset f15ab7984211 (bug 1433592) for failing browser chrome at browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js on a CLOSED TREE 2018-03-02 13:03:58 +02:00
Arthur Edelstein
14ac093b1f Bug 1433592 - Don't spoof ctrl key modifier for privacy.resistFingerprinting=true r=masayuki 2018-03-01 16:25:00 +02:00
Dorel Luca
8427275738 Backed out 6 changesets (bug 1425462) for XPCShell failure on multiple files
Backed out changeset 9ace3811f525 (bug 1425462)
Backed out changeset 7d440e52e3a4 (bug 1425462)
Backed out changeset 85896ea96faf (bug 1425462)
Backed out changeset 127b5d2e6779 (bug 1425462)
Backed out changeset 95ce64d3a29a (bug 1425462)
Backed out changeset ddd2c4da4ba4 (bug 1425462)
2018-03-02 03:33:17 +02:00
Tom Ritter
b82c627ae3 Bug 1425462 Refactor the static members into static globals to avoid leakchecks r=ckerschb
MozReview-Commit-ID: 2lm1Skf3KEH
2018-03-01 05:24:36 -06:00
Tom Ritter
107fd680c0 Bug 1425462 Turn jitter on by default r=luke
MozReview-Commit-ID: 9u0rJ8FoteG
2018-02-15 15:35:42 -06:00
Tom Ritter
2c16f29fb9 Bug 1425462 Sprinkle some thread safety on the LRU Cache r=handyman
We use a mozilla:Mutex to avoid race conditions in the LRU Cache

MozReview-Commit-ID: DyeK4RUnGhP
2018-02-24 08:21:15 -06:00
Tom Ritter
81b860c08e Bug 1425462 Normalize the JavaScript Engine behavior by adding a callback r=luke
Time Precision Reduction in the JS Engine was handled by a small bit of
duplicated logic. With Time Jittering, and general improvements to the
logic due to float fuzziness, we want to unify the logic for the JS Engine
and the browser into one location. This patch does that.

Note that this will leave the JS Shell without a time jittering implementation.
It currently has a time clamping implementation - but I'm not actually sure if
the shell is doing anything with it, because it's probably not calling
SetTimeResolutionUsec to set it up.  In Bug 1440539 we will add a jitter
implementation for the shell. (And probably turn time rounding and jittering on
for it too.)

MozReview-Commit-ID: 2BTIMzE8MjW
2018-02-22 16:05:50 -06:00
Tom Ritter
3bb968d575 Bug 1425462 When reducing the precision of timestamps, also apply fuzzytime to them r=bkelly
Fuzzytime deterministically generates a random midpoint between two clamped values,
and if the unreduced timestamp is above the midpoint, the time is rounded upwards.
This allows safe time jittering to occur, as time will never go backwards on a given
timeline.

It _is_ possible for time to go backwards when comparing different (but related)
timelines, such as a relative timeline in one page (with its own
performance.timeOrigin) and a relative timeline in an iframe or Worker (which
also has its own performance.timeOrigin). This is the same behavior as the 2ms timer
reduction we previously landed; jitter doesn't make this any better or worse.

MozReview-Commit-ID: IdRLxcWDQBZ
2018-03-01 00:07:03 -06:00
Tom Ritter
ec8416c544 Bug 1430841 Eliminate float fuzziness in ReduceTimerPrecision r=froydnj
We eliminate float fuzziness by calculating the reduced precision using
integers in microseconds. (This means we automatically lose any granularity
about nanoseconds, but that's okay.)

MozReview-Commit-ID: D9ReLknsafo
2018-02-12 16:17:03 -06:00
Tom Ritter
66e9777fa4 Bug 1430841 Refactor ReduceTimePrecision and add (failing) gtests r=bkelly
This commit adds a gtest calling ReduceTimePrecision that illustrates several
failing test cases from float fuzziness, as well as generating a ton of test
cases at random that also fail.

MozReview-Commit-ID: Epia5gm5Ahb
2018-02-12 13:11:18 -06:00
Tom Ritter
b87ec33e99 Bug 1429647 Switch privacy.reduceTimerPrecision and privacy.resistFingerprinting to use Relaxed Semantics r=froydnj,mystor
MozReview-Commit-ID: HdW4tmQAcTT
2018-01-24 18:09:43 -06:00
Tom Ritter
80bdd914d8 Bug 1435296 Do not apply timer clamping to CSS animations. r=birtles
This patch creates the capability to have callsites specify if timestamps
should be clamped only in Resist Fingerprinting Mode, or in the more expansive
Timer PRecision Reduction Mode.

Then it changes the CSS Animation callsite to only apply in RFP Mode.

This avoids regressing RFP.

MozReview-Commit-ID: B1pSri0kRk6
2018-02-07 16:50:57 -06:00
Tom Ritter
d098a89053 Bug 1435296 Bump the default timer precision resolution to 2ms r=baku
MozReview-Commit-ID: G33jNNJVRSU
2018-02-02 11:05:40 -06:00
Boris Zbarsky
3e6529d189 Bug 1436508 part 9. Remove nsIDOMKeyEvent::DOM_KEY* constants. r=masayuki
MozReview-Commit-ID: JXCCrbaMcn
2018-02-09 11:17:09 -05:00
Tom Ritter
4d42c63ef9 Bug 1431455 Fix a regression for ResistFingerprinting: use the larger of the reduceTimerPrecision pref and the constant 100ms r=bkelly
MozReview-Commit-ID: 73MpmfEKoQG
2018-01-18 11:25:59 -06:00
Tim Huang
e21040baac Bug 1222285 - Part 1: Spoofing the keyboard event to mimc a certain keyboard layout according to the content-language of the document when 'privacy.resistFingerprinting' is true. r=arthuredelstein,masayuki,smaug
This patch makes Firefox to spoof keyboardEvent.code, keyboardEvent.keycode and
modifier states, for 'Shift', 'Alt', 'Control' and 'AltGraph', when 'privacy.resistFingerprinting'
is true. Firefox will spoof keyboard events as a certain keyboard layout according
to the content language of the document, for example, we use US English keyboard for
English content. Right now, it only supports English contents, we will add more
support for more languages later. The spoofing only affects content, chrome
can still see real keyboard events.

MozReview-Commit-ID: 40JPvwLmMMB
2017-08-29 11:33:27 +08:00
Tom Ritter
8dec05b890 Bug 1429764 Do not call ReduceTimerPrecision twice for DOM Navigation timers r=bkelly,timhuang
Bug 1429764 details a test failure that was asserting that the performance navigation
timers were strictly increasing (or equal). fetchStart should have a timestamp before
domainLookupStart.  But it didn't.

The problem is two-fold.  This corrects the test and the issue by addressing one part
of the problem, the second part of the problem needs to be written up in a new bug
and addressed there. (That bug is not yet filed at writing, but see dependencies of
1429764 in the future to find it.)

The second, and underlying, problem is that calling ReduceTimerPrecision with the
same value multiple times may continually reduce it. Meaning that the first you call
it with, say, .75, (and a precision of .20), it will be reduced to .6. The second time
you call it (with .6), instead of staying at .6 it will be reduced to .4. This is
because floats are fuzzy. Inside ReduceTimerPrecision we are multiplying a decimal by
a decimal, so while floor(.6 / .20)  should equal 3, sometimes it's actually 2.999...
which gets floors to 2, gets multiplied again by .2, and which results in .4

If that's the underlying problem, the first, and surface, problem is - why are we
calling ReduceTimerPrecision multiple times? We shouldn't be. That's what this
patch fixes.

TimeStampToDOMHighResOrFetchStart will return either TimeStampToDOMHighRes() or
FetchStartHighRes(). FetchStartHighRes() internally calls TimeStampToDOMHighRes
and then ReduceTimerPrecision - this is where (some of) the two reduction calls
happen - because TimeStampToDOMHighRes itself calls ReduceTimerPrecision also.

I remove the ReduceTimerPrecision from TimeStampToDOMHighRes. FetchStartHighRes
will now only call ReduceTimerPrecision once, at the end of the return.

But we have to fix places we call TimeStampToDOMHighResOrFetchStart, because the
callers of that function also call ReduceTimerPrecision. So if
TimeStampToDOMHighResOrFetchStart returned FetchStartHighRes, we'd be calling
ReduceTimerPrecision twice for those callers.

So inside first off, we remove the outer call to ReduceTimerPrecision. that
surrounds the 5 or so callsites of TimeStampToDOMHighResOrFetchStart. Then
inside of TimeStampToDOMHighResOrFetchStart we return either FetchStartHighRes
(which is has already called ReduceTimerPrecision) or we call
ReduceTimerPrecision with the value.

Now. TimeStampToDOMHighRes was used in more places than just FetchStartHighRes -
there were several other places where we were doing double rounding, and this
fixed those as well. AsyncOpenHighRes, WorkerStartHighRes, DomainLookupEndHighRes,
ConnectStartHighRes, SecureConnectionStartHighRes, ConnectEndHighRes, and
ResponseEndHighRes.

MozReview-Commit-ID: K5nHql135rb
2018-01-12 13:36:04 -06:00
Tom Ritter
93237c0b72 Bug 1429885 Support a rounding value of 0 for reduceTimerPrecision r=bkelly,timhuang
MozReview-Commit-ID: F96EUfXgK9F
2018-01-11 14:25:14 -06:00
Tom Ritter
0a8b5b6e7c Bug 1424341 Add privacy.reduceTimerPrecision and privacy.reduceTimerPrecision.microseconds prefs r=bkelly,timhuang
This pref does not override privacy.resistFingerprinting, but when it is set (and
privacy.resistFingerprinting is not) we will still adjust the precision of almost
all timers. The adjustment amount is the second pref, which is defaulted to
20us but now dynamically adjustable (in the scale of microseconds.)

This patch does _not_ address the performance API, which privacy.resistFingerprinting
disables.

We are landing this preffed on at the current value we clamp performance.now() at
which is 20us.

MozReview-Commit-ID: ESZlSvH9w1D
2018-01-09 14:58:34 -06:00