JavaScript Restrictor
Browser extension that improves privacy and security
Loading...
Searching...
No Matches
wrappingS-GEO.js File Reference

This file contains wrappers for the Geolocation API. More...

Functions

function spoofCall (fakeData, originalPositionObject, successCallback)
 Modifies the given PositionObject according to settings.
 
function processOriginalGPSDataObject (expectedMaxAge, originalPositionObject)
 
 switch (args[0])
 

Variables

function let randomx = geo_prng()
 
let randomy = geo_prng()
 
let previouslyReturnedCoords
 
let clone = obj => Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj))
 
var geoTimestamp = Date.now()
 Store the limit for the returned timestamps.
 
var setArgs
 process the parameters of the wrapping function
 
var provideAccurateGeolocationData = (args[0] === -1)
 
let desiredAccuracy = 0
 
var wrappers
 

Detailed Description

This file contains wrappers for the Geolocation API.

See also
https://www.w3.org/TR/geolocation-API/
Author
Copyright (C) 2019 Martin Timko
Copyright (C) 2020 Libor Polcak
Copyright (C) 2020 Peter Marko
Copyright (C) 2021 Giorgio Maone
License:
SPDX-License-Identifier: GPL-3.0-or-later

The goal is to prevent leaks of user current position. The Geolocation API also provides access to high precision timestamps which can be used to various web attacks (see for example, http://www.jucs.org/jucs_21_9/clock_skew_based_computer, https://lirias.kuleuven.be/retrieve/389086).

Although it is true that the user needs to specificaly approve access to location facilities, these wrappers aim on improving the control of the precision of the geolocation.

The wrappers support the following controls:

  • Accurate data: the extension provides precise geolocation position but modifies the time precision in conformance with the Date and Performance wrappers.
  • Modified position: the extension modifies the time precision of the time stamps in conformance with the Date and Performance wrappers, and additionally, allows to limit the precision of the current position to hundered of meters, kilometers, tens, or hundereds of kilometers.

When modifying position:

  • Repeated calls of navigator.geolocation.getCurrentPosition() return the same position without page load and typically return another position after page reload.
  • navigator.geolocation.watchPosition() does not change position.

Function Documentation

◆ processOriginalGPSDataObject()

function processOriginalGPSDataObject (   expectedMaxAge,
  originalPositionObject 
)
Here is the call graph for this function:

◆ spoofCall()

function spoofCall (   fakeData,
  originalPositionObject,
  successCallback 
)

Modifies the given PositionObject according to settings.

Parameters
expectedMaxAgeThe maximal age of the returned time stamps as defined by the wrapped API (https://www.w3.org/TR/geolocation-API/#max-age)
originalPositionObjectthe position object to be returned without this wrapper, see the Position interface (https://www.w3.org/TR/geolocation-API/#position)

The function modifies the originalPositionObject and stores it for later readins. The returned position does not modify during the life time of a pages. The returned postion can be different after a page reload.

The goal of the behavoiur is to prevent learning the current position so that different original postion can be mapped to the same position and the same position should generally yield a different outcome to prevent correlation of user activities.

The algorithm works as follows:

  1. The Earth surface is partitioned into squares (tiles) with the edge derived from the desired accuracy.
  2. The position from the originalPositionObject is mapped to its tile and eight adjacent tiles.
  3. A position in the current tile and the eight adjacent tiles is selected randomly.

The returned timestamp is not older than 1 hour and it is the same as was during the last call or newer. Different calls to the function can yield different timestamps.

Bug:
The tile-based approach does not work correctly near poles but:
  • The function returns fake locations near poles.
  • As there are not many people near poles, we do not believe this wrapping is useful near poles so we do not consider this bug as important.
Here is the caller graph for this function:

◆ switch()

switch (   args[0])

Variable Documentation

◆ clone

let clone = obj => Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj))

◆ desiredAccuracy

let desiredAccuracy = 0

◆ geoTimestamp

var geoTimestamp = Date.now()

Store the limit for the returned timestamps.

This is used to avoid returning older readings compared to the previous readings. The timestamp needs to be the same as was last time or newser.

◆ previouslyReturnedCoords

let previouslyReturnedCoords

Make sure that repeated calls shows the same position (BUT different objects, via cloning) to reduce fingerprintablity.

◆ provideAccurateGeolocationData

var provideAccurateGeolocationData = (args[0] === -1)

◆ randomx

function let randomx = geo_prng()

◆ randomy

let randomy = geo_prng()

◆ setArgs

var setArgs
Initial value:
= `
var enableGeolocation = (args[0] !== 0)

process the parameters of the wrapping function

Checks if the wrappers should be active, and the position modified. Transforms the desired precision into kilometers.

◆ wrappers

var wrappers