Skip to content

Commit 2358e53

Browse files
elekanuengineer
authored andcommitted
HDDS-2111. XSS fragments can be injected to the S3g landing page
Signed-off-by: Anu Engineer <[email protected]>
1 parent 66bd168 commit 2358e53

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

hadoop-ozone/s3gateway/src/main/resources/webapps/static/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<meta charset="utf-8">
2222
<meta http-equiv="X-UA-Compatible" content="IE=edge">
2323
<meta name="viewport" content="width=device-width, initial-scale=1">
24+
<meta http-equiv="Content-Security-Policy" content="script-src 'self';">
2425
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
2526
<meta name="description" content="Apache Hadoop Ozone S3 gateway">
2627

@@ -68,12 +69,15 @@ <h1>S3 gateway</h1>
6869

6970
<p>For example with aws-cli:</p>
7071

71-
<pre>aws s3api --endpoint <script>document.write(window.location.href.replace("static/", ""))</script> create-bucket --bucket=wordcount</pre>
72+
<pre>aws s3api --endpoint <span id="s3gurl"></span> create-bucket --bucket=wordcount</pre>
7273

7374
<p>For more information, please check the <a href="docs">documentation.</a>
7475
</p>
7576
</div><!-- /.container -->
7677

77-
<script src="static/bootstrap-3.4.1/js/bootstrap.min.js"></script>
78+
<script src="jquery-3.4.1.min.js"></script>
79+
<script src="bootstrap-3.4.1/js/bootstrap.min.js"></script>
80+
<script src="s3g.js"></script>
81+
7882
</body>
7983
</html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
window.onload = function () {
20+
var safeurl = window.location.protocol + "//" + window.location.host + window.location.pathname;
21+
safeurl = safeurl.replace("static/", "");
22+
document.getElementById('s3gurl').innerHTML = safeurl;
23+
};

0 commit comments

Comments
 (0)