This code is vulnerable to an off-by-one-overflow, because
strlen(arg)
returns the length without the
\0
byte while
strcpy(buffer, arg)
copies everything including the
\0
byte.
Therefore our input can have the length 43 (incl. the
\0
byte) while the buffer can only take 42 bytes.
Therefore:
✅ Saved Frame Pointer
❌ Return Pointer
❌ No overflow because of a length check
Address Layout randomization
Which of the following is true?
Is always better than DEP
Randomizes memory layout
Can be bypassed with knowledge about addresses and local variables
Prevents a buffer overflow
Solution
ASLR is a countermeasure against ret2link and ROP attacks that bypass DEP by reusing code instead of injecting code into the
stack to execute it. Therefore ASLR without DEP would not be secure and is not necessarily better. ❌
Makes stack addresses, addresses of library routines, etc. unpredictable and different from machine to machine → Random base
addresses for: system call IDs, instruction sets, most importantly pointers. ✅
Can still be bypassed with Return/Jump/Data Oriented Programming and knowledge about addresses and local variables. ✅
XSS is possible and the server sees the attack scripts
XSS is possible and the server does not see the attack scripts
No exploits possible
Solution
Server side attacks in summary:
RCE: executing code (php or shell) remotely on the server
Client side attacks in summary:
CSRF: auto-triggering a request from clients browser to another cross site webpage
XSS: executing scripts on the clients browser (that get detected by the server-side except in the XSS-DOM attack if there is
no logging)
In this case
Server side attacks:
RCE:
GET ?argument=a; system("Shell Code"); HTTP/2
Host: example.com
GET ?argument=a; eval("PHP Code"); HTTP/2
Host: example.com
Client side attacks:
CSRF: possible by triggering a remote code injection from clients browser
XSS: reflected
GET ?argument="bogus content made by attacker"; HTTP/2
Host: example.com
CSRF is possible
: ✅ the attacker can auto trigger a request from the victims browser that contains a payload in the query.
XSS is possible and the server sees the attack scripts
: ✅ Reflected XSS attacks: can display data that the attacker chose once the vicitm clicked on a link containing the
attackers payload. (ie. using echo to display an arbitrary message)
A stored XSS attack is not possible because we can not store stuff into the html directly. (ie. as a forum post)
XSS is possible and the server does not see the attack scripts
: ❌
No exploits possible
: ❌ the server sees all attack scripts no matter if they are stored or not because it has to process each request. (even in
the case of DOM-XSS it can still be logged)
Cryptographic Protocols
A←{A,B,nB}−B
A−{Enc(m,sig(m,nB,skA)}pk
B
→B
Which of the following is true?
Injective agreement
A→B
non injective agreement
no agreement at all
confidentiality of
m
Solution
This is a type of PC-Handshake.
If we would place the authentication log events, then the protocol would look like this:
A←{A,B,n
B
}−B
event begin(A,B,M)
A−{Enc(m,sig(m,n
B
,skA)}p
k
B
→B
event end(A,B,M)
Injective agreementA→B
: Yes -
B
can check the freshness of the nonce ✅
non injective agreement
: No - the challenge could have been sent by anyone. ❌
no agreement at all: ❌
confidentiality ofm
: is preserved, because only
B
can read the message encrypted with their public key.
Electronic Codebook ECB
Which of the following is true?
Plaintext patterns are visible
parallel encryption is possible
parallel decryption is possible
random access is possible
Solution
All of the options above are true.
We can also see the plaintext-
patterns
that the ECB reveals:
One-way functions
Easy to compute output, infeasible to find the input from output
Collision-resistance
Infeasible to find different inputs that map to the same output
Collision(H(m1)=H(m2))∧(m1=m2)
✅ → definition from slides: "A hash function is any function that can be used to map data of arbitrary size to data of
fixed size."
❌
✅
✅ yes - because we use salt
OTP
What gets leaked when we use the
same key
multiple times for
two different plaintexts
?
m1⊕m2
the key
k
itself
m1⊕m2⊕k
nothing
Solution
✅
Important: Key must be used once for entirem
To save storage, one might try to split
m
up in smaller pieces and encrypt them with the same
c
.
c1=Enc(k,m1)=k⊕m1
c2=Enc(k,m2)=k⊕m2
c1⊕c2=(k⊕m1)⊕(k⊕m2)=m1⊕m2
which is vulnerable to frequency analysis.
❌
❌
❌
Stack Canaries
Which of the following is true?
Get validated just when we want to return from a function
Prevent overwriting the return address
Have no performance impact
Require a recompilation for activation
Solution
✅
❌ If pointer and its content both overwritable → changing
any memory
on or off the stack possible, therefore also the return address. like:
*dst=buf[0]
❌ Checking before each return does have a cost.
✅ aswell as a modified compiler.
SOP
What does the SOP check for the DOM?
Protocol
Domain
Port
Path
Solution
Javascript scripts can only read and write on same-origin-resources like the DOM.
same-origin
means pages must share the same: protocol, domain, subdomain, hostname, port.