Self XSS via User-Agent

Description

Overview

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.

An attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with that site. These scripts can even rewrite the content of the HTML page.

Reflected attacks are those where the injected script is reflected off the web server, such as in an error message, search result, or any other response that includes some or all of the input sent to the server as part of the request. Reflected attacks are delivered to victims via another route, such as in an e-mail message, or on some other website. When a user is tricked into clicking on a malicious link, submitting a specially crafted form, or even just browsing to a malicious site, the injected code travels to the vulnerable web site, which reflects the attack back to the user’s browser. The browser then executes the code because it came from a "trusted" server. Reflected XSS is also sometimes referred to as Non-Persistent or Type-II XSS.

Browser URL

https://onmspentest.eastus.cloudapp.azure.com/opennms/admin/sysconfig.jsp

Steps To Reproduce

Replication steps are below:

![XSS_payload.png](https://api.cobalt.io/v1/attachments/att_LNN29Rz/preview)

  • Forward traffic

  • XSS payload will be triggered.

![Proof.png](https://api.cobalt.io/v1/attachments/att_F1BA3AR/preview)

Suggested Fix

1. Always treat all user input as untrusted data.

2. Never insert untrusted data except in allowed locations.
3. Always input or output-encode all data coming into or out of the application.
4. Always whitelist allowed characters and seldom use blacklisting of characters except in certain use cases.
5. Always use a well-known and security encoding API for input and output encoding such as the OWASP ESAPI.
6. Never try to write input and output encoders unless absolutely necessary. Chances are that someone has already written a good one.
7. Never use the DOM function innerHtml and instead use the functions innerText and textContent to prevent against DOM-based XSS.
8. As a best practice, consider using the HTTPOnly flag on cookies that are session tokens or sensitive tokens.
9. As a best practice, consider implementing Content Security Policy to protect against XSS and other injection type attacks.
10. As a best practice, consider using an auto-escaping templating system.
11. As a best practice, consider using the X-XSS-Protection response header.

Cobalt URL

#PT9265_16

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

chiuen (Qun) June 22, 2023 at 8:18 PM

Infosec evaluated at the following risk:

CVSS: AV:A/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:N/E:P/RL:U/RC:R/CR:H/IR:H/AR:H/MAV:A/MAC:X/MPR:X/MUI:X/MS:X/MC:X/MI:X/MA:X

CVSS Score: 6.0 x low likelihood 0.5 = 3.0 low

Details

Assignee

Reporter

Doc Backlog Status

Priority

PagerDuty

Created February 19, 2022 at 1:11 PM
Updated June 22, 2023 at 8:18 PM