JavaScript Restrictor
Browser extension that improves privacy and security
wrappingS-HTML-LS.js File Reference

Wrappers for Workers. More...

Functions

function executeEach (arr, fun)
 
function callErrorListener (err)
 
function addEventListener (type, fun)
 
function removeEventListener (type, fun)
 
function postError (err)
 
function runPostMessage (msg, transfer)
 
function postMessage (msg, transfer)
 
function workerPostMessage (msg)
 
function workerAddEventListener (type, fun)
 
xhr open ('GET', path)
 
xhr send ()
 

Variables

var errorListeners = []
 
var workerMessageListeners = []
 
var workerErrorListeners = []
 
var postMessageListeners = []
 
var terminated = false
 
var script
 
var workerSelf
 
var api = this
 
var xhr = new XMLHttpRequest()
 
xhr onreadystatechange
 
api postMessage = postMessage
 
api addEventListener = addEventListener
 
api removeEventListener = removeEventListener
 
api terminate = terminate
 
var slowBody
 
let _old = _data.postMessage
 
var wrappers
 

Detailed Description

Wrappers for Workers.

Author
Copyright (C) 2019 Libor Polcak
Copyright (C) 2020 Peter Hornak
Copyright (C) 2021 Matus Svancar
License:
SPDX-License-Identifier: GPL-3.0-or-later

This wrapper aims on prevention of microarchitectural attacks. This code was originally a part of https://github.com/IAIK/ChromeZero.

The wrappers support the following behaviour:

  • Polyfill: Completely eliminates the paralelism.
  • Randomly slow messages: Add noise to the postMessage method execution.
See also
Lipp, M., Gruss, D., Schwarz, M., Bidner, D., Maurice, C. et al. Practical Keystroke Timing Attacks in Sandboxed JavaScript. In:. August 2017, s. 191–209. ISBN 978-3-319-66398-2.
Schwarz, M., Lipp, M. a Gruss, D. JavaScript Zero: Real JavaScript and Zero Side-Channel Attacks. NDSS'18.
https://www.fit.vut.cz/study/thesis/22374/?year=0&sup=Pol%C4%8D%C3%A1k

Function Documentation

◆ addEventListener()

function addEventListener (   type,
  fun 
)
Here is the caller graph for this function:

◆ callErrorListener()

function callErrorListener (   err)
Here is the caller graph for this function:

◆ executeEach()

function executeEach (   arr,
  fun 
)
Here is the caller graph for this function:

◆ open()

xhr open ( 'GET'  ,
path   
)

◆ postError()

function postError (   err)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ postMessage()

function postMessage (   msg,
  transfer 
)
Here is the call graph for this function:

◆ removeEventListener()

function removeEventListener (   type,
  fun 
)

◆ runPostMessage()

function runPostMessage (   msg,
  transfer 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send()

xhr send ( )
Here is the caller graph for this function:

◆ workerAddEventListener()

function workerAddEventListener (   type,
  fun 
)

◆ workerPostMessage()

function workerPostMessage (   msg)
Here is the call graph for this function:

Variable Documentation

◆ _old

let _old = _data.postMessage

◆ addEventListener

window addEventListener = addEventListener

◆ api

return api = this

◆ errorListeners

var errorListeners = []

◆ onreadystatechange

xhr onreadystatechange
Initial value:
= function () {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 400) {
script = xhr.responseText;
};
doEval(workerSelf, script);
var currentListeners = postMessageListeners;
for (var i = 0; i < currentListeners.length; i++) {
runPostMessage(currentListeners[i].msg, currentListeners[i].transfer);
}
} else {
postError(new Error('cannot find script ' + path));
}
}
}
window close()
function workerAddEventListener(type, fun)
Definition: wrappingS-HTML-LS.js:184
var xhr
Definition: wrappingS-HTML-LS.js:193
api terminate
Definition: wrappingS-HTML-LS.js:222
var workerSelf
Definition: wrappingS-HTML-LS.js:69
api addEventListener
Definition: wrappingS-HTML-LS.js:220
var script
Definition: wrappingS-HTML-LS.js:68
function runPostMessage(msg, transfer)
Definition: wrappingS-HTML-LS.js:134
function workerPostMessage(msg)
Definition: wrappingS-HTML-LS.js:167
function postError(err)
Definition: wrappingS-HTML-LS.js:122
api postMessage
Definition: wrappingS-HTML-LS.js:219
var postMessageListeners
Definition: wrappingS-HTML-LS.js:66

◆ postMessage

_data postMessage = postMessage

◆ postMessageListeners

var postMessageListeners = []

◆ removeEventListener

api removeEventListener = removeEventListener

◆ script

var script

◆ slowBody

var slowBody
Initial value:
= `
let _data = new originalF(path)
_data
Definition: wrappingS-ECMA-ARRAY.js:536

◆ terminate

function terminate = terminate

◆ terminated

var terminated = false

◆ workerErrorListeners

var workerErrorListeners = []

◆ workerMessageListeners

var workerMessageListeners = []

◆ workerSelf

var workerSelf

◆ wrappers

var wrappers

◆ xhr

var xhr = new XMLHttpRequest()