Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending tainted number via postmessage leaves them in 'zombie state' #218

Open
leeN opened this issue Aug 13, 2024 · 0 comments
Open

Sending tainted number via postmessage leaves them in 'zombie state' #218

leeN opened this issue Aug 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working primitaint Tainting of primitive types (numbers, bool, etc.)

Comments

@leeN
Copy link
Collaborator

leeN commented Aug 13, 2024

While debugging stuff related to the primitive tainting, I noticed something that breaks some applications in a subtle way.

If I send a tainted string via post message, it gets cloned, transferred, and deserialized as expected. The same sadly is not true for numbers.

<!DOCTYPE html>
<html>
  <head>
    <script>
      window.addEventListener(
  "message",
  (event) => {
    d = event.data;
    console.log(`Number: ${d.num}, (type: ${typeof d.num}), taint: ${d.num.taint}`);
    console.log(`String: ${d.str}, (type: ${typeof d.str}), taint: ${d.str.taint}`);
  },
  false,
);
        let tn = Number.tainted(52);
        let ts = String.tainted("foo");
        window.postMessage({ num: tn, str: ts}, "*");
    </script>
  </head>
  <body></body>
</html>

I would expect this to print something like:

Number: 52, (type: number), taint: [object Object] test.html:9:13
String: foo, (type: string), taint: [object Object] test.html:10:13

but instead it is as follows:

Number: 52, (type: object), taint: null [test.html:9:13]
String: foo, (type: string), taint: [object Object] [test.html:10:13]

That is, the value is correctly restored, but the taint object is left as null. This changes the semantics of the typeof operator, which is problematic if you are sending properties of the client to yourself via post message.

@leeN leeN added the bug Something isn't working label Aug 13, 2024
@leeN leeN self-assigned this Aug 13, 2024
@leeN leeN added the primitaint Tainting of primitive types (numbers, bool, etc.) label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working primitaint Tainting of primitive types (numbers, bool, etc.)
Projects
None yet
Development

No branches or pull requests

1 participant