Skip to content

Flawed taint propagation with toLowerCase and normalize #361

@eleumasc

Description

@eleumasc

The methods toLowerCase and normalize of String.prototype (see js/src/builtin/String.cpp) internally propagate taint by first extending the taint of the input string and then assigning the taint of the input string to the output string.

This causes the following JavaScript program (we have a similar behavior by replacing toLowerCase with normalize)

let s = String.tainted("hello");
let t = s.toLowerCase();
console.log(s.taint);

to output this (actual)

[{
  begin: 0,
  end: 5,
  flow: [
    { operation: "normalize", ... },
    { operation: "manual taint source", ... }
  ]
}]

rather than this (expected)

[{
  begin: 0,
  end: 5,
  flow: [
    { operation: "manual taint source", ... }
  ]
}]

In the next days, I will create a PR with a mochitest and a solution attempt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions