Skip to content
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

Checkmarx reports Client Potential XSS #905

Closed
richardf opened this issue Mar 10, 2021 · 3 comments
Closed

Checkmarx reports Client Potential XSS #905

richardf opened this issue Mar 10, 2021 · 3 comments

Comments

@richardf
Copy link

richardf commented Mar 10, 2021

Our infosec area ran Checkmarx against an application using QueryBuilder which reported two potential XSS, as shown below.
I am not sure those are real problems. Could they be false positives?

Client Potential XSS\Path 1:

The application's function embeds untrusted data in the generated output with html, at line 1452 of js/query-builder.standalone.js. This untrusted data is embedded straight into the output without proper sanitization or encoding, enabling an attacker to inject malicious code into the output.

Source
File: js/query-builder.standalone.js
Line: 3152
Object: change

Destination
File: js/query-builder.standalone.js
Line: 1464
Object: html

Code snippet
Method: QueryBuilder.prototype.getRuleFilterSelect = function(rule, filters) {

...
3152. return this.change('getRuleFilterSelect', h, rule,
$.parseHTML(filters));

Method: QueryBuilder.prototype.createRuleFilters = function(rule) {

...
1464.
rule.$el.find(QueryBuilder.selectors.filter_container).html(htmlFilter);

Client Potential XSS\Path 2:

The application's function embeds untrusted data in the generated output with append, at line 1178 of js/query-builder.standalone.js. This untrusted data is embedded straight into the output without proper sanitization or encoding, enabling an attacker to inject malicious code into the output.

Source
File: js/query-builder.standalone.js
Line: 3096
Object: change

Destination
File: js/query-builder.standalone.js
Line: 1184
Object: append

Code snippet
Method: QueryBuilder.prototype.getGroupTemplate = function(group_id, level) {

...
3096. return this.change('getGroupTemplate', h, level);

Method: QueryBuilder.prototype.setRoot = function(addRule, data, flags) {

...
1184. this.$el.append($group);
@mistic100
Copy link
Owner

mistic100 commented Mar 19, 2021

Is using $.parseHTML enough ?

@mistic100
Copy link
Owner

Using $($.parseHTML(content)) instead of $(content) seems to solve it.

Tested locally by registering this handler :

$('#builder').on('getRuleFilterSelect.queryBuilder.filter', function(e) {
    e.value += '<script';
    e.value += '>alert("hello");</';
    e.value += 'script>';
  });

I will make the same change on all HTML parsing

@richardf
Copy link
Author

Thank you for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants