-
Notifications
You must be signed in to change notification settings - Fork 2
Create query for vulnerability not specific to webapp security #78
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
Conversation
...t/queries/UI5PathInjection/path-custom-control-sanitized/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
...s/ui5/test/queries/UI5PathInjection/path-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
...5/test/queries/UI5PathInjection/path-custom-control-property-sanitized/webapp/control/xss.js
Fixed
Show resolved
Hide resolved
...eworks/ui5/test/queries/UI5PathInjection/path-custom-control-sanitized/webapp/control/xss.js
Fixed
Show resolved
Hide resolved
...s/ui5/test/queries/UI5PathInjection/path-html-control-df/webapp/controller/app.controller.js
Fixed
Show resolved
Hide resolved
Due to the addition of 4 lines at the beginning, the alert locations are expected to shift by 4 lines.
...5/test/queries/UI5PathInjection/path-custom-control-property-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...s/ui5/test/queries/UI5PathInjection/path-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
.../ui5/test/queries/UI5FormulaInjection/formula-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...test/queries/UI5FormulaInjection/formula-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
...rmulaInjection/formula-custom-control-property-sanitized/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
.../ui5/test/queries/UI5FormulaInjection/formula-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...rmulaInjection/formula-custom-control-property-sanitized/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
...ies/UI5FormulaInjection/formula-custom-control-sanitized/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
...test/queries/UI5FormulaInjection/formula-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
/* Data is sanitized against XSS. */ | ||
oRm.unsafeHtml(oControl.getText()); | ||
/* Data is not sanitized against formula injection. */ | ||
File.save(oControl.getText(), "/some/path/", "csv", "text/csv", "utf-8"); |
Check failure
Code scanning / CodeQL
UI5 Formula Injection
.../ui5/test/queries/UI5FormulaInjection/formula-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
.../queries/UI5FormulaInjection/formula-custom-control-property-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
.../ui5/test/queries/UI5FormulaInjection/formula-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...test/queries/UI5FormulaInjection/formula-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
.../ui5/test/queries/UI5FormulaInjection/formula-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
.../ui5/test/queries/UI5FormulaInjection/formula-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...test/queries/UI5FormulaInjection/formula-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
Technically it is also correct to use `require` here, but doing so complicates things since our queries are geared towards using `sap.ui.define`.
oRm.unsafeHtml(xssSanitized); | ||
oRm.close("div"); | ||
/* Data is not sanitized against formula injection. */ | ||
File.save(xssSanitized, "/some/path/", "csv", "text/csv", "utf-8"); |
Check failure
Code scanning / CodeQL
UI5 Formula Injection
this.getView().setModel(oModel); | ||
|
||
/* Data is not sanitized against formula injection. */ | ||
File.save(oModel.getProperty('/input'), "/some/path/", "csv", "text/csv", "utf-8"); |
Check failure
Code scanning / CodeQL
UI5 Formula Injection
<Input placeholder="Enter Payload" | ||
description="Try: <img src=x onerror=alert("XSS")>" | ||
value="{/input}" /> <!--User input source sap.m.Input.value --> | ||
<core:HTML id="xssSink" content="{/input}"/> <!--XSS sink sap.ui.core.HTML.content --> |
Check warning
Code scanning / CodeQL
UI5 Client-side cross-site scripting
...test/queries/UI5FormulaInjection/formula-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
...test/queries/UI5FormulaInjection/formula-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
/* Data is sanitized against XSS. */ | ||
oRm.unsafeHtml(oControl.getText()); | ||
/* Data is not sanitized against formula injection. */ | ||
File.save("some_content", oControl.getText(), "csv", "text/csv", "utf-8"); |
Check failure
Code scanning / CodeQL
UI5 Path Injection
oRm.unsafeHtml(xssSanitized); | ||
oRm.close("div"); | ||
/* Data is not sanitized against formula injection. */ | ||
File.save("some_content", xssSanitized, "csv", "text/csv", "utf-8"); |
Check failure
Code scanning / CodeQL
UI5 Path Injection
this.getView().setModel(oModel); | ||
|
||
/* Data is not sanitized against formula injection. */ | ||
File.save("some_content", oModel.getProperty('/input'), "csv", "text/csv", "utf-8"); |
Check failure
Code scanning / CodeQL
UI5 Path Injection
...5/test/queries/UI5PathInjection/path-custom-control-property-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...eworks/ui5/test/queries/UI5PathInjection/path-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...s/ui5/test/queries/UI5PathInjection/path-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
...eworks/ui5/test/queries/UI5PathInjection/path-custom-control-sanitized/webapp/control/xss.js
Fixed
Show fixed
Hide fixed
...s/ui5/test/queries/UI5PathInjection/path-html-control-df/webapp/controller/app.controller.js
Fixed
Show fixed
Hide fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Nice to see that queries look pretty standardized within the project 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested a few changes for the help files, feel free to use what you think is good
javascript/frameworks/ui5/src/UI5FormulaInjection/UI5FormulaInjection.md
Outdated
Show resolved
Hide resolved
javascript/frameworks/ui5/src/UI5FormulaInjection/UI5FormulaInjection.md
Outdated
Show resolved
Hide resolved
javascript/frameworks/ui5/src/UI5FormulaInjection/UI5FormulaInjection.md
Outdated
Show resolved
Hide resolved
javascript/frameworks/ui5/src/UI5PathInjection/UI5PathInjection.md
Outdated
Show resolved
Hide resolved
javascript/frameworks/ui5/src/UI5PathInjection/UI5PathInjection.md
Outdated
Show resolved
Hide resolved
javascript/frameworks/ui5/src/UI5PathInjection/UI5PathInjection.md
Outdated
Show resolved
Hide resolved
javascript/frameworks/ui5/src/UI5PathInjection/UI5PathInjection.md
Outdated
Show resolved
Hide resolved
javascript/frameworks/ui5/src/UI5PathInjection/UI5PathInjection.md
Outdated
Show resolved
Hide resolved
…jection.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
…jection.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
…jection.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
…n.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
…n.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
…n.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
…n.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
…n.md Co-authored-by: Mauro Baluda <mbaluda@github.com>
@mbaluda I ended up using all suggestions, thank you! |
What this PR contributes
This PR adds two additional queries to find two vulnerabilities not specific to web applications: path injection (CWE-022, CWE-035) and formula injection (CWE-1236).
Path Injection
A UI5-specific variant of semmle.javascript.security.dataflow.TaintedPathQuery. This query catches data flows from an arbitrary remote flow source to one of these data-flow nodes:
Storage.put(key, value)
's first argumentkey
File.save(content, path, extension, mimetype, charset, binaryordermark?)
's second argumentpath
Test suites
pathSinkTest.ql
path-custom-control-property-sanitized
path-custom-control-sanitized
sap.base.security.encodeXML
) does not prevent path injection.path-html-control
Formula Injection
This query aims to find a user-controlled data being written to a CSV or JSON file (CWE-1236 is originally about injecting into CSVs, but here it also aims to catch JSON injections as well). It catches data flows from an arbitrary remote flow source to one of these data-flow nodes:
Storage.put(key, value)
's second argumentvalue
File.save(content, path, extension, mimetype, charset, binaryordermark?)
's first argumentcontent
advanced_security.javascript.frameworks.ui5.UI5FormulaInjectionQuery
).There are no counterparts of this query in the standard query suite.
Test suites
formulaSinkTest.ql
formula-custom-control-property-sanitized
formula-custom-control-sanitized
sap.base.security.encodeXML
) does not prevent formula injection.formula-html-control
Miscellaneous
sap.ui.require
at the toplevel of sink.js to sap.ui.define. Technically it is also correct to userequire
, but it complicates things since the query codebase targetssap.ui.define
.Future Work
import semmle.javascript.security.dataflow.TaintedPathQuery as TaintedPathQuery
makes the testformula-custom-control-sanitized
fail.sap.ui.require
as well as its jQuery counterpart,jquery.sap.require
.