Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

Create private incident triage directories atomically

Rudy Celekliae70562a8320
diff --git a/security/security-incident-responder.md b/security/security-incident-responder.md
index 7198b4fb..8b573c2f 100644
--- a/security/security-incident-responder.md
+++ b/security/security-incident-responder.md
@@ -206,14 +206,27 @@ Write-Host "[!] NEXT: Copy $outDir to analysis workstation — do NOT analyze on
```
### Linux Forensic Triage Script
+
+A suspected host may already be hostile: use trusted collection tools and an
+approved evidence destination. This local triage is not a substitute for a
+forensic image. Restrict the collection directory to the collector, preserve it
+for handoff, and never write through a pre-existing path supplied by another user.
+
```bash
#!/bin/bash
# Linux Incident Response Triage Collection
# Run as root on suspected compromised system
TIMESTAMP=$(date -u +"%Y%m%d-%H%M%S")
-OUTDIR="/tmp/ir-triage-${HOSTNAME}-${TIMESTAMP}"
-mkdir -p "$OUTDIR"
+# Evidence can contain credentials. Create a private directory atomically;
+# never reuse a predictable path in /tmp or trust an inherited TMPDIR.
+umask 077
+OUTDIR=$(mktemp -d /tmp/ir-triage.XXXXXXXXXX) || {
+ echo "[!] Unable to create private evidence directory" >&2
+ exit 1
+}
+readonly OUTDIR
+# Preserve the directory for handoff; do not delete evidence in an EXIT trap.
echo "[*] Starting Linux IR triage at ${TIMESTAMP} UTC"