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

json Handlebars helper allows unsafe HTML #84

Merged
merged 4 commits into from
Jan 21, 2018

Conversation

robhanlon22
Copy link
Contributor

@robhanlon22 robhanlon22 commented Jan 16, 2018

I noticed this vulnerability when I added a job to Bull that had job data that included some HTML. Since the json Handlebars helper assumes that its input is safe, any HTML that is rendered onto the job details page will be considered valid, including <script> tags.

You can repro this by creating a job in Bull (and maybe in Bee?) with data along the lines of

{
  "something": "<script>alert('Hello there!')</script>"
}

and then opening up the queueJobsByState page that includes the job with unsafe HTML. You'll see an alert.

bug is in this helper function:

json(obj, pretty = false) {

I've attached a fix in which all string values are escaped when the object is stringified.

@robhanlon22
Copy link
Contributor Author

Hi @bradvogel, thanks for merging #85! Was wondering if you saw this one—I converted it from an issue so you may have missed it.

@robhanlon22 robhanlon22 force-pushed the unsafe-html branch 4 times, most recently from 9b13b00 to 1122103 Compare January 19, 2018 16:03
Copy link
Contributor

@ttacon ttacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks great! Just a few tiny styling comments.

return content ? content.join('\n') : null;
const blocks = this._blocks;
const content = blocks && blocks[name];
return content ? content.join("\n") : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Let's keep these as (single quotes).

@@ -1,15 +1,25 @@
const _ = require('lodash');
const Handlerbars = require('handlebars');
const _ = require("lodash");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Here and below, let's use single quotes.

@robhanlon22
Copy link
Contributor Author

@ttacon comments addressed!

@bradvogel bradvogel merged commit 164ec86 into bee-queue:master Jan 21, 2018
@bradvogel
Copy link
Contributor

published as 2.4.2

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

Successfully merging this pull request may close these issues.

3 participants