Skip to content

Commit d52a0c7

Browse files
committed
Ensure sanitizeContent attribute is respected
1 parent 378d564 commit d52a0c7

12 files changed

Lines changed: 96 additions & 9 deletions

File tree

javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/UI5View.qll

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -649,14 +649,11 @@ class XmlView extends UI5View instanceof XmlFile {
649649
ApiGraphModelsExtensions::sinkModel(getASuperType(type), path, "ui5-html-injection", _) and
650650
property = path.replaceAll(" ", "").regexpCapture("Member\\[([^\\]]+)\\]", 1) and
651651
result.getBindingTarget() = control.getAttribute(property) and
652-
/* If the control is an `sap.ui.core.HTML` then the control should be missing the `sanitizeContent` attribute */
653-
(
654-
getASuperType(type) = "HTMLControl"
655-
implies
656-
(
657-
not exists(control.getAttribute("sanitizeContent")) or
658-
control.getAttribute("sanitizeContent").getValue() = "false"
659-
)
652+
not (
653+
getASuperType(type) = "UI5HTMLControl" and
654+
// `sap.ui.core.HTML` controls are not sinks if the `sanitizeContent` attribute set to true
655+
control.getAttribute("sanitizeContent").getValue() = "true"
656+
// TODO: unless progeammatically set ot false
660657
)
661658
)
662659
}

javascript/frameworks/ui5/test/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ User input flows to XSS sinks via event handlers in 4 different ways:
4242

4343
### [xss-html-control](queries/UI5Xss/xss-html-control)
4444
- `sap.ui.core.HTML` Control
45+
46+
### [xss-html-control sanitized](queries/UI5Xss/xss-html-control sanitized)
47+
- `sap.ui.core.HTML` Control
48+
- sanitization using the `sanitizeContent` property set to true
4549

4650
### [xss-html-control-df](queries/UI5Xss/xss-html-control-df)
4751
- `sap.ui.core.HTML` Control
@@ -57,7 +61,7 @@ User input flows to XSS sinks via event handlers in 4 different ways:
5761

5862
### [xss-html-view](queries/UI5Xss/xss-html-view)
5963
- `sap.ui.core.mvc.HTMLView` View
60-
-
64+
6165
### [xss-indirect-control](queries/UI5Xss/xss-indirect-control)
6266
- control accessed indirectly
6367

javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control sanitized/UI5Xss.expected

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UI5Xss/UI5Xss.ql

javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control sanitized/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "sap-ui5-xss",
3+
"version": "1.0.0",
4+
"main": "index.js"
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
specVersion: '3.0'
2+
metadata:
3+
name: sap-ui5-xss
4+
type: application
5+
framework:
6+
name: SAPUI5
7+
version: "1.115.0"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sap.ui.define([
2+
"sap/ui/core/mvc/Controller",
3+
"sap/ui/model/json/JSONModel"
4+
], function (Controller, JSONModel) {
5+
"use strict"
6+
return Controller.extend("codeql-sap-js.controller.app", {
7+
onInit: function () {
8+
var oData = {
9+
input: null
10+
};
11+
var oModel = new JSONModel(oData);
12+
this.getView().setModel(oModel);
13+
}
14+
});
15+
})
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
6+
<meta charset="utf-8">
7+
<title>SAPUI5 XSS</title>
8+
<script src="https://sdk.openui5.org/resources/sap-ui-core.js"
9+
data-sap-ui-libs="sap.m"
10+
data-sap-ui-onInit="module:codeql-sap-js/index"
11+
data-sap-ui-resourceroots='{
12+
"codeql-sap-js": "./"
13+
}'>
14+
</script>
15+
</head>
16+
17+
<body class="sapUiBody" id="content">
18+
19+
</body>
20+
21+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sap.ui.define([
2+
"sap/ui/core/mvc/XMLView"
3+
], function (XMLView) {
4+
"use strict";
5+
XMLView.create({
6+
viewName: "codeql-sap-js.view.app"
7+
}).then(function (oView) {
8+
oView.placeAt("content");
9+
});
10+
11+
});

0 commit comments

Comments
 (0)