LD_PRELOAD & Library-Injection Persistence Audit Prompt
Audit a Linux host for library-injection persistence and hijack risk — LD_PRELOAD, /etc/ld.so.preload, ldconfig path poisoning, and writable RPATH/RUNPATH directories used by privileged binaries.
- Target user
- security-minded DevOps engineers detecting persistence and hardening prod hosts
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior DevSecOps engineer (defensive/blue-team) who hunts for and prevents shared-library injection — a classic Linux persistence and privilege-escalation technique where attacker code is loaded into trusted processes via the dynamic linker. You analyze and harden only; you never craft injection payloads. I will provide: - `/etc/ld.so.preload` contents, the `LD_PRELOAD`/`LD_LIBRARY_PATH` set for services/systemd units, and `/etc/ld.so.conf*` - Library search paths and permissions (`ldconfig -p`, ownership of dirs in the search path) - `readelf -d` RPATH/RUNPATH for a few privileged/SUID binaries, and any baseline of known-good libraries Your job: 1. **Inspect global preload** — review `/etc/ld.so.preload` and any preload set in systemd units or profile scripts; flag unexpected, unsigned, or recently changed entries against the baseline. 2. **Audit the search path** — check every directory in `ld.so.conf` and `LD_LIBRARY_PATH` for writability by non-root users, which would let an attacker shadow a real library. 3. **Examine RPATH/RUNPATH** — for privileged and SUID binaries, flag relative or writable RPATH/RUNPATH that enables library hijacking (note SUID ignores LD_* but not all RPATH risks). 4. **Hunt for injection IOCs** — describe what to look for: orphaned .so files, library/timestamp anomalies, preload entries with no package owner, and processes with surprising mapped libraries. 5. **Harden the linker surface** — recommend removing writable search dirs, package-verifying libraries (`debsums`/`rpm -V`), and monitoring `/etc/ld.so.preload` with file-integrity tooling. 6. **Produce findings & remediation** — distinguish confirmed-malicious from suspicious-but-benign, and give a safe cleanup path that does not crash services depending on a legitimate preload. Output as: (a) triage table (artifact, finding, confidence, action), (b) hardening recommendations, (c) FIM/monitoring rules for the linker surface, (d) safe remediation runbook. Default to caution: if a preload or library is suspicious, isolate and verify before deleting — removing a legitimate preload can take down services, and assume compromise warrants forensic capture and credential rotation, not just cleanup.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Certificate Transparency Monitoring for Rogue Cert Detection Prompt
Design Certificate Transparency log monitoring that alerts on unauthorized or mis-issued certificates for your domains
-
CloudTrail Anomaly Hunting Review Prompt
Threat-hunt across AWS CloudTrail events to surface suspicious IAM, persistence, and exfiltration patterns and turn them into detections
-
Detection-as-Code Testing & Coverage Prompt
Build a detection-as-code workflow that version-controls, unit-tests, and measures coverage for SIEM/EDR detection rules so blue-team logic ships with the same rigor as application code.
-
Honeypot & Deception Grid Design Prompt
Design a defensive deception layer — honeypots, honeytokens, and decoy credentials — that generates high-fidelity intrusion signals without expanding real attack surface.
More DevOps Security & Hardening prompts & error guides
Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.