question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Search Bar contains Reflected Cross-Site Scripting

See original GitHub issue

Search-bar contains Reflected Cross-Site Scripting

The search-bar that functions as a product filter is vulnerable to XSS since it does not perform any validation nor sanitization on users’ input. An example of exploitation of this vulnerability is shown below,

poc_reflected_xss_simplcommerce

As illustrated above, since the application doesn’t perform any processing of the data, an attacker can construct a basic XSS payload like this,

</script><script>alert(‘s1nj0r0’)<script>

triggering cross-site scripting. In other words, the malicious input is injected in the HTML opening a script tag with an alert method. As shown, the alert was triggered confirming that the code is vulnerable.

Exploitation and Mitigation

The following figure illustrates the vulnerable code. The user-supplied data is passed directly through an @Html.Raw which allows outputting text containing HTML elements to the client, and have them still be rendered as such i.e., will allow the execution of any script that is on the value to display, exposing SimplCommerce to cross-site scripting.

Index.cshtml

search_bar_reflected_xss

How should I fix it?

Sanitizing the user-supplied data is the key to avoid XSS. Moreover, @Html.Raw is just a tool but if you are displaying user-supplied data it is better to use another method such as @Html.Encode(). However, @Html.Encode() does not cover all XSS attacks.

Useful Links

Cross Site Scripting (XSS) Software Attack | OWASP Foundation

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
s1nj0r0commented, Sep 28, 2020

Hey guys @thiennn @hishamco, yes, it is fixed. I strongly recommend you to create the GitHub Security Advisories GSC for this repository.

0reactions
tavershimafxcommented, Sep 29, 2020

This vulnerability is rippled around the application. Somewhere in _WidgetInstance.cshtml too

Read more comments on GitHub >

github_iconTop Results From Across the Web

[CVE-2021-26722] Reflected Cross-Site Scripting in search ...
Hi! I've found a reflected cross-site scripting vulnerability in Oncall's search bar. I've reported this issue to the LinkedIn Information ...
Read more >
javascript - Typical 'search box' XSS attack
The goal of an XSS attack is for an attacker to somehow inject code into a webpage that is served from your site....
Read more >
Cross Site Scripting (XSS) Attack Tutorials with Examples, ...
Let's analyze a simple Example: Consider we have a website with a search field. XSS Example. If the search field is vulnerable, when...
Read more >
What is reflected XSS (cross-site scripting)? Tutorial ...
Reflected cross -site scripting (or XSS) arises when an application receives data in an HTTP request and includes that data within the immediate...
Read more >
What kind of XSS can I do in a search bar? : r/cybersecurity
I have an academic project where I need to explore a vulnerable application. One of the pages is this products where there is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found