Remove support for ducktyped errors
Categories
(Core :: JavaScript Engine, task, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox143 | --- | fixed |
People
(Reporter: tschuster, Assigned: tschuster)
References
(Blocks 2 open bugs)
Details
Attachments
(2 files)
SpiderMonkey has special code to treat objects like {message: "<message>", fileName: "foo", lineNumber: 1} as actual instances of an Error object. This can actually be abused to execute code in some cases: https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#no-parentheses-using-exception-handling-and-object-eval-on-firefox
I think this used to exist primarily to handle tricky wrapper cases where it might not be possible to obtain an actual error object. Nowadays, we just don't have that many wrappers anymore.
One thing we might want to think about are DOMException objects, these are almost Error objects but not really. If we just remove the duck typing, the following code will change behavior:
onerror = (message, source, lineno, colno, error) => {
console.log(lineno, colno);
}
/* line 5 */ let exception = new DOMException("<DOMException message>", "<DOMException name>")
/* line 6 */ throw exception;
Currently this will log 5 0 (where the DOMException is constructed, but apparently we are missing the column?). This will change to 6 14 (the location of throw). Chrome matches with the new behavior.
I did a try push with the duck typing code disabled, there are some test failures related to changed error messages, but it looks manageable.
Updated•8 months ago
|
| Assignee | ||
Comment 1•8 months ago
|
||
| Assignee | ||
Comment 2•8 months ago
|
||
| Assignee | ||
Updated•8 months ago
|
Updated•8 months ago
|
Updated•8 months ago
|
| Assignee | ||
Updated•8 months ago
|
Updated•8 months ago
|
Comment 4•8 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/c0c6f170e490
https://hg.mozilla.org/mozilla-central/rev/831879a358fc
https://hg.mozilla.org/mozilla-central/rev/429249e44884
Updated•7 months ago
|
Description
•