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

Wrappers for WebGL Specification standards (both 1.0 and 2.0) More...

Functions

function farbleNull (name, ctx,...fcarg)
 Returns null or output of given function.
 
function farbleZero (name, ctx,...fcarg)
 Returns 0 or output of given function.
 
function farbleMinusOne (name, ctx,...fcarg)
 Returns -1 or output of given function.
 
function farbleNullArray (name, ctx,...fcarg)
 Returns [] or output of given function.
 
function farbleGetPrecisionFormat (ctx,...fcarg)
 Returns empty WebGLShaderPrecisionFormat object or real value.
 
function farbleGetActives (name, ctx,...fcarg)
 Returns empty WebGLActiveInfo object or real value.
 
function farbleGetFramebufferAttachmentParameter (ctx, target, attachment, pname)
 Returns modified WebGLRenderingContext.getFramebufferAttachmentParameter output for some specific parameters, original value for the rest.
 
function farbleGetVertexAttrib (ctx, index, pname)
 Returns modified WebGLRenderingContext.getVertexAttrib output for some specific parameters, original value for the rest.
 
function farbleGetBufferParameter (ctx, target, pname)
 Returns modified WebGLRenderingContext.getBufferParameter output for some specific parameters, original value for the rest.
 
function farbleGetShaderParameter (ctx, shader, pname)
 Returns modified WebGLRenderingContext.getShaderParameter output for some specific parameters, original value for the rest.
 
function farbleGetRenderbufferParameter (ctx, target, pname)
 Returns modified WebGLRenderingContext.getRenderbufferParameter output for some specific parameters, original value for the rest.
 
function farbleGetProgramParameter (ctx, program, pname)
 Returns modified WebGLRenderingContext.getProgramParameter output for some specific parameters, original value for the rest.
 
function farblePixels (gl, x, y, width, height, format, type, outpixels, offset)
 Modifies pixels array.
 

Variables

function let farbleGetParameterString
 
var unmasked_vendor = randomString(8, 0, webgl_prng)
 
var vendor = randomString(8, 0, webgl_prng)
 
var unmasked_renderer = randomString(8, 0, webgl_prng)
 
var renderer = randomString(8, 0, webgl_prng)
 
const STATIC_RANDOM_VALUE = webgl_prng.uint32()
 
 farbleGetParameter
 
var wrappers
 

Detailed Description

Wrappers for WebGL Specification standards (both 1.0 and 2.0)

See also
https://www.khronos.org/registry/webgl/specs/latest/1.0/
https://www.khronos.org/registry/webgl/specs/latest/2.0/
Author
Copyright (C) 2021 Matus Svancar
Copyright (C) 2023 Martin Zmitko
License:
SPDX-License-Identifier: GPL-3.0-or-later
License:
SPDX-License-Identifier: MPL-2.0

This file contains wrappers for WebGL related calls

The goal is to prevent fingerprinting by modifying the values from certain WebGLRenderingContext API functions. This includes return values of various functions which can be hardware/software specific and image data reading.

Content is either modified according to domain and session keys to be different than the original albeit very similar or replaced by bottom value which is consistent every time. Both approaches are inspired by the algorithms created by Brave Software available here and here.

This wrapper operates with two levels of protection:

  • (0) - return modified results, such as slightly changed image, slightly changed number or random string
  • (1) - return bottom values - such as zero, empty string, empty image, null, etc.

Level 0 is trying to force WebGL fingeprint to be unique on every domain and every session. This can be effective when used with other wrappers with same options. This level causes breakage of websites using WebGL only rarely. Level 1 is trying to return as little information as possible while being consistent across domains and sessions. This level can cause breakage on majority of websites using WebGL.

Note
Both approaches are detectable by a fingerprinter that checks if a predetermined image is the same as the read one or if specific function returns expected value. Nevertheless, the aim of the wrappers is to limit the finerprintability.

Function Documentation

◆ farbleGetActives()

function farbleGetActives (   name,
  ctx,
  fcarg 
)

Returns empty WebGLActiveInfo object or real value.

Parameters
nameof original function
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
...fcargdelegated arguments depending on function

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - WebGLActiveInfo object with empty attributes

◆ farbleGetBufferParameter()

function farbleGetBufferParameter (   ctx,
  target,
  pname 
)

Returns modified WebGLRenderingContext.getBufferParameter output for some specific parameters, original value for the rest.

Parameters
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
targetGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)
pnameGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - bottom value (0, 35044)

◆ farbleGetFramebufferAttachmentParameter()

function farbleGetFramebufferAttachmentParameter (   ctx,
  target,
  attachment,
  pname 
)

Returns modified WebGLRenderingContext.getFramebufferAttachmentParameter output for some specific parameters, original value for the rest.

Parameters
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
targetGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)
attachmentGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)
pnameGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - bottom value (0, 34069, 9729, 5124)

◆ farbleGetPrecisionFormat()

function farbleGetPrecisionFormat (   ctx,
  fcarg 
)

Returns empty WebGLShaderPrecisionFormat object or real value.

Parameters
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
...fcargdelegated arguments depending on function

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - WebGLShaderPrecisionFormat object with empty attributes

◆ farbleGetProgramParameter()

function farbleGetProgramParameter (   ctx,
  program,
  pname 
)

Returns modified WebGLRenderingContext.getProgramParameter output for some specific parameters, original value for the rest.

Parameters
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
programWebGLProgram object (https://developer.mozilla.org/en-US/docs/Web/API/WebGLProgram)
pnameGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - bottom value (false, 0, 35981)

◆ farbleGetRenderbufferParameter()

function farbleGetRenderbufferParameter (   ctx,
  target,
  pname 
)

Returns modified WebGLRenderingContext.getRenderbufferParameter output for some specific parameters, original value for the rest.

Parameters
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
targetGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)
pnameGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - bottom value (0, 32854)

◆ farbleGetShaderParameter()

function farbleGetShaderParameter (   ctx,
  shader,
  pname 
)

Returns modified WebGLRenderingContext.getShaderParameter output for some specific parameters, original value for the rest.

Parameters
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
programWebGLShader object (https://developer.mozilla.org/en-US/docs/Web/API/WebGLShader)
pnameGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - bottom value (false, 35633)

◆ farbleGetVertexAttrib()

function farbleGetVertexAttrib (   ctx,
  index,
  pname 
)

Returns modified WebGLRenderingContext.getVertexAttrib output for some specific parameters, original value for the rest.

Parameters
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
indexGLuint specifying index
pnameGLenum (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants)

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - bottom value (false, 0, 5120, empty Float32Array)

◆ farbleMinusOne()

function farbleMinusOne (   name,
  ctx,
  fcarg 
)

Returns -1 or output of given function.

Parameters
nameof original function
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
...fcargdelegated arguments depending on function

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - minus one

◆ farbleNull()

function farbleNull (   name,
  ctx,
  fcarg 
)

Returns null or output of given function.

Parameters
nameof original function
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
...fcargdelegated arguments depending on function

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - null

◆ farbleNullArray()

function farbleNullArray (   name,
  ctx,
  fcarg 
)

Returns [] or output of given function.

Parameters
nameof original function
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
...fcargdelegated arguments depending on function

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - empty array

◆ farblePixels()

function farblePixels (   gl,
  x,
  y,
  width,
  height,
  format,
  type,
  outpixels,
  offset 
)

Modifies pixels array.

Parameters
glWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
xstarting x position
ystarting y position
widthwidth to be read (in pixels)
heightheight to be read (in pixels)
formatformat of read pixel data
typespecifies data type of pixels
pixelstyped array to return result
offsetoptional offset

Depending on level chosen this function returns to pixels array:

  • (0) - slightly changed image data according to domain and session keys
  • (1) - empty array
Bug:
We do not support calls without explicit buffers, NOOP
Here is the call graph for this function:

◆ farbleZero()

function farbleZero (   name,
  ctx,
  fcarg 
)

Returns 0 or output of given function.

Parameters
nameof original function
ctxWebGLRenderingContext (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
...fcargdelegated arguments depending on function

Depending on level chosen this function returns:

  • (0) - original value
  • (1) - zero

Variable Documentation

◆ farbleGetParameter

farbleGetParameter

◆ farbleGetParameterString

function let farbleGetParameterString
Initial value:
= `
var webgl_prng = alea(domainHash, "WebGL wrappers")
var alea
Definition alea.js:74
const domainHash
<reference path="../../common/wrappingS-GEO.js">
Definition wrappingS-GEO_tests.js:26

◆ renderer

var renderer = randomString(8, 0, webgl_prng)

◆ STATIC_RANDOM_VALUE

const STATIC_RANDOM_VALUE = webgl_prng.uint32()

◆ unmasked_renderer

var unmasked_renderer = randomString(8, 0, webgl_prng)

◆ unmasked_vendor

var unmasked_vendor = randomString(8, 0, webgl_prng)

◆ vendor

var vendor = randomString(8, 0, webgl_prng)

◆ wrappers

var wrappers