Bug 115087 - Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions
Summary: Web Inspector: WebCore::reportException should not evaluate JavaScript handli...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Chris Curtis
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-04-23 22:16 PDT by Joseph Pecoraro
Modified: 2016-12-13 15:40 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2013-04-23 22:16:03 PDT
Currently WebCore::reportException can evaluate JavaScript when handling exceptions. The JS evaluation can itself throw an exception if running code in the page.

For example:

    function MyError() {
        this.name = "MyErrorName";
        this.message = "MyErrorMessage";
    }
    MyError.prototype.toString = function() {
        throw "oops";
    }

    function produceError() {
        throw new MyError();
    }

    produceError();

WebCore::reportException call's this toString, and can potentially get values with hooks in valueOf as well. We should avoid running JS that can trigger its own exceptions if possible.
Comment 1 Geoffrey Garen 2013-07-16 14:05:01 PDT
Chris is working on similar bugs in JSC, so reassigning to him.
Comment 2 Timothy Hatcher 2014-01-10 15:37:13 PST
Moving to the right component.
Comment 3 Radar WebKit Bug Importer 2014-01-10 15:37:41 PST
<rdar://problem/15796841>
Comment 4 Joseph Pecoraro 2014-02-19 14:20:02 PST
Oliver had a suggestion on IRC:

    - if the exception object is a builtin Exception/Error object => directly get "message" property
    - if the exception object is a primitive => toString
    - otherwise, send the exception object to the inspector frontend like a console.log (RemoteObject)

I think that is a good idea. This would nicely handle these cases:

    - SyntaxError / ReferenceError
    - throw 1, throw "test", ...
    - throw {a:1,b:2}, throw [1,2,3], throw new MyError()