NShiftKey-Rule-Guide logo NShiftKey-Rule-Guide

1. Vulnerability Description

There are three types of XSS: Reflected XSS, Stored XSS, and DOM Based XSS, each with the following characteristics:

Reflected XSS

Stored XSS

DOM Based XSS

2. How to check vulnerability

To prove the vulnerability, simply enter a script to see if it runs. In a typical web environment, it is considered that a vulnerability exists if the desired HTML and JavaScript can be executed.

Reflected XSS

Stored XSS or DOM Based XSS

3. Vulnerability Countermeasure

3.1. Allow only characters in range to be used

http://www.target.com/board/read.do?table=qna&no=123&page=2

3.2. If Javascript is not allowed, the string used primarily in an attack is treated as a Black List to restrict input.

location=, href=, .open(, <script, javascript:, .cookie, .write, alert(, &#40, &#040, …

3.3. All arguments that do not need to allow HTML are processed as entities

Processing space(%0d,%0a,%0a0d) characters as null

< → &lt;
> → &gt;
" → &quot;
' → &#39;
& → &amp;
( → &#40
) → &#41
/  → &#47

3.4 When input values are output to JavaScript variables

(1) Do not use output of JavaScript variables, or take action using escapeJavaScript

(2) Use HTML attribute without outputting JavaScript variable. data-xxxx = “html encoded value” etc.