Web Application Security Theory Flashcards

1
Q

What is the golden rule of web application security

A

The client is never trustworthy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the golden rule means in practice?

A

We need to filter and check carefully anything that is sent to us

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the possibilities for implementing filtering?

A

Whitelisting, only allowing through what we expect

Blacklisting, discard known bad stuff

Escaping, transform special characters into something else which is less dangerous

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Blacklisting is safer than whitelisting

True or false

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is XSS?

A

Cross site scripting, is a vulnerability by means of which client side code can be injected in a page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the types of XSS

A

Stored XSS

Reflected XSS

Dom-based XSS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe the stored cross site scripting

A

The attacker input is stored on the target server in a database. Then the victim retrieves the stored, malicious code from the web application without that data being made safe to render in the browse.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe how the reflected XSS happens

A

A reflected Cross-Site Scripting (XSS) attack occurs when an attacker injects malicious scripts into a website, which are then reflected off a web server and executed in a user’s browser. These scripts are often included in a URL or input field and are processed by the server, then sent back to the user’s browser without proper validation or encoding.

Here’s a breakdown of how a reflected XSS attack typically works:

1.	Injection: The attacker crafts a malicious URL or input that contains JavaScript or other executable scripts.
2.	Submission: The victim clicks on the malicious link or submits a form with the malicious input.
3.	Reflection: The web server processes the input and includes it in the response back to the user’s browser without proper sanitization.
4.	Execution: The user’s browser executes the malicious script, which can then perform actions like stealing cookies, session tokens, or other sensitive information, and sending it back to the attacker.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the main difference between Stored and Reflected XSS

A

• Persistence: Stored XSS is persistent and affects any user accessing the compromised data, while reflected XSS is transient and targets individual users who interact with the malicious input.
• Attack Vector: Stored XSS typically requires an attacker to inject the script into a part of the application where it will be saved and viewed by users later. Reflected XSS requires the attacker to convince a user to click a link or submit a form containing the malicious script.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe the DOM based XSS

A

A DOM-based Cross-Site Scripting (XSS) attack is a type of XSS where the vulnerability exists in the client-side code rather than the server-side code. In this scenario, the malicious script is injected and executed entirely within the Document Object Model (DOM) of the user’s browser.

How DOM-based XSS Works

1.	Injection: The attacker crafts a malicious URL or input that manipulates the client-side script.
2.	Execution: When the victim’s browser processes the page, the client-side JavaScript reads and executes the malicious payload from the URL or other client-side sources like document.location, document.referrer, or document.cookie.
3.	Result: The script is executed within the context of the page, leading to the same kinds of effects as reflected or stored XSS, such as data theft, session hijacking, or defacement.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What can be done with cross site scripting

A

Cookie theft or section hijack

Manipulation of a section and execution of fraudulent transaction

Snooping on private information

Drive by download

Effective bypass, the same origin policy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Define the same origin policy (SOP)

A

All client side code loaded from origin A should only be able to access data from origin A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the problem of SOP?

A

Modern web has blurry boundaries (cross origin resource sharing, client side extensions)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does CSP stand for and what are its uses?

A

It stands for content security policy. It is a world wild Web consortium (W3C) specification to inform the browser on what should be trusted, and what not should be trusted.

Technically, it’s a set of directives sent by the server to the client in the form of HTTP response Heather.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Discuss an example of a CSP policy enforcement

A

Client ← Server:
Content-Security-Policy: script-src ‘self’ https://apis.google.com

Client (attacker) → Server:
XSS to permanently inject


Client (victim) ← Server:

<html> ...

<script>
</html>

Browser refuses to load script
</script>
</html>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the trade-off of CSP?

A

Strict policies break some functionalities

Relaxed policies can be bypassed

17
Q

What is a SQL injection?

A

SQL Injection is a type of security vulnerability that allows an attacker to interfere with the queries that an application makes to its database. It occurs when an attacker is able to insert or manipulate SQL code in such a way that it is executed by the database, potentially leading to unauthorized access, data leakage, or manipulation.

18
Q

How SQL injection works

A
  1. Injection Point: The attacker finds an input field in the application, such as a login form, search box, or URL parameter, where SQL queries are processed.
    1. Malicious Input: The attacker provides specially crafted input containing SQL code. This input is designed to modify the intended SQL query.
    2. Execution: The application executes the modified query, which can lead to various outcomes depending on the nature of the injected SQL.
19
Q

What is a blind injection and how does an attacker exploit it?

A

Blind SQLi: The attacker cannot see the results of the query directly but can infer them based on the application’s behavior.
• Boolean-based Blind SQLi: The attacker sends queries that result in true or false conditions and observes the application’s response.
• Time-based Blind SQLi: The attacker sends queries that cause delays in the database response and infers information based on the response time.

20
Q

How do we make SQL injections more difficult

A

Input sanitization (validation and filtering)

Using prepared statements (parametric query) instead of building query strings

Not using table names as field names

Limitations on query privileges, different users can execute different types of queries on different tables

21
Q

How does the security requirement of never mix code and data, conflict with the web functional requirement and what is the consequence of that?

A

The functional requirement of a Web sometimes enforces to mix code and data.

The consequence of that is, if, at any point, there is a parser routine (EX, the browsers JavaScript parser) that reacts (EX, prints something) on some control sequences found in the data, we have a vulnerability

22
Q

What are Freudian slips?

A

In the context of computer security, “Freudian slips” can be seen as analogous to human errors or unintentional actions that reveal underlying vulnerabilities or security weaknesses in systems and practices. These “slips” in cybersecurity can lead to unintended consequences that compromise security.

23
Q

What are some examples of Freudian Slips?

A

Error messages containing sensitive information

Insertion of user supplied data in errors (reflected XSS risk)

Debug traces active in production. They can reveal: server and application versions, database names, structure, and credential, path names.

Side–channels (EX, user not found VS password mismatch)

24
Q

Define a session creation and identification using cookies

A

See picture 4S in the Comp Sec album

25
Q

What are some security issues with sessions created by cookies?

A

Prevent prediction of the token a client received or will receive, to prevent impersonations/spoofing attacks, minimize damage of session stealing

Any token Should have a reasonable expiration period

Cookie encryption and storage

26
Q

Due to the fact, that HTTPis a stateless what are the types of hijacking that can occur

A

Stealing a cookie with a XSS attack

Brute forcing a weak session ID parameter

27
Q

What does CSRF stands for?

A

Cross site request forgery

28
Q

Define CSRF

A

Forces an user to execute unwanted actions (state changing action) on a web application in which he or she is currently authenticated with ambient credentials (EX, with cookies)

29
Q

Discuss how a CSRF can occur

A

Key Concept:
● Cookies are used for session management.
● All the requests originating by the browser come with the
user’s cookies (cookies are ambient credentials: they are
sent automatically for every request).
● Malicious requests (e.g., crafted links) are routed to the
vulnerable web application through the victim’s browser.
● Websites cannot distinguish if the requests coming from
authenticated users have been originated by an explicit user interaction or not.

30
Q

Discuss a CSRF example for a malicious bank transfer

A

See picture 5S in the Comp Sec album

31
Q

What is the main mitigation for CSRF?

A

The CSRF token

32
Q

How does a CSRF token works

A

How CSRF Tokens Work

1.	Token Generation: When a user visits a web application, the server generates a unique CSRF token for that user session. This token is a random value that is difficult for an attacker to guess.
2.	Token Storage: The CSRF token is stored on the server side and is also included in the client’s web page, typically as a hidden form field or as a value in the session storage or a cookie.
3.	Token Validation: When the user submits a form or makes a state-changing request, the CSRF token is included in the request. The server then checks the token received from the client against the token it generated and stored.
4.	Action Authorization: If the token is valid and matches the stored token, the server processes the request. If the token is missing or incorrect, the server rejects the request, preventing the CSRF attack.
33
Q

What is another mitigation for CSRF

A

Same site cookies

The main idea is to not send session cookies at all for requests originating from different websites.

This way a request that was induced by an attacker do not contain the authentication cookie, possibly present in the client cash.

34
Q

How can a same site cookie be specified?

A

They are specified when the website is created by setting the SameSite attribute

The SameSite attribute can be set to one of three values: Strict, Lax, or None. Each of these values offers a different level of protection against CSRF attacks:

  1. SameSite=Strict
    • Behavior: Cookies with the SameSite=Strict attribute are not sent with any cross-site requests, including links clicked from another site.
  2. SameSite=Lax
    • Behavior: Cookies with the SameSite=Lax attribute are sent with top-level navigation requests (e.g., when the user clicks a link to the site) but not with subrequests (e.g., images or iframes from another site).