doc/user/application_security/dast/browser/checks/79.1.md
Cross Site Scripting (XSS) is an attack which exploits a web application or system to treat user input as markup or script code. It is important to encode the data depending on the specific context it is used in. There are at least six context types:
<div>context 1</div><div class="context 2"></div><button onclick="context 3">button</button><script>var x = "context 4"</script>element.innerHTML = "context 5"<iframe src="context 6"></iframe><a href="context 6">link</a>Script blocks alone can be encoded in multiple ways. Exercise caution if user input must be written outside script tags.
User input displayed in the application must be encoded, sanitized, or validated
so it isn't treated as HTML or executed as JavaScript code. Be careful not to
mix server-side templating with client-side templating, because the server-side doesn't encode
text like {{ 7*7 }}, which might execute client-side features.
Do not encode user input before inserting it into a data store. The data must be encoded based on its output context. It is much safer to force the displaying system to handle the encoding.
Consider using built-in framework capabilities for automatically encoding user input. If you can't automatically encode input, be careful to use the proper output encoding. The following recommendations are a best effort, and might not work in all circumstances.
Encode the following inside HTML tags, excluding script:
< to <> to >' to '" to "= to =Encode the following inside attributes, excluding event attributes:
< to <> to >' to '" to "= to =Encode the following inside event attributes, script blocks, and unsafe HTML assignment:
\t) to \\t\n) to \\n\v) to \u000b\f) to \\f\r) to \\r=) to \u0061\) to \u0060") to \u0022&) to \u0026') to \u0027+) to \u002b/) to \/<) to \u003c>) to \u003e() to \u0028)) to \u0029[) to \u005b]) to \u005d{) to \u007b}) to \u007d\) to \\This list is not exhaustive. You might need to encode additional characters depending on context.
Inside URLs:
javascript:... code or malicious links.| ID | Aggregated | CWE | Type | Risk |
|---|---|---|---|---|
| 79.1 | false | 79 | Active | high |