Ldd(1) and Untrusted Binaries (2023)
jmmv.dev
jmmv.dev
ldd invokes the Windows loader on the file specified, then uses the Windows debugging interface to report DLLs loaded, and (for executables) to attempt to stop execution before the entrypoint. Thus, you should never use ldd on an untrusted file.
https://cygwin.com/cygwin-ug-net/ldd.htmlI just tried this and I get different addresses every time I ran `ldd /bin/true` on Linux, but I always get back the same addresses on Windows.
ELF like libraries are supported, but not the way most things are expected to work, with XCOFF and export description files.
Symbian was another OS with similar model, but it wasn't a UNIX anyway, and PIPS was a compatible layer on top.
$ strace ./true
execve("./true", ["./true"], 0x7ffc9993be20 /* 40 vars */) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV +++
(hexedited copy of /bin/true; something different might happen with a specially crafted file which has no other data in it besides the name of the interpreter?)strncpy had been touted the "safe strcpy alternative" for years.
The reason it doesn't find all with a simple elf-parse is that included libs might depend on other libs. I'd say if your linker can figure out before executing anything after the entry-point what to resolve, it has read it from ELF files it has seen by parsing the initial executable.
I was really surprised honestly to see LDD executes stuff, but I suppose it's a very old thing, from before 'untrusted' executables were really a (big) thing.
objdump -x /path/to/binary | grep NEEDED