toolkit/components/passwordmgr/test/test_bug_360493_2.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test for Login Manager</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="text/javascript" src="pwmgr_common.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 8 </head>
michael@0 9 <body>
michael@0 10 Login Manager test: 360493
michael@0 11 <p id="display"></p>
michael@0 12 <div id="content" style="display: none">
michael@0 13
michael@0 14 <!-- The tests in this page exercise things that shouldn't work. -->
michael@0 15
michael@0 16 <!-- Change port # of action URL from 8888 to 7777 -->
michael@0 17 <form id="form1" action="http://localhost:7777/tests/toolkit/components/passwordmgr/test/formtest.js">
michael@0 18 <input type="text" name="uname">
michael@0 19 <input type="password" name="pword">
michael@0 20
michael@0 21 <button type="submit">Submit</button>
michael@0 22 <button type="reset"> Reset </button>
michael@0 23 </form>
michael@0 24
michael@0 25 <!-- No port # in action URL -->
michael@0 26 <form id="form2" action="http://localhost/tests/toolkit/components/passwordmgr/test/formtest.js">
michael@0 27 <input type="text" name="uname">
michael@0 28 <input type="password" name="pword">
michael@0 29
michael@0 30 <button type="submit">Submit</button>
michael@0 31 <button type="reset"> Reset </button>
michael@0 32 </form>
michael@0 33
michael@0 34 <!-- Change protocol from http:// to ftp://, include the expected 8888 port # -->
michael@0 35 <form id="form3" action="ftp://localhost:8888/tests/toolkit/components/passwordmgr/test/formtest.js">
michael@0 36 <input type="text" name="uname">
michael@0 37 <input type="password" name="pword">
michael@0 38
michael@0 39 <button type="submit">Submit</button>
michael@0 40 <button type="reset"> Reset </button>
michael@0 41 </form>
michael@0 42
michael@0 43 <!-- Change protocol from http:// to ftp://, no port # specified -->
michael@0 44 <form id="form4" action="ftp://localhost/tests/toolkit/components/passwordmgr/test/formtest.js">
michael@0 45 <input type="text" name="uname">
michael@0 46 <input type="password" name="pword">
michael@0 47
michael@0 48 <button type="submit">Submit</button>
michael@0 49 <button type="reset"> Reset </button>
michael@0 50 </form>
michael@0 51
michael@0 52 <!-- Try a weird URL. -->
michael@0 53 <form id="form5" action="about:blank">
michael@0 54 <input type="text" name="uname">
michael@0 55 <input type="password" name="pword">
michael@0 56
michael@0 57 <button type="submit">Submit</button>
michael@0 58 <button type="reset"> Reset </button>
michael@0 59 </form>
michael@0 60
michael@0 61 <!-- Try a weird URL. (If the normal embedded action URL doesn't work, that should mean other URLs won't either) -->
michael@0 62 <form id="form6" action="view-source:http://localhost:8888/tests/toolkit/components/passwordmgr/test/formtest.js">
michael@0 63 <input type="text" name="uname">
michael@0 64 <input type="password" name="pword">
michael@0 65
michael@0 66 <button type="submit">Submit</button>
michael@0 67 <button type="reset"> Reset </button>
michael@0 68 </form>
michael@0 69
michael@0 70 <!-- Try a weird URL. -->
michael@0 71 <form id="form7" action="view-source:formtest.js">
michael@0 72 <input type="text" name="uname">
michael@0 73 <input type="password" name="pword">
michael@0 74
michael@0 75 <button type="submit">Submit</button>
michael@0 76 <button type="reset"> Reset </button>
michael@0 77 </form>
michael@0 78
michael@0 79 <!-- Action URL points to a different host (this is the archetypical exploit) -->
michael@0 80 <form id="form8" action="http://www.cnn.com/">
michael@0 81 <input type="text" name="uname">
michael@0 82 <input type="password" name="pword">
michael@0 83
michael@0 84 <button type="submit">Submit</button>
michael@0 85 <button type="reset"> Reset </button>
michael@0 86 </form>
michael@0 87
michael@0 88 <!-- Action URL points to a different host, user field prefilled -->
michael@0 89 <form id="form9" action="http://www.cnn.com/">
michael@0 90 <input type="text" name="uname" value="testuser">
michael@0 91 <input type="password" name="pword">
michael@0 92
michael@0 93 <button type="submit">Submit</button>
michael@0 94 <button type="reset"> Reset </button>
michael@0 95 </form>
michael@0 96
michael@0 97 <!-- Try wrapping a evil form around a good form, to see if we can confuse the parser. -->
michael@0 98 <form id="form10-A" action="http://www.cnn.com/">
michael@0 99 <form id="form10-B" action="formtest.js">
michael@0 100 <input type="text" name="uname">
michael@0 101 <input type="password" name="pword">
michael@0 102
michael@0 103 <button type="submit">Submit (inner)</button>
michael@0 104 <button type="reset"> Reset (inner)</button>
michael@0 105 </form>
michael@0 106 <button type="submit" id="neutered_submit10">Submit (outer)</button>
michael@0 107 <button type="reset">Reset (outer)</button>
michael@0 108 </form>
michael@0 109
michael@0 110 <!-- Try wrapping a good form around an evil form, to see if we can confuse the parser. -->
michael@0 111 <form id="form11-A" action="formtest.js">
michael@0 112 <form id="form11-B" action="http://www.cnn.com/">
michael@0 113 <input type="text" name="uname">
michael@0 114 <input type="password" name="pword">
michael@0 115
michael@0 116 <button type="submit">Submit (inner)</button>
michael@0 117 <button type="reset"> Reset (inner)</button>
michael@0 118 </form>
michael@0 119 <button type="submit" id="neutered_submit11">Submit (outer)</button>
michael@0 120 <button type="reset">Reset (outer)</button>
michael@0 121 </form>
michael@0 122
michael@0 123 <!-- TODO: probably should have some accounts which have no port # in the action url. JS too. And different host/proto. -->
michael@0 124 <!-- TODO: www.site.com vs. site.com? -->
michael@0 125 <!-- TODO: foo.site.com vs. bar.site.com? -->
michael@0 126
michael@0 127 </div>
michael@0 128 <pre id="test">
michael@0 129 <script class="testbody" type="text/javascript">
michael@0 130
michael@0 131 /** Test for Login Manager: 360493 (Cross-Site Forms + Password Manager = Security Failure) **/
michael@0 132
michael@0 133 commonInit();
michael@0 134
michael@0 135 function startTest() {
michael@0 136 for (var i = 1; i <= 8; i++) {
michael@0 137 // Check form i
michael@0 138 is($_(i, "uname").value, "", "Checking for unfilled username " + i);
michael@0 139 is($_(i, "pword").value, "", "Checking for unfilled password " + i);
michael@0 140 }
michael@0 141
michael@0 142 is($_(9, "uname").value, "testuser", "Checking for unmodified username 9");
michael@0 143 is($_(9, "pword").value, "", "Checking for unfilled password 9");
michael@0 144
michael@0 145 is($_("10-A", "uname").value, "", "Checking for unfilled username 10A");
michael@0 146 is($_("10-A", "pword").value, "", "Checking for unfilled password 10A");
michael@0 147 //is($_("10-B", "uname").value, "", "Checking for unfilled username 10B");
michael@0 148 //is($_("10-B", "pword").value, "", "Checking for unfilled password 10B");
michael@0 149
michael@0 150 // The DOM indicates this form could be filled, as the evil inner form
michael@0 151 // is discarded. And yet pwmgr seems not to fill it. Not sure why.
michael@0 152 todo(false, "Mangled form combo not being filled when maybe it could be?");
michael@0 153 is($_("11-A", "uname").value, "testuser", "Checking filled username 11A");
michael@0 154 is($_("11-A", "pword").value, "testpass", "Checking filled password 11A");
michael@0 155 //is($_("11-B", "uname").value, "", "Checking for unfilled username 11B");
michael@0 156 //is($_("11-B", "pword").value, "", "Checking for unfilled password 11B");
michael@0 157
michael@0 158 // Verify this by making sure there are no extra forms in the document, and
michael@0 159 // that the submit button for the neutered forms don't do anything.
michael@0 160 // If the test finds extra forms the submit() causes the test to timeout, then
michael@0 161 // there may be a security issue.
michael@0 162 is(document.forms.length, 11, "Checking for unexpected forms");
michael@0 163 $("neutered_submit10").click();
michael@0 164 $("neutered_submit11").click();
michael@0 165
michael@0 166 SimpleTest.finish();
michael@0 167 }
michael@0 168
michael@0 169 window.onload = startTest;
michael@0 170
michael@0 171 SimpleTest.waitForExplicitFinish();
michael@0 172
michael@0 173 </script>
michael@0 174 </pre>
michael@0 175 </body>
michael@0 176 </html>
michael@0 177

mercurial