-
Notifications
You must be signed in to change notification settings - Fork 4
Improve UI5Xss.ql query to detect default OData model with bindElement
#283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c36405e
UI5 XSS detect default OData model w/ bindElement
data-douser a6964d5
Update javascript.sarif.expected
data-douser 3c580c3
Fix cross-app isolation for UI5 default OData model
data-douser f01e030
Improve and re-use UI5::inSameWebApp() predicate
data-douser e0ed82a
Merge branch 'main' into dd/default-odata-model-fragments
data-douser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/UI5Xss.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| nodes | ||
| | webapp_a/controller/App.controller.js:21:17:21:54 | oFragme ... sA(1)") | | ||
| | webapp_a/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageA} | | ||
| | webapp_b/controller/App.controller.js:21:17:21:54 | oFragme ... sB(1)") | | ||
| | webapp_b/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageB} | | ||
| edges | ||
| | webapp_a/controller/App.controller.js:21:17:21:54 | oFragme ... sA(1)") | webapp_a/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageA} | | ||
| | webapp_a/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageA} | webapp_a/controller/App.controller.js:21:17:21:54 | oFragme ... sA(1)") | | ||
| | webapp_b/controller/App.controller.js:21:17:21:54 | oFragme ... sB(1)") | webapp_b/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageB} | | ||
| | webapp_b/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageB} | webapp_b/controller/App.controller.js:21:17:21:54 | oFragme ... sB(1)") | | ||
| #select | ||
| | webapp_a/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageA} | webapp_a/controller/App.controller.js:21:17:21:54 | oFragme ... sA(1)") | webapp_a/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageA} | XSS vulnerability due to $@. | webapp_a/controller/App.controller.js:21:17:21:54 | oFragme ... sA(1)") | user-provided value | | ||
| | webapp_b/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageB} | webapp_b/controller/App.controller.js:21:17:21:54 | oFragme ... sB(1)") | webapp_b/fragments/DataDisplay.fragment.xml:7:9:7:43 | content={messageB} | XSS vulnerability due to $@. | webapp_b/controller/App.controller.js:21:17:21:54 | oFragme ... sB(1)") | user-provided value | |
1 change: 1 addition & 0 deletions
1
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/UI5Xss.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| UI5Xss/UI5Xss.ql |
5 changes: 5 additions & 0 deletions
5
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "xss-cross-app-isolation", | ||
| "version": "1.0.0", | ||
| "description": "Test case for ensuring XSS detection does not cross webapp boundaries with default OData models" | ||
| } |
7 changes: 7 additions & 0 deletions
7
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/ui5.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| specVersion: "3.1" | ||
| type: application | ||
| metadata: | ||
| name: xss-cross-app-isolation | ||
| framework: | ||
| name: SAPUI5 | ||
| version: "1.120.0" |
13 changes: 13 additions & 0 deletions
13
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_a/Component.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/UIComponent" | ||
| ], function (UIComponent) { | ||
| "use strict"; | ||
| return UIComponent.extend("app.a.Component", { | ||
| metadata: { | ||
| manifest: "json" | ||
| }, | ||
| init: function () { | ||
| UIComponent.prototype.init.apply(this, arguments); | ||
| } | ||
| }); | ||
| }); |
28 changes: 28 additions & 0 deletions
28
...rks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_a/controller/App.controller.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/mvc/Controller", | ||
| "sap/ui/core/Fragment" | ||
| ], function (Controller, Fragment) { | ||
| "use strict"; | ||
|
|
||
| return Controller.extend("app.a.controller.App", { | ||
| onInit: function () { | ||
| // XSS vulnerability pattern in App A: | ||
| // 1. OData model is configured as default model in manifest.json | ||
| // 2. Fragment is loaded dynamically | ||
| // 3. Fragment is bound to OData entity via bindElement | ||
| // 4. Fragment contains HTML control that renders OData content | ||
|
|
||
| Fragment.load({ | ||
| id: this.getView().getId(), | ||
| name: "app.a.fragments.DataDisplay", | ||
| controller: this | ||
| }).then(function (oFragment) { | ||
| // Bind fragment to an OData entity - vulnerability is in the backend data | ||
| oFragment.bindElement("/MessagesA(1)"); | ||
|
|
||
| // Add the fragment to the page content | ||
| this.byId("page").addContent(oFragment); | ||
| }.bind(this)); | ||
| } | ||
| }); | ||
| }); |
9 changes: 9 additions & 0 deletions
9
...5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_a/fragments/DataDisplay.fragment.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <core:FragmentDefinition | ||
| xmlns="sap.m" | ||
| xmlns:core="sap.ui.core"> | ||
| <VBox class="sapUiSmallMargin"> | ||
| <Label text="Message from OData in App A:" /> | ||
| <!-- XSS vulnerability: HTML content bound to OData property containing unsanitized data --> | ||
| <core:HTML content="{messageA}" /> | ||
|
|
||
| </VBox> | ||
| </core:FragmentDefinition> | ||
19 changes: 19 additions & 0 deletions
19
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_a/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>App A - XSS Cross-App Isolation Test</title> | ||
| <script | ||
| id="sap-ui-bootstrap" | ||
| src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" | ||
| data-sap-ui-theme="sap_fiori_3" | ||
| data-sap-ui-resourceroots='{ | ||
| "app.a": "./" | ||
| }' | ||
| data-sap-ui-oninit="module:app/a/index" | ||
| data-sap-ui-async="true"> | ||
| </script> | ||
| </head> | ||
| <body class="sapUiBody" id="content"> | ||
| </body> | ||
| </html> |
12 changes: 12 additions & 0 deletions
12
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_a/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/ComponentContainer" | ||
| ], function (ComponentContainer) { | ||
| "use strict"; | ||
| new ComponentContainer({ | ||
| name: "app.a", | ||
| settings: { | ||
| id: "app.a" | ||
| }, | ||
| async: true | ||
| }).placeAt("content"); | ||
| }); |
48 changes: 48 additions & 0 deletions
48
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_a/manifest.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| { | ||
| "_version": "1.58.0", | ||
| "sap.app": { | ||
| "id": "app.a", | ||
| "type": "application", | ||
| "title": "App A - XSS Cross-App Isolation Test", | ||
| "applicationVersion": { | ||
| "version": "1.0.0" | ||
| }, | ||
| "dataSources": { | ||
| "mainService": { | ||
| "uri": "/odata/v4/catalog_a/", | ||
| "type": "OData", | ||
| "settings": { | ||
| "odataVersion": "4.0" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "sap.ui": { | ||
| "technology": "UI5", | ||
| "deviceTypes": { | ||
| "desktop": true, | ||
| "tablet": true, | ||
| "phone": true | ||
| } | ||
| }, | ||
| "sap.ui5": { | ||
| "rootView": { | ||
| "viewName": "app.a.view.App", | ||
| "type": "XML", | ||
| "id": "app" | ||
| }, | ||
| "dependencies": { | ||
| "minUI5Version": "1.60", | ||
| "libs": { | ||
| "sap.m": {} | ||
| } | ||
| }, | ||
| "models": { | ||
| "": { | ||
| "dataSource": "mainService", | ||
| "preload": true, | ||
| "settings": {} | ||
| } | ||
| } | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...ipt/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_a/view/App.view.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <mvc:View | ||
| controllerName="app.a.controller.App" | ||
| xmlns:mvc="sap.ui.core.mvc" | ||
| xmlns="sap.m" | ||
| xmlns:core="sap.ui.core" | ||
| displayBlock="true"> | ||
| <App id="app"> | ||
| <Page id="page" title="App A - XSS Cross-App Isolation Test"> | ||
| <content> | ||
| <!-- Fragment will be loaded here dynamically --> | ||
| </content> | ||
| </Page> | ||
| </App> | ||
| </mvc:View> |
13 changes: 13 additions & 0 deletions
13
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_b/Component.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/UIComponent" | ||
| ], function (UIComponent) { | ||
| "use strict"; | ||
| return UIComponent.extend("app.b.Component", { | ||
| metadata: { | ||
| manifest: "json" | ||
| }, | ||
| init: function () { | ||
| UIComponent.prototype.init.apply(this, arguments); | ||
| } | ||
| }); | ||
| }); |
28 changes: 28 additions & 0 deletions
28
...rks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_b/controller/App.controller.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/mvc/Controller", | ||
| "sap/ui/core/Fragment" | ||
| ], function (Controller, Fragment) { | ||
| "use strict"; | ||
|
|
||
| return Controller.extend("app.b.controller.App", { | ||
| onInit: function () { | ||
| // XSS vulnerability pattern in App B: | ||
| // 1. OData model is configured as default model in manifest.json | ||
| // 2. Fragment is loaded dynamically | ||
| // 3. Fragment is bound to OData entity via bindElement | ||
| // 4. Fragment contains HTML control that renders OData content | ||
|
|
||
| Fragment.load({ | ||
| id: this.getView().getId(), | ||
| name: "app.b.fragments.DataDisplay", | ||
| controller: this | ||
| }).then(function (oFragment) { | ||
| // Bind fragment to an OData entity - vulnerability is in the backend data | ||
| oFragment.bindElement("/MessagesB(1)"); | ||
|
|
||
| // Add the fragment to the page content | ||
| this.byId("page").addContent(oFragment); | ||
| }.bind(this)); | ||
| } | ||
| }); | ||
| }); |
9 changes: 9 additions & 0 deletions
9
...5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_b/fragments/DataDisplay.fragment.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <core:FragmentDefinition | ||
| xmlns="sap.m" | ||
| xmlns:core="sap.ui.core"> | ||
| <VBox class="sapUiSmallMargin"> | ||
| <Label text="Message from OData in App B:" /> | ||
| <!-- XSS vulnerability: HTML content bound to OData property containing unsanitized data --> | ||
| <core:HTML content="{messageB}" /> | ||
|
|
||
| </VBox> | ||
| </core:FragmentDefinition> | ||
19 changes: 19 additions & 0 deletions
19
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_b/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>App B - XSS Cross-App Isolation Test</title> | ||
| <script | ||
| id="sap-ui-bootstrap" | ||
| src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" | ||
| data-sap-ui-theme="sap_fiori_3" | ||
| data-sap-ui-resourceroots='{ | ||
| "app.b": "./" | ||
| }' | ||
| data-sap-ui-oninit="module:app/b/index" | ||
| data-sap-ui-async="true"> | ||
| </script> | ||
| </head> | ||
| <body class="sapUiBody" id="content"> | ||
| </body> | ||
| </html> |
12 changes: 12 additions & 0 deletions
12
javascript/frameworks/ui5/test/queries/UI5Xss/xss-cross-app-isolation/webapp_b/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/ComponentContainer" | ||
| ], function (ComponentContainer) { | ||
| "use strict"; | ||
| new ComponentContainer({ | ||
| name: "app.b", | ||
| settings: { | ||
| id: "app.b" | ||
| }, | ||
| async: true | ||
| }).placeAt("content"); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.