Changeset 100213 in webkit


Ignore:
Timestamp:
Nov 14, 2011 4:24:33 PM (12 years ago)
Author:
abarth@webkit.org
Message:

Unique origins shouldn't remember their scheme, host, or port
https://bugs.webkit.org/show_bug.cgi?id=72308

Reviewed by Eric Seidel.

Source/WebCore:

This patch contains the bulk (all?) of the behavior differences in this
patch series. Unique origins shouldn't remember their schemes. Doing
so causes some privileges (e.g., local access) to leak into unique
origins.

  • page/SecurityOrigin.cpp:

(WebCore::SecurityOrigin::SecurityOrigin):

  • Explicitly clear out the protocol, host, and port for unique origins. A future patch will refactor all this code to be more elegant.
  • platform/SchemeRegistry.cpp:

(WebCore::schemesWithUniqueOrigins):

  • Merge "about" and "javascript" in with the general case now that we don't have a separate notion of an empty origin.

LayoutTests:

  • fast/filesystem/async-operations-expected.txt:
  • fast/filesystem/not-enough-arguments-expected.txt:
  • fast/filesystem/read-directory-expected.txt:
  • fast/filesystem/simple-persistent-expected.txt:
  • fast/filesystem/simple-readonly-expected.txt:
  • fast/filesystem/simple-temporary-expected.txt:
    • Update test results to show that we no longer leak the scheme in storage identifiers.
  • fast/frames/resources/sandboxed-iframe-storage-disallowed.html:
    • Inline script because the sandbox iframe isn't allowed to load local resources.
  • fast/frames/sandboxed-iframe-attribute-parsing.html:
  • fast/frames/sandboxed-iframe-forms-dynamic.html:
  • fast/frames/sandboxed-iframe-forms.html:
  • fast/frames/sandboxed-iframe-navigation-top-by-constant-name.html:
  • fast/frames/sandboxed-iframe-navigation-top-by-constant-name2.html:
  • fast/frames/sandboxed-iframe-navigation-top-by-name.html:
  • fast/frames/sandboxed-iframe-navigation-top.html:
  • media/video-controls-no-scripting.html:
    • Previously sandboxed local iframes still got universal access when we're running with universal access for file URLs! Now that they correctly get unique origins, we need to update these tests to allow-same-origin access in order for them to function properly.
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r100211 r100213  
     12011-11-14  Adam Barth  <abarth@webkit.org>
     2
     3        Unique origins shouldn't remember their scheme, host, or port
     4        https://bugs.webkit.org/show_bug.cgi?id=72308
     5
     6        Reviewed by Eric Seidel.
     7
     8        * fast/filesystem/async-operations-expected.txt:
     9        * fast/filesystem/not-enough-arguments-expected.txt:
     10        * fast/filesystem/read-directory-expected.txt:
     11        * fast/filesystem/simple-persistent-expected.txt:
     12        * fast/filesystem/simple-readonly-expected.txt:
     13        * fast/filesystem/simple-temporary-expected.txt:
     14            - Update test results to show that we no longer leak the scheme in
     15              storage identifiers.
     16        * fast/frames/resources/sandboxed-iframe-storage-disallowed.html:
     17            - Inline script because the sandbox iframe isn't allowed to load
     18              local resources.
     19        * fast/frames/sandboxed-iframe-attribute-parsing.html:
     20        * fast/frames/sandboxed-iframe-forms-dynamic.html:
     21        * fast/frames/sandboxed-iframe-forms.html:
     22        * fast/frames/sandboxed-iframe-navigation-top-by-constant-name.html:
     23        * fast/frames/sandboxed-iframe-navigation-top-by-constant-name2.html:
     24        * fast/frames/sandboxed-iframe-navigation-top-by-name.html:
     25        * fast/frames/sandboxed-iframe-navigation-top.html:
     26        * media/video-controls-no-scripting.html:
     27            - Previously sandboxed local iframes still got universal access
     28              when we're running with universal access for file URLs!  Now that
     29              they correctly get unique origins, we need to update these tests
     30              to allow-same-origin access in order for them to function
     31              properly.
     32
    1332011-11-14  Julien Chaffraix  <jchaffraix@webkit.org>
    234
  • trunk/LayoutTests/fast/filesystem/async-operations-expected.txt

    r72882 r100213  
    55
    66requested FileSystem.
    7 Got FileSystem:file__0:Temporary
     7Got FileSystem:__0:Temporary
    88Starting async test stage 1.
    99Starting async test stage 2.
  • trunk/LayoutTests/fast/filesystem/not-enough-arguments-expected.txt

    r96956 r100213  
    44
    55
    6 Successfully obtained Persistent FileSystem:file__0:Temporary
     6Successfully obtained Persistent FileSystem:__0:Temporary
    77PASS fileSystem.root.moveTo() threw exception TypeError: Not enough arguments.
    88PASS fileSystem.root.copyTo() threw exception TypeError: Not enough arguments.
  • trunk/LayoutTests/fast/filesystem/read-directory-expected.txt

    r72882 r100213  
    44
    55
    6 Successfully obtained Persistent FileSystem:file__0:Temporary
     6Successfully obtained Persistent FileSystem:__0:Temporary
    77PASS readEntriesCount is entriesCallbackCount
    88PASS resultEntries.length is testEntriesCount
  • trunk/LayoutTests/fast/filesystem/simple-persistent-expected.txt

    r72882 r100213  
    44
    55
    6 Successfully obtained PERSISTENT FileSystem:file__0:Persistent
     6Successfully obtained PERSISTENT FileSystem:__0:Persistent
    77PASS fileSystem.name.length > 0 is true
    88PASS fileSystem.root.fullPath is "/"
  • trunk/LayoutTests/fast/filesystem/simple-readonly-expected.txt

    r97542 r100213  
    77trying to set readonly property fileSystem.name
    88fileSystem.name = 'bar'
    9 PASS fileSystem.name is still file__0:Temporary
     9PASS fileSystem.name is still __0:Temporary
    1010root = fileSystem.root
    1111root.getFile('foo', {create:true}, getFileCallback, errorCallback)
  • trunk/LayoutTests/fast/filesystem/simple-temporary-expected.txt

    r72882 r100213  
    44
    55
    6 Successfully obtained TEMPORARY FileSystem:file__0:Temporary
     6Successfully obtained TEMPORARY FileSystem:__0:Temporary
    77PASS fileSystem.name.length > 0 is true
    88PASS fileSystem.root.fullPath is "/"
  • trunk/LayoutTests/fast/frames/resources/sandboxed-iframe-storage-disallowed.html

    r98733 r100213  
    11<html>
    22<head>
    3 <script src="../../js/resources/js-test-pre.js"></script>
     3<script>
     4// This code is inlined from js-test-pre.js because this document is displayed
     5// in a sandboxed iframe and cannot load local resources.
     6
     7if (window.layoutTestController)
     8    layoutTestController.dumpAsText();
     9
     10function debug(msg)
     11{
     12    var span = document.createElement("span");
     13    document.getElementById("console").appendChild(span);
     14    span.innerHTML = msg + '<br />';
     15}
     16
     17function escapeHTML(text)
     18{
     19    return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\0/g, "\\0");
     20}
     21
     22function testPassed(msg)
     23{
     24    debug('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
     25}
     26
     27function testFailed(msg)
     28{
     29    debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
     30}
     31
     32function shouldThrow(_a, _e)
     33{
     34  var exception;
     35  var _av;
     36  try {
     37     _av = eval(_a);
     38  } catch (e) {
     39     exception = e;
     40  }
     41
     42  var _ev;
     43  if (_e)
     44      _ev =  eval(_e);
     45
     46  if (exception) {
     47    if (typeof _e == "undefined" || exception == _ev)
     48      testPassed(_a + " threw exception " + exception + ".");
     49    else
     50      testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + ".");
     51  } else if (typeof _av == "undefined")
     52    testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined.");
     53  else
     54    testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + ".");
     55}
     56</script>
    457<script>
    558
  • trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing.html

    r51579 r100213  
    5757
    5858    <!-- plain, proper attribute value -->
    59     <iframe sandbox="allow-scripts"
     59    <iframe sandbox="allow-scripts allow-same-origin"
    6060            name="f1"
    6161            src="resources/sandboxed-iframe-attribute-parsing-allowed.html">
     
    6767allow-scripts
    6868
    69 "
     69allow-same-origin"
    7070            name="f2"
    7171            src="resources/sandboxed-iframe-attribute-parsing-allowed.html">
     
    104104        'Kyssarna' ('The kisses'), Esaias Tegnér, 1782-1846
    105105
    106     allow-scripts
     106    allow-scripts allow-same-origin
    107107   
    108108        int main(void)
     
    115115
    116116    <!-- tab characters before and after attribute value -->
    117     <iframe sandbox="           allow-scripts           "
     117    <iframe sandbox="           allow-scripts           allow-same-origin"
    118118            name="f4"
    119119            src="resources/sandboxed-iframe-attribute-parsing-allowed.html">
     
    121121
    122122    <!-- mixed case -->
    123     <iframe sandbox="AlLoW-sCrIpTs"
     123    <iframe sandbox="AlLoW-sCrIpTs allow-same-origin"
    124124            name="f5"
    125125            src="resources/sandboxed-iframe-attribute-parsing-allowed.html">
     
    128128    <!-- iframes where script execution is disallowed -->
    129129
    130     <iframe sandbox="allowscripts"
     130    <iframe sandbox="allowscripts allow-same-origin"
    131131            src="resources/sandboxed-iframe-attribute-parsing-disallowed.html">
    132132    </iframe>
    133133
    134     <iframe sandbox="allows-cripts"
     134    <iframe sandbox="allows-cripts allow-same-origin"
    135135            src="resources/sandboxed-iframe-attribute-parsing-disallowed.html">
    136136    </iframe>
    137137
    138     <iframe sandbox="-allow-scripts"
     138    <iframe sandbox="-allow-scripts allow-same-origin"
    139139            src="resources/sandboxed-iframe-attribute-parsing-disallowed.html">
    140140    </iframe>
    141141
    142     <iframe sandbox="allow_scripts"
     142    <iframe sandbox="allow_scripts allow-same-origin"
    143143            src="resources/sandboxed-iframe-attribute-parsing-disallowed.html">
    144144    </iframe>
    145145
    146     <iframe sandbox="allowScripts"
     146    <iframe sandbox="allowScripts allow-same-origin"
    147147            src="resources/sandboxed-iframe-attribute-parsing-disallowed.html">
    148148    </iframe>
    149149
    150     <iframe sandbox="aallow-scripts"
     150    <iframe sandbox="aallow-scripts allow-same-origin"
    151151            src="resources/sandboxed-iframe-attribute-parsing-disallowed.html">
    152152    </iframe>
    153153
    154     <iframe sandbox="allow-scriptss"
     154    <iframe sandbox="allow-scriptss allow-same-origin"
    155155            src="resources/sandboxed-iframe-attribute-parsing-disallowed.html">
    156156    </iframe>
  • trunk/LayoutTests/fast/frames/sandboxed-iframe-forms-dynamic.html

    r56290 r100213  
    3131    frameElements = document.getElementsByTagName("iframe");
    3232
    33     frameElements[0].sandbox = "allow-scripts";
    34     frameElements[1].sandbox = "allow-scripts allow-forms";
    35     frameElements[2].sandbox = "allow-scripts";
     33    frameElements[0].sandbox = "allow-scripts allow-same-origin";
     34    frameElements[1].sandbox = "allow-scripts allow-forms allow-same-origin";
     35    frameElements[2].sandbox = "allow-scripts allow-same-origin";
    3636
    3737    frames[0].postMessage("go", "*");
     
    4646
    4747    <iframe style="width: 60px; height: 60px;"
    48         sandbox="allow-scripts allow-forms"
     48        sandbox="allow-scripts allow-forms allow-same-origin"
    4949        src="resources/sandboxed-iframe-form-dynamic-allowed.html">
    5050    </iframe>
    5151    <iframe style="width: 60px; height: 60px;"
    52         sandbox="allow-scripts"
     52        sandbox="allow-scripts allow-same-origin"
    5353        src="resources/sandboxed-iframe-form-dynamic-disallowed.html">
    5454    </iframe>
    5555    <iframe style="width: 60px; height: 60px;"
    56         sandbox="allow-scripts allow-forms"
     56        sandbox="allow-scripts allow-forms allow-same-origin"
    5757        src="resources/sandboxed-iframe-form-dynamic-allowed.html">
    5858    </iframe>
  • trunk/LayoutTests/fast/frames/sandboxed-iframe-forms.html

    r51577 r100213  
    4242
    4343    <iframe style="width: 60px; height: 60px;"
    44         sandbox="allow-scripts allow-forms"
     44        sandbox="allow-scripts allow-forms allow-same-origin"
    4545        src="resources/sandboxed-iframe-form-allowed.html">
    4646    </iframe>
    4747    <iframe style="width: 60px; height: 60px;"
    48         sandbox="allow-scripts allow-forms"
     48        sandbox="allow-scripts allow-forms allow-same-origin"
    4949        src="resources/sandboxed-iframe-form-allowed.html">
    5050    </iframe>
    5151    <iframe style="width: 60px; height: 60px;"
    52         sandbox="allow-scripts allow-forms"
     52        sandbox="allow-scripts allow-forms allow-same-origin"
    5353        src="resources/sandboxed-iframe-form-allowed.html">
    5454    </iframe>
    5555    <iframe style="width: 60px; height: 60px;"
    56         sandbox="allow-scripts allow-forms"
     56        sandbox="allow-scripts allow-forms allow-same-origin"
    5757        src="resources/sandboxed-iframe-form-allowed.html">
    5858    </iframe>
    5959    <iframe style="width: 60px; height: 60px;"
    60         sandbox="allow-scripts allow-forms"
     60        sandbox="allow-scripts allow-forms allow-same-origin"
    6161        src="resources/sandboxed-iframe-form-allowed.html">
    6262    </iframe>
     
    6565
    6666    <iframe style="width: 60px; height: 60px;"
    67         sandbox="allow-scripts"
     67        sandbox="allow-scripts allow-same-origin"
    6868        src="resources/sandboxed-iframe-form-disallowed.html">
    6969    </iframe>
     
    7272
    7373    <iframe style="width: 60px; height: 60px;"
    74         sandbox="allow-scripts allow-forms"
     74        sandbox="allow-scripts allow-forms allow-same-origin"
    7575        src="resources/sandboxed-iframe-form-allowed.html">
    7676    </iframe>
    7777    <iframe style="width: 60px; height: 60px;"
    78         sandbox="allow-scripts allow-forms"
     78        sandbox="allow-scripts allow-forms allow-same-origin"
    7979        src="resources/sandboxed-iframe-form-allowed.html">
    8080    </iframe>
    8181    <iframe style="width: 60px; height: 60px;"
    82         sandbox="allow-scripts allow-forms"
     82        sandbox="allow-scripts allow-forms allow-same-origin"
    8383        src="resources/sandboxed-iframe-form-allowed.html">
    8484    </iframe>
    8585    <iframe style="width: 60px; height: 60px;"
    86         sandbox="allow-scripts allow-forms"
     86        sandbox="allow-scripts allow-forms allow-same-origin"
    8787        src="resources/sandboxed-iframe-form-allowed.html">
    8888    </iframe>
    8989    <iframe style="width: 60px; height: 60px;"
    90         sandbox="allow-scripts allow-forms"
     90        sandbox="allow-scripts allow-forms allow-same-origin"
    9191        src="resources/sandboxed-iframe-form-allowed.html">
    9292    </iframe>
  • trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-top-by-constant-name.html

    r56591 r100213  
    1010<body>
    1111<p>This test verifies that a sandboxed IFrame can navigate the top-level frame with allow-top-navigation.</p>
    12 <iframe sandbox="allow-scripts allow-top-navigation"
     12<iframe sandbox="allow-scripts allow-top-navigation allow-same-origin"
    1313        src="resources/navigate-top-by-constant-name-to-pass.html">
    1414</body>
  • trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-top-by-constant-name2.html

    r56591 r100213  
    1010<body>
    1111<p>This test verifies that a sandboxed IFrame can navigate the top-level frame with allow-top-navigation.</p>
    12 <iframe sandbox="allow-scripts allow-top-navigation"
     12<iframe sandbox="allow-scripts allow-top-navigation allow-same-origin"
    1313        src="resources/navigate-top-by-constant-name2-to-pass.html">
    1414</body>
  • trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-top-by-name.html

    r56591 r100213  
    1111<body>
    1212<p>This test verifies that a sandboxed IFrame can navigate the top-level frame with allow-top-navigation.</p>
    13 <iframe sandbox="allow-scripts allow-top-navigation"
     13<iframe sandbox="allow-scripts allow-top-navigation allow-same-origin"
    1414        src="resources/navigate-top-by-name-to-pass.html">
    1515</body>
  • trunk/LayoutTests/fast/frames/sandboxed-iframe-navigation-top.html

    r56591 r100213  
    1010<body>
    1111<p>This test verifies that a sandboxed IFrame can navigate the top-level frame with allow-top-navigation.</p>
    12 <iframe sandbox="allow-scripts allow-top-navigation"
     12<iframe sandbox="allow-scripts allow-top-navigation allow-same-origin"
    1313        src="resources/navigate-top-to-pass.html">
    1414</body>
  • trunk/LayoutTests/media/video-controls-no-scripting.html

    r93148 r100213  
    2828    <body>
    2929
    30         <iframe sandbox src="resources/video-controls-no-scripting-iframe.html" id="fr" style="width: 400px; height: 320px; border: 1px solid black;"></iframe>
     30        <iframe sandbox="allow-same-origin" src="resources/video-controls-no-scripting-iframe.html" id="fr" style="width: 400px; height: 320px; border: 1px solid black;"></iframe>
    3131
    3232        <p>Tests that the built-in controls are always enabled when JavaScript is disabled.</p>
  • trunk/Source/WebCore/ChangeLog

    r100203 r100213  
     12011-11-14  Adam Barth  <abarth@webkit.org>
     2
     3        Unique origins shouldn't remember their scheme, host, or port
     4        https://bugs.webkit.org/show_bug.cgi?id=72308
     5
     6        Reviewed by Eric Seidel.
     7
     8        This patch contains the bulk (all?) of the behavior differences in this
     9        patch series.  Unique origins shouldn't remember their schemes.  Doing
     10        so causes some privileges (e.g., local access) to leak into unique
     11        origins.
     12
     13        * page/SecurityOrigin.cpp:
     14        (WebCore::SecurityOrigin::SecurityOrigin):
     15            - Explicitly clear out the protocol, host, and port for unique
     16              origins.  A future patch will refactor all this code to be more
     17              elegant.
     18        * platform/SchemeRegistry.cpp:
     19        (WebCore::schemesWithUniqueOrigins):
     20            - Merge "about" and "javascript" in with the general case now that
     21              we don't have a separate notion of an empty origin.
     22
    1232011-11-14  Adam Barth  <abarth@webkit.org>
    224
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r100203 r100213  
    4242namespace WebCore {
    4343
     44const int InvalidPort = 0;
    4445const int MaxAllowedPort = 65535;
    4546
     
    6667    , m_enforceFilePathSeparation(false)
    6768{
    68     // These protocols do not create security origins; the owner frame provides the origin
    69     if (m_protocol == "about" || m_protocol == "javascript")
    70         m_protocol = "";
    71 
    7269#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
    7370    bool isBlobOrFileSystemProtocol = false;
     
    9491    if (schemeRequiresAuthority(m_protocol) && m_host.isEmpty())
    9592        m_isUnique = true;
     93
    9694    if (m_protocol.isEmpty())
    9795        m_isUnique = true;
     
    117115
    118116    if (isDefaultPortForProtocol(m_port, m_protocol))
    119         m_port = 0;
     117        m_port = InvalidPort;
     118
     119    // Don't leak details from URLs into unique origins.
     120    if (m_isUnique) {
     121        m_protocol = "";
     122        m_host = "";
     123        m_port = InvalidPort;
     124    }
    120125}
    121126
  • trunk/Source/WebCore/platform/SchemeRegistry.cpp

    r99509 r100213  
    6969    DEFINE_STATIC_LOCAL(URLSchemesMap, schemesWithUniqueOrigins, ());
    7070
    71     // This is a willful violation of HTML5.
    72     // See https://bugs.webkit.org/show_bug.cgi?id=11885
    73     if (schemesWithUniqueOrigins.isEmpty())
     71    if (schemesWithUniqueOrigins.isEmpty()) {
     72        schemesWithUniqueOrigins.add("about");
     73        schemesWithUniqueOrigins.add("javascript");
     74        // This is a willful violation of HTML5.
     75        // See https://bugs.webkit.org/show_bug.cgi?id=11885
    7476        schemesWithUniqueOrigins.add("data");
     77    }
    7578
    7679    return schemesWithUniqueOrigins;
Note: See TracChangeset for help on using the changeset viewer.