What are some taint sources in this binary?
In this binary the only un-trusted input comes in over the network socket and then gets shoved into an execl(…) call. The key taint‐sources are:
• socket()/bind()/listen()/accept()
– these set up the listening TCP socket and give you a client FD, but don’t actually read user data yet.
• recv() (at 0x00101240)
– this is where raw bytes from the remote client enter your program’s buffer.
Everything downstream (any sscanf/swscanf parsing, strcpy-style copies, string ops, etc.) is ultimately driven by the data you got from recv(), and that buffer is what winds up as an argument to execl(), making recv() your primary taint source.
Can you describe the propagation path from recv() to excel()?
Here’s the step-by-step flow of taint from the network all the way into the execl() call:
-
socket()/bind()/listen()/accept()
– sets up a listening socket and hands you a client fd (local_ac). -
recv(local_ac, local_a0 + local_98, 99-local_98, 0)
–local_a0points atlocal_78, which was pre-filled with “ls ”
–local_98 = strlen(local_78)== 3, so recv appends up to 96 bytes of attacker data immediately after “ls ” -
if (recv > 0) {
• NUL-terminate at the end of what you read
• Find any ‘\r’ or ‘\n’ in the buffer and replace it with ‘\0’
} -
close the sockets
-
FUN_00101914(&local_a0)
– you pass the address of yourchar *local_a0into this helper -
Inside FUN_00101914:
execl(
"/bin/sh", ← hard-coded shell path
"/bin/sh", ← argv[0]
&DAT_00103046, ← typically the literal "-c"
*param_1, ← the contents oflocal_a0(i.e. "ls " + attacker data)
NULL
);
Because the exact bytes you recv get concatenated to the “ls ” prefix and then passed straight to execl("/bin/sh","/bin/sh","-c", buffer, NULL), an attacker who controls the socket input can inject arbitrary shell commands.
Can you assign a CWE for this vulnerability?
This is a textbook OS‐command‐injection flaw. The appropriate CWE identifier is:
• CWE-78: Improper Neutralization of Special Elements used in an OS Command (‘OS Command Injection’)
