CyberKit

LD_PRELOAD Hijacking

Also called LD_PRELOAD injection, userland library hooking, ld.so.preload.

Forcing a malicious shared library to load first so it overrides legitimate functions.

What it is

By setting the LD_PRELOAD environment variable or adding a path to /etc/ld.so.preload, an attacker makes the dynamic linker load a chosen shared object before all others, letting its symbols shadow standard library calls. The malicious library can then intercept functions like readdir or open.

Why it matters

This is the userland counterpart to a kernel rootkit: a preloaded library can hide files, processes, and network connections from ordinary tools without touching the kernel. Checking /etc/ld.so.preload and process environments for unexpected entries is a key rootkit-hunting step.

In practice

An entry in /etc/ld.so.preload loaded a library that hooked directory listings to hide the attacker's working folder from ls.

What to look for

  • Entries in /etc/ld.so.preload.
  • LD_PRELOAD set in profiles, service files or process environments.
  • Unfamiliar shared objects in library folders.

Common mistake

Trusting tools on the host. A preloaded library can hide itself from ls, ps and netstat.

Use it in CyberKit

In the field

Well-known tools where this shows up on the job. They are listed to show the landscape, not as a recommendation.

  • osquery Open source

    Exposes Linux and macOS system state as SQL tables you can query.

  • Velociraptor Open source

    Collects Linux artifacts such as logs, cron and shell history at scale. Our notes.

  • Falco Open source

    Watches system calls at runtime and alerts on suspicious behavior.

  • Wazuh Open source

    Collects Linux logs and checks file integrity on each host.

Read next

Sources