What are some taint sources in this binary?

Dr.Binary
open_ghidra_server
search_functions_by_name
list_imports
decompile_function_by_address
search_functions_by_name
search_functions_by_name
list_methods
decompile_function_by_address
decompile_function_by_address
decompile_function_by_address
decompile_function_by_address
decompile_function_by_address
search_functions_by_name
list_exports

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()?

Dr.Binary
decompile_function_by_address
list_strings
get_xrefs_to
decompile_function_by_address
decompile_function_by_address
decompile_function_by_address

Here’s the step-by-step flow of taint from the network all the way into the execl() call:

  1. socket()/bind()/listen()/accept()
    – sets up a listening socket and hands you a client fd (local_ac).

  2. recv(local_ac, local_a0 + local_98, 99-local_98, 0)
    – local_a0 points at local_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 ”

  3. 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’
    }

  4. close the sockets

  5. FUN_00101914(&local_a0)
    – you pass the address of your char *local_a0 into this helper

  6. Inside FUN_00101914:
    execl(
    "/bin/sh", ← hard-coded shell path
    "/bin/sh", ← argv[0]
    &DAT_00103046, ← typically the literal "-c"
    *param_1, ← the contents of local_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?

Dr.Binary

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’)