4 - Application-Layer Security (Web Security) Flashcards

1
Q

Explain SQL Injection.

A

Poorly developed systems do not validate user input properly, making it possible for the user (attacker) to type commands as input for a command (query) to be executed on the server.

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

How to prevent injection attacks?

A

Never trust any incoming data:

  • Check all incoming strings for executable code.
  • Replace special characters with their respective escape sequence.
  • Whitelist of specific set of characters.
  • Parameterized queries in SQL statements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How a system can store its users passwords securely in a database?

A

Only store a hash h = H(password) of the password and check H(input) == h to authenticate the user. Hash functions are non-reversible.

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

How does dictionary attacks on hashed passwords work?

A

The attacker pre-computes a vast amount of password-hash pairs and stores them in a lookup table (dictionary). Given a hash, the attacker can simply look the plain text
password up in the dictionary .

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

What is the limitation of dictionary attacks on hashed passwords?

A

Does not scale. The size of the dictionary grows exponentially with the length of the passwords. Storing and querying this amount of data is expensive, if not
infeasible.

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

Explain rainbow tables.

A

Set of chains. Each chain of fixed length K. A chain is creating by alternating plain-text passwords of a dictionary and hash values, obtained by applying the hash function H and a reduce function R:
passwd –H–> hash –R–> passwd –H–> hash –R–> passwd

The database stores only the first and last plain-text passwords of a chain.

Given a hash value, to find its equivalent password, we apply a reduce function to get a password from the dictionary. If this password is in the list of “last words” in the database, this chain contains the password we are looking for. Apply H and R until find the hash value we are looking and then take the previous password.

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

Why use rainbow tables?

A

Compared to dictionaries, rainbow tables offer a trade-off between time (more processing) and memory (less).

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

How can we protect against rainbow tables?

A

Using salted hashes. We append a random sequence of characters with the user password and then we apply the hash function. The random sequence (salt) is stores in the database along with the hash value. By doing this we force the attacker to recalculate the rainbow table for each password on a set of passwords.

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

How can sessions be implemented?

A

Hidden values: values are stored as invisible elements embedded in HTML and send by the browser with each request.

Cookies: key-value pairs sent by the server and stored in the user’s browser. Cookies are sent back to the server whenever the user loads a website from the same server.

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

How can an attacker hijack a victim’s session?

A

By getting hold of a client‘s session ID, an attacker can identify the victim and perform actions on behalf of the victim.

Attack #1: sniffing a client‘s traffic reveals the session ID.
Attack #2: Cross-Site Scripting (XSS) consists of injecting malicious code into third party pages viewed by others.

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

Which are the three types of XSS?

A

Reflected XSS:

  1. Malicious code is passed to the server as parameter (e.g. in the URL) and is inserted into the website by the server.
  2. The server sends the modified site back to the client which then executes the code.
  3. Attacker needs to lure the victim to his side or distribute a obscure link containing the XSS code (Links are usually distributed in forums or emails).

Persistent XSS: Malicious code directly stored on the vulnerable website ( comment sections, guest books, forums). Usually delivered to any visitor of the legitimate web page.

Local or DOM-based XSS: similar to reflected, but malicious code runs locally on the victim, without exploring server-side flaws.

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

How to prevent XSS attacks?

A
  • Sanity check of user inputs and escape characters
  • Blacklist: disallow certain characters and strings
  • Whitelist: restrict user input on a certain set of characters.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Cross-Site Request Forgery?

A

It is a method that allows the attacker to act on behalf of a victim by triggering HTTP request via the victim’s browser.

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

Which are the countermeasures for CSRF?

A

Secret Validation Token: embed a token as a hidden value in the original webpage and store it as session information on the server. When the request is triggered by the correct webpage, the client will send the correct token (the attacker does not know the correct token to use in its submission).

Check Refer/Origin: browsers send the URL which initiated the request in their header.

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

How to prevent an attacker from sniffing a client’s traffic to steal its session ID?

A

Using E2EE (SSL/TLS).

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