DISE 3033 Computer Security: Chapter 4. Injection Attacks & Application Confinement
DISE 3033 Computer Security: Chapter 4. Injection Attacks & Application Confinement
Computer
Security
Chapter 4. Injection
Attacks & application
confinement
Asma Zubaida.2018
Last week, we looked at …
Attacks
• Buffer overflows
– Stack overflow & return address override
– Off-by-one overflow & frame pointer override
– Heap overflow & data or function pointer corruption
• printf attacks
– If you have the ability to set the format string
https://www.owasp.org/index.php/Top_10-2017_Top_10
February 20, 2018
Bad Input: SQL Injection
• Let’s create an SQL query in our program
sprintf(buf,
"SELECT * WHERE user='%s' AND query='%s';",
uname, query);
• You’re careful to limit your queries to a specific user
foo' OR user='root
https://xkcd.com/327/
uname = getResourceString("username");
passwd = getResourceString("password");
query = "SELECT * FROM users WHERE username = @0 AND password = @1";
db.Execute(query, uname, passwd);
try1.sh names
• ENV, BASH_ENV
– Set to a file name that some shells execute when a shell starts
LD_PRELOAD
– Forces a list of libraries to be loaded for a program, even if the program does
not ask for them
– If we preload our libraries, they get used instead of standard ones
You won’t get root access with this but you can change the behavior of
programs
– Change random numbers, key generation, time-related functions in
games
– List files or network connections that a program does
– Modify features or behavior of a program
• Parsing is tricky
– Particularly if wildcards are permitted (*, ?)
– And if subdirectories are permitted
• UTF-8
– If the first bit is a 0, we have a one-byte ASCII character
• Range 0..127
/ = 47 = 0x2f = 0010 0111
Yuck!
TUTORIAL
https://www.hacksplaining.com/exercises/sql-injectio
n