-
Notifications
You must be signed in to change notification settings - Fork 3
UI5 client side log-injection improvements #136
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 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9be063d
UpdateCodeQL, Remove warnings
mbaluda 43a33ad
UI5 client side log-injection improvements
mbaluda 253ec8a
Merge branch 'main' into mbaluda/logi-df
mbaluda e36a952
Fix expected file
mbaluda c094ef0
Updated test cases
mbaluda da07fc7
log data source and handler should be in the same web app
mbaluda 4f993e2
Update expected file
mbaluda 34e5585
Privete newtypes avoid name clashing
mbaluda 617b844
Rename query
mbaluda 9658ec8
Rename query
mbaluda 1d0b23e
Update SARIF expected file
mbaluda 4239d07
Add help files
mbaluda e54e4dc
Fix Typo
mbaluda a352009
Merge remote-tracking branch 'origin/main' into mbaluda/logi-df
mbaluda 1a1d423
Update expected SARIF file
mbaluda 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
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
6 changes: 3 additions & 3 deletions
6
javascript/frameworks/ui5/src/UI5LogInjection/UI5LogInjection.ql
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
36 changes: 36 additions & 0 deletions
36
javascript/frameworks/ui5/src/UI5LogInjection/UI5LogsToHttp.ql
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,36 @@ | ||
| /** | ||
| * @name UI5 Log injection in outbound network request | ||
| * @description Building log entries from user-controlled sources is vulnerable to | ||
| * insertion of forged log entries by a malicious user. | ||
| * @kind path-problem | ||
| * @problem.severity warning | ||
| * @security-severity 6.5 | ||
| * @precision medium | ||
| * @id js/ui5-log-injection-to-http | ||
| * @tags security | ||
| * external/cwe/cwe-117 | ||
| */ | ||
|
|
||
| import javascript | ||
| import advanced_security.javascript.frameworks.ui5.dataflow.DataFlow | ||
| import advanced_security.javascript.frameworks.ui5.dataflow.DataFlow::UI5PathGraph | ||
| import semmle.javascript.security.dataflow.LogInjectionQuery as LogInjection | ||
|
|
||
| class UI5LogInjectionConfiguration extends LogInjection::LogInjectionConfiguration { | ||
| override predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource } | ||
|
|
||
| override predicate isSink(DataFlow::Node node) { | ||
| exists(ClientRequest req | | ||
| node = req.getUrl() or | ||
| node = req.getADataNode() | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| from | ||
| UI5LogInjectionConfiguration cfg, UI5PathNode source, UI5PathNode sink, UI5PathNode primarySource | ||
| where | ||
| cfg.hasFlowPath(source.getPathNode(), sink.getPathNode()) and | ||
| primarySource = source.getAPrimarySource() | ||
| select sink, primarySource, sink, "Outbound network request depends on $@ log data.", primarySource, | ||
| "user-provided" |
63 changes: 63 additions & 0 deletions
63
javascript/frameworks/ui5/src/UI5LogInjection/UI5LogsUsed.ql
jeongsoolee09 marked this conversation as resolved.
Show resolved
Hide resolved
|
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,63 @@ | ||
| /** | ||
| * @name Access to user-controlled UI5 Logs | ||
| * @description Log entries from user-controlled sources should not be further processed. | ||
| * @kind path-problem | ||
| * @problem.severity warning | ||
| * @security-severity 5 | ||
| * @precision medium | ||
| * @id js/ui5-unsafe-log-access | ||
| * @tags security | ||
| * external/cwe/cwe-117 | ||
| */ | ||
|
|
||
| import javascript | ||
| import advanced_security.javascript.frameworks.ui5.dataflow.DataFlow | ||
| import advanced_security.javascript.frameworks.ui5.dataflow.DataFlow::UI5PathGraph | ||
| import semmle.javascript.security.dataflow.LogInjectionQuery as LogInjection | ||
|
|
||
| class UI5LogInjectionConfiguration extends LogInjection::LogInjectionConfiguration { | ||
| override predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource } | ||
|
|
||
| override predicate isSink(DataFlow::Node node) { | ||
| node = ModelOutput::getASinkNode("ui5-log-injection").asSink() | ||
| } | ||
| } | ||
|
|
||
| newtype TLogEntriesNode = | ||
| TDataFlowNode(DataFlow::Node node) or | ||
| TUI5ControlNode(UI5Control node) | ||
|
|
||
| class LogEntriesNode extends TLogEntriesNode { | ||
| DataFlow::Node asDataFlowNode() { | ||
| this = TDataFlowNode(result) and | ||
| result = ModelOutput::getATypeNode("SapLogEntries").getInducingNode() | ||
| } | ||
|
|
||
| UI5Control asUI5ControlNode() { | ||
| this = TUI5ControlNode(result) and | ||
| result.getImportPath() = "sap/ui/vk/Notifications" | ||
| } | ||
|
|
||
| string toString() { | ||
| result = this.asDataFlowNode().toString() | ||
| or | ||
| result = "UI5 control " + this.asUI5ControlNode().toString() | ||
| } | ||
|
|
||
| predicate hasLocationInfo( | ||
| string filepath, int startline, int startcolumn, int endline, int endcolumn | ||
| ) { | ||
| this.asDataFlowNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) | ||
| or | ||
| this.asUI5ControlNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) | ||
| } | ||
| } | ||
|
|
||
| from | ||
| UI5LogInjectionConfiguration cfg, UI5PathNode source, UI5PathNode sink, UI5PathNode primarySource, | ||
| LogEntriesNode logEntries | ||
| where | ||
| cfg.hasFlowPath(source.getPathNode(), sink.getPathNode()) and | ||
| primarySource = source.getAPrimarySource() | ||
| select logEntries, primarySource, sink, "Processing UI5 log entries that depend on $@.", | ||
mbaluda marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| primarySource, "user-provided data", logEntries, logEntries.toString() | ||
15 changes: 15 additions & 0 deletions
15
...i5/test/queries/UI5LogInjection/log-entry-flows-to-notifications/UI5LogInjection.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,15 @@ | ||
| nodes | ||
| | webapp/controller/app.controller.js:9:17:9:27 | input: null | | ||
| | webapp/controller/app.controller.js:15:17:15:52 | input | | ||
| | webapp/controller/app.controller.js:15:25:15:52 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:17:34:17:38 | input | | ||
| | webapp/view/app.view.xml:6:5:8:28 | value={/input} | | ||
| edges | ||
| | webapp/controller/app.controller.js:9:17:9:27 | input: null | webapp/controller/app.controller.js:15:25:15:52 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:9:17:9:27 | input: null | webapp/view/app.view.xml:6:5:8:28 | value={/input} | | ||
| | webapp/controller/app.controller.js:15:17:15:52 | input | webapp/controller/app.controller.js:17:34:17:38 | input | | ||
| | webapp/controller/app.controller.js:15:25:15:52 | oModel. ... input') | webapp/controller/app.controller.js:15:17:15:52 | input | | ||
| | webapp/view/app.view.xml:6:5:8:28 | value={/input} | webapp/controller/app.controller.js:9:17:9:27 | input: null | | ||
| | webapp/view/app.view.xml:6:5:8:28 | value={/input} | webapp/controller/app.controller.js:12:26:12:45 | new JSONModel(oData) | | ||
| #select | ||
| | webapp/controller/app.controller.js:17:34:17:38 | input | webapp/view/app.view.xml:6:5:8:28 | value={/input} | webapp/controller/app.controller.js:17:34:17:38 | input | Log entry depends on a $@. | webapp/view/app.view.xml:6:5:8:28 | value={/input} | user-provided value | |
15 changes: 15 additions & 0 deletions
15
...ks/ui5/test/queries/UI5LogInjection/log-entry-flows-to-notifications/UI5LogsUsed.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,15 @@ | ||
| nodes | ||
| | webapp/controller/app.controller.js:9:17:9:27 | input: null | | ||
| | webapp/controller/app.controller.js:15:17:15:52 | input | | ||
| | webapp/controller/app.controller.js:15:25:15:52 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:17:34:17:38 | input | | ||
| | webapp/view/app.view.xml:6:5:8:28 | value={/input} | | ||
| edges | ||
| | webapp/controller/app.controller.js:9:17:9:27 | input: null | webapp/controller/app.controller.js:15:25:15:52 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:9:17:9:27 | input: null | webapp/view/app.view.xml:6:5:8:28 | value={/input} | | ||
| | webapp/controller/app.controller.js:15:17:15:52 | input | webapp/controller/app.controller.js:17:34:17:38 | input | | ||
| | webapp/controller/app.controller.js:15:25:15:52 | oModel. ... input') | webapp/controller/app.controller.js:15:17:15:52 | input | | ||
| | webapp/view/app.view.xml:6:5:8:28 | value={/input} | webapp/controller/app.controller.js:9:17:9:27 | input: null | | ||
| | webapp/view/app.view.xml:6:5:8:28 | value={/input} | webapp/controller/app.controller.js:12:26:12:45 | new JSONModel(oData) | | ||
| #select | ||
| | webapp/view/app.view.xml:5:9:24:9 | UI5 control Notifications | webapp/view/app.view.xml:6:5:8:28 | value={/input} | webapp/controller/app.controller.js:17:34:17:38 | input | Processing UI5 log entries that depend on $@. | webapp/view/app.view.xml:6:5:8:28 | value={/input} | user-provided data | webapp/view/app.view.xml:5:9:24:9 | UI5 control Notifications | UI5 control Notifications | |
1 change: 1 addition & 0 deletions
1
...works/ui5/test/queries/UI5LogInjection/log-entry-flows-to-notifications/UI5LogsUsed.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 @@ | ||
| UI5LogInjection/UI5LogsUsed.ql |
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
19 changes: 19 additions & 0 deletions
19
...eworks/ui5/test/queries/UI5LogInjection/log-entry-flows-to-sinks/UI5LogInjection.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,19 @@ | ||
| nodes | ||
| | webapp/controller/app.controller.js:8:11:8:21 | input: null | | ||
| | webapp/controller/app.controller.js:14:13:14:48 | input | | ||
| | webapp/controller/app.controller.js:14:21:14:48 | oModel. ... input") | | ||
| | webapp/controller/app.controller.js:15:30:15:34 | input | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | | ||
| | webapp/view/app.view.xml:8:5:8:37 | content={/output} | | ||
| edges | ||
| | webapp/controller/app.controller.js:8:11:8:21 | input: null | webapp/controller/app.controller.js:14:21:14:48 | oModel. ... input") | | ||
| | webapp/controller/app.controller.js:8:11:8:21 | input: null | webapp/view/app.view.xml:5:5:7:28 | value={/input} | | ||
| | webapp/controller/app.controller.js:9:11:9:22 | output: null | webapp/view/app.view.xml:8:5:8:37 | content={/output} | | ||
| | webapp/controller/app.controller.js:11:22:11:41 | new JSONModel(oData) | webapp/view/app.view.xml:8:5:8:37 | content={/output} | | ||
| | webapp/controller/app.controller.js:14:13:14:48 | input | webapp/controller/app.controller.js:15:30:15:34 | input | | ||
| | webapp/controller/app.controller.js:14:21:14:48 | oModel. ... input") | webapp/controller/app.controller.js:14:13:14:48 | input | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:8:11:8:21 | input: null | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:11:22:11:41 | new JSONModel(oData) | | ||
| | webapp/view/app.view.xml:8:5:8:37 | content={/output} | webapp/controller/app.controller.js:9:11:9:22 | output: null | | ||
| #select | ||
| | webapp/controller/app.controller.js:15:30:15:34 | input | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:15:30:15:34 | input | Log entry depends on a $@. | webapp/view/app.view.xml:5:5:7:28 | value={/input} | user-provided value | |
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
...ameworks/ui5/test/queries/UI5LogInjection/log-entry-flows-to-sinks/UI5LogsToHttp.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,36 @@ | ||
| nodes | ||
| | webapp/controller/app.controller.js:8:11:8:21 | input: null | | ||
| | webapp/controller/app.controller.js:14:13:14:48 | input | | ||
| | webapp/controller/app.controller.js:14:21:14:48 | oModel. ... input") | | ||
| | webapp/controller/app.controller.js:15:30:15:34 | input | | ||
| | webapp/utils/CustomLogListener.js:9:29:9:34 | oEvent | | ||
| | webapp/utils/CustomLogListener.js:13:19:13:24 | oEvent | | ||
| | webapp/utils/CustomLogListener.js:13:19:13:32 | oEvent.message | | ||
| | webapp/utils/LogEntriesToHttp.js:7:13:7:52 | message | | ||
| | webapp/utils/LogEntriesToHttp.js:7:23:7:41 | Log.getLogEntries() | | ||
| | webapp/utils/LogEntriesToHttp.js:7:23:7:44 | Log.get ... es()[0] | | ||
| | webapp/utils/LogEntriesToHttp.js:7:23:7:52 | Log.get ... message | | ||
| | webapp/utils/LogEntriesToHttp.js:11:19:11:25 | message | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | | ||
| | webapp/view/app.view.xml:8:5:8:37 | content={/output} | | ||
| edges | ||
| | webapp/controller/app.controller.js:8:11:8:21 | input: null | webapp/controller/app.controller.js:14:21:14:48 | oModel. ... input") | | ||
| | webapp/controller/app.controller.js:8:11:8:21 | input: null | webapp/view/app.view.xml:5:5:7:28 | value={/input} | | ||
| | webapp/controller/app.controller.js:9:11:9:22 | output: null | webapp/view/app.view.xml:8:5:8:37 | content={/output} | | ||
| | webapp/controller/app.controller.js:11:22:11:41 | new JSONModel(oData) | webapp/view/app.view.xml:8:5:8:37 | content={/output} | | ||
| | webapp/controller/app.controller.js:14:13:14:48 | input | webapp/controller/app.controller.js:15:30:15:34 | input | | ||
| | webapp/controller/app.controller.js:14:21:14:48 | oModel. ... input") | webapp/controller/app.controller.js:14:13:14:48 | input | | ||
| | webapp/controller/app.controller.js:15:30:15:34 | input | webapp/utils/CustomLogListener.js:9:29:9:34 | oEvent | | ||
| | webapp/controller/app.controller.js:15:30:15:34 | input | webapp/utils/LogEntriesToHttp.js:7:23:7:41 | Log.getLogEntries() | | ||
| | webapp/utils/CustomLogListener.js:9:29:9:34 | oEvent | webapp/utils/CustomLogListener.js:13:19:13:24 | oEvent | | ||
| | webapp/utils/CustomLogListener.js:13:19:13:24 | oEvent | webapp/utils/CustomLogListener.js:13:19:13:32 | oEvent.message | | ||
| | webapp/utils/LogEntriesToHttp.js:7:13:7:52 | message | webapp/utils/LogEntriesToHttp.js:11:19:11:25 | message | | ||
| | webapp/utils/LogEntriesToHttp.js:7:23:7:41 | Log.getLogEntries() | webapp/utils/LogEntriesToHttp.js:7:23:7:44 | Log.get ... es()[0] | | ||
| | webapp/utils/LogEntriesToHttp.js:7:23:7:44 | Log.get ... es()[0] | webapp/utils/LogEntriesToHttp.js:7:23:7:52 | Log.get ... message | | ||
| | webapp/utils/LogEntriesToHttp.js:7:23:7:52 | Log.get ... message | webapp/utils/LogEntriesToHttp.js:7:13:7:52 | message | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:8:11:8:21 | input: null | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:11:22:11:41 | new JSONModel(oData) | | ||
| | webapp/view/app.view.xml:8:5:8:37 | content={/output} | webapp/controller/app.controller.js:9:11:9:22 | output: null | | ||
| #select | ||
| | webapp/utils/CustomLogListener.js:13:19:13:32 | oEvent.message | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/utils/CustomLogListener.js:13:19:13:32 | oEvent.message | Outbound network request depends on $@ log data. | webapp/view/app.view.xml:5:5:7:28 | value={/input} | user-provided | | ||
| | webapp/utils/LogEntriesToHttp.js:11:19:11:25 | message | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/utils/LogEntriesToHttp.js:11:19:11:25 | message | Outbound network request depends on $@ log data. | webapp/view/app.view.xml:5:5:7:28 | value={/input} | user-provided | |
1 change: 1 addition & 0 deletions
1
.../frameworks/ui5/test/queries/UI5LogInjection/log-entry-flows-to-sinks/UI5LogsToHttp.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 @@ | ||
| UI5LogInjection/UI5LogsToHttp.ql |
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.