-
Notifications
You must be signed in to change notification settings - Fork 4
Xml Fragments models #270
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
Xml Fragments models #270
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
02c8eda
Add small investigative modelling for fragments - WIP
knewbury01 ad42e91
Fix controls in xml detection
knewbury01 8f80775
Add simple testcase xss fragment in html view
knewbury01 b0c1aef
Add Fragment load model and test cases for basic xss
knewbury01 530df03
Improve UI5Xss detection for fragments_samples 1
data-douser bb9452e
More potential detection improvements for UI5 XSS
data-douser 97af1ac
Merge branch 'main' into knewbury01/ui5-fragments
mbaluda 4be732a
Fix syntax error in testcases for fragments
knewbury01 52cab4a
Merge branch 'knewbury01/ui5-fragments' of https://github.com/advance…
knewbury01 8b2be19
Fix sytnax fragment testcases
knewbury01 e75912c
Cleanup UI5 & RemoteFlowSources qll
data-douser 56ab432
Cleanup xss-urlparams-jsonmodel query test
data-douser 255b3ca
Add comment to FragmentModule class def
data-douser caf2596
Merge branch 'knewbury01/ui5-fragments' into knewbury01/dd/ui5-fragments
data-douser e762b43
Merge pull request #281 from advanced-security/knewbury01/dd/ui5-frag…
knewbury01 3b1847d
Merge branch 'knewbury01/ui5-fragments' of https://github.com/advance…
knewbury01 e66d3d8
Update expected js sarif for scan
knewbury01 af9af3d
Fix testcase naming for views in view files
knewbury01 e251725
Update expected file for xss-urlparams-jsonmodel after known model up…
knewbury01 86fd7d5
Add modelling for binding paths and default models when those are use…
knewbury01 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
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
51 changes: 51 additions & 0 deletions
51
javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/Fragment.qll
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,51 @@ | ||
| /** | ||
| * Provides classes for modeling the sap.ui.core.Fragment API. | ||
| */ | ||
|
|
||
| import javascript | ||
| import DataFlow | ||
| import advanced_security.javascript.frameworks.ui5.UI5 | ||
|
|
||
| /** | ||
| * Gets a reference to the Fragment module import. | ||
| */ | ||
| class FragmentLoad extends InvokeNode, MethodCallNode { | ||
| FragmentLoad() { | ||
| this = | ||
| TypeTrackers::hasDependency(["sap/ui/core/Fragment", "sap.ui.core.Fragment"]) | ||
| .getAMemberCall("load") | ||
| or | ||
| exists(RequiredObject requiredModule, SapDefineModule sapModule | | ||
| this = requiredModule.asSourceNode().getAMemberCall("load") and | ||
| //ensure it is an sap module define | ||
|
knewbury01 marked this conversation as resolved.
Outdated
|
||
| requiredModule.getEnclosingFunction() = sapModule.getArgument(1) | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Gets the configuration object passed to Fragment.load(). | ||
| */ | ||
| DataFlow::Node getConfigObject() { result = this.getArgument(0) } | ||
|
|
||
| /** | ||
| * Gets the 'name' property value from the config object. | ||
| * This specifies the fragment resource to load (e.g., "my.app.fragments.MyFragment"). | ||
| */ | ||
| DataFlow::Node getNameArgument() { | ||
| exists(DataFlow::ObjectLiteralNode config | | ||
| config = this.getConfigObject().getALocalSource() and | ||
| result = config.getAPropertyWrite("name").getRhs() | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Gets the 'controller' property value from the config object. | ||
| * This specifies the fragment's controller, if it has one. | ||
| */ | ||
| DataFlow::Node getControllerArgument() { | ||
| exists(DataFlow::ObjectLiteralNode config | | ||
| config = this.getConfigObject().getALocalSource() and | ||
| result = config.getAPropertyWrite("controller").getRhs() | ||
| ) | ||
| } | ||
| } | ||
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
31 changes: 31 additions & 0 deletions
31
...ipt/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/dataflow/FlowSteps.qll
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
12 changes: 12 additions & 0 deletions
12
javascript/frameworks/ui5/test/queries/UI5Xss/xss-fragment-static-byid/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,12 @@ | ||
| nodes | ||
| | webapp/controller/Main.controller.js:20:17:20:29 | sAttackerData | | ||
| | webapp/controller/Main.controller.js:20:33:20:97 | Fragmen ... Value() | | ||
| | webapp/controller/Main.controller.js:24:34:24:69 | "<span> ... /span>" | | ||
| | webapp/controller/Main.controller.js:24:45:24:57 | sAttackerData | | ||
| | webapp/view/Main.view.html:4:10:4:34 | data-content={/payload} | | ||
| edges | ||
| | webapp/controller/Main.controller.js:20:17:20:29 | sAttackerData | webapp/controller/Main.controller.js:24:45:24:57 | sAttackerData | | ||
| | webapp/controller/Main.controller.js:20:33:20:97 | Fragmen ... Value() | webapp/controller/Main.controller.js:20:17:20:29 | sAttackerData | | ||
| | webapp/controller/Main.controller.js:24:45:24:57 | sAttackerData | webapp/controller/Main.controller.js:24:34:24:69 | "<span> ... /span>" | | ||
| #select | ||
| | webapp/controller/Main.controller.js:24:34:24:69 | "<span> ... /span>" | webapp/controller/Main.controller.js:20:33:20:97 | Fragmen ... Value() | webapp/controller/Main.controller.js:24:34:24:69 | "<span> ... /span>" | XSS vulnerability due to $@. | webapp/controller/Main.controller.js:20:33:20:97 | Fragmen ... Value() | user-provided value | |
1 change: 1 addition & 0 deletions
1
javascript/frameworks/ui5/test/queries/UI5Xss/xss-fragment-static-byid/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-fragment-static-byid/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": "ui5-xss-fragment-static-byid", | ||
| "version": "1.0.0", | ||
| "main": "index.js" | ||
| } |
7 changes: 7 additions & 0 deletions
7
javascript/frameworks/ui5/test/queries/UI5Xss/xss-fragment-static-byid/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.0' | ||
| metadata: | ||
| name: ui5-xss-fragment-static-byid | ||
| type: application | ||
| framework: | ||
| name: SAPUI5 | ||
| version: "1.115.0" |
27 changes: 27 additions & 0 deletions
27
...rks/ui5/test/queries/UI5Xss/xss-fragment-static-byid/webapp/controller/Main.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,27 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/mvc/Controller", | ||
| "sap/ui/core/Fragment" | ||
| ], function (Controller, Fragment) { | ||
| "use strict"; | ||
| return Controller.extend("ui5-xss-fragment-static-byid.controller.Main", { | ||
| onInit: function () { | ||
| // Load fragment with view ID prefix | ||
| Fragment.load({ | ||
| id: this.getView().getId(), | ||
| name: "ui5-xss-fragment-static-byid.view.PayloadForm", | ||
| controller: this | ||
| }).then(function (oFragment) { | ||
| this.byId("fragmentArea").addContent(oFragment); | ||
| }.bind(this)); | ||
| }, | ||
|
|
||
| onSubmitPayload: function () { | ||
| // XSS vulnerability: Fragment.byId() static method to access fragment controls | ||
| var sAttackerData = Fragment.byId(this.getView().getId(), "attackerInput").getValue(); | ||
| var oHtmlSink = Fragment.byId(this.getView().getId(), "vulnerableOutput"); | ||
|
|
||
| // Sink: setContent with unsanitized user input | ||
| oHtmlSink.setContent("<span>" + sAttackerData + "</span>"); | ||
|
|
||
| } | ||
| }); | ||
| }); | ||
16 changes: 16 additions & 0 deletions
16
javascript/frameworks/ui5/test/queries/UI5Xss/xss-fragment-static-byid/webapp/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,16 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>UI5 XSS Fragment Static ById Test</title> | ||
| <script src="https://sdk.openui5.org/resources/sap-ui-core.js" | ||
| data-sap-ui-libs="sap.m" | ||
| data-sap-ui-onInit="module:ui5-xss-fragment-static-byid/index" | ||
| data-sap-ui-resourceroots='{ | ||
| "ui5-xss-fragment-static-byid": "./" | ||
| }'> | ||
| </script> | ||
| </head> | ||
| <body class="sapUiBody" id="content"> | ||
| </body> | ||
| </html> |
10 changes: 10 additions & 0 deletions
10
javascript/frameworks/ui5/test/queries/UI5Xss/xss-fragment-static-byid/webapp/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,10 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/mvc/HTMLView" | ||
| ], function (HTMLView) { | ||
| "use strict"; | ||
| HTMLView.create({ | ||
| viewName: "ui5-xss-fragment-static-byid.view.Main" | ||
| }).then(function (oView) { | ||
| oView.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.