Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Cross-Site Scripting (XSS) : issue fix by sanitizing strings#1

Merged
JamieSlome merged 1 commit into418sec:masterfrom
d3v53c:huntr/xss-01
Jan 19, 2021
Merged

Cross-Site Scripting (XSS) : issue fix by sanitizing strings#1
JamieSlome merged 1 commit into418sec:masterfrom
d3v53c:huntr/xss-01

Conversation

@d3v53c
Copy link
Copy Markdown

@d3v53c d3v53c commented Nov 29, 2020

📊 Metadata *

d2b is vulnerable to Cross-Site Scripting (XSS).

Bounty URL: https://www.huntr.dev/bounties/1-npm-d2b

⚙️ Description *

Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted websites. XSS attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user. Flaws that allow these attacks to succeed are quite widespread and occur anywhere a web application uses input from a user within the output it generates without validating or encoding it.

💻 Technical Description *

Cross-Site Scripting (XSS) attacks are mitigated by sanitizing the user inputs before rendering, thereby preventing malicious execution.

🐛 Proof of Concept (PoC) *

  1. Open https://www.npmjs.com/package/d2b
  2. Open docs http://docs.d2bjs.org/ (You can see the d2b API references here.)
  3. Select any chart(Ex:pie chart http://docs.d2bjs.org/chartsAdvanced/pie.html)
  4. Edit in Codesandbox https://codesandbox.io/s/github/d2bjs/demos/tree/master/charts/pie/default-donut?from-embed
  5. We can change the version("d2b": "1.0.12")in package.json https://codesandbox.io/s/d2b-pie-default-donut-demo-forked-seghw?file=/package.json:231-246 see the screenshots.
  6. Insert the xss payload in any of the label field in data. EX: {label: 'arc 1"><img src=x onerror=alert(1)>', value: 23},
  7. XSS payload will get executed.

🔥 Proof of Fix (PoF) *

Before:

poc-before-xss

After:

poc-after-xss

👍 User Acceptance Testing (UAT)

poc-test

After the fix, functionality is unaffected.

@JamieSlome JamieSlome requested a review from mzfr December 16, 2020 14:21
@d3v53c
Copy link
Copy Markdown
Author

d3v53c commented Dec 22, 2020

Hi @bbeale , @Mik317 , @mufeedvh , @mzfr , I'm aware that you guys are busy, and I really appreciate the work you guys have done and are doing. However, I'd like an input on this fix, about whether this one is adequate or a nod on the fact that this fix involves installing another package/library only for the sake of escaping some strings is the right way to go ahead. If anyone has some pointers on any other approach, please do let me know. It'd not only help me fix and close this one, but also for the similar other open issues.

Keep up the good work!

Cheers!!

Copy link
Copy Markdown

@Mik317 Mik317 left a comment

Choose a reason for hiding this comment

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

LGTM 😄 🍰

Cheers,
Mik

Copy link
Copy Markdown

@mzfr mzfr left a comment

Choose a reason for hiding this comment

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

LGTM

@huntr-helper
Copy link
Copy Markdown

Congratulations d3v53c - your fix has been selected! 🎉

Thanks for being part of the community & helping secure the world's open source code.
If you have any questions, please respond in the comments section, or hit us up on Discord. Your bounty is on its way - keep hunting!

Come join us on Discord

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants