Skip to content

Commit b7ffa5d

Browse files
committed
Add new detection rules, fix fork tracking, harden dashboard security
New detection rules: - Blocked paths: .netrc, .npmrc, .pypirc, .docker/config.json (PATH-LIN-014–018, PATH-MAC-021–025) - Blocked executable: mkfs (BIN-028) - Deny rules: dd disk destruction (LIN-050), argv-based sensitive file alerting for .env, .pem, .key, .p12, .pfx, credentials.json, secrets.yaml/json, tokens.json (LIN-051–057) eBPF fix: - Fix fork TGID mismatch in sched_process_fork tracepoint — worker thread forks now correctly inherit tracking via bpf_get_current_pid_tgid() fallback Dashboard security hardening: - Fix timing attack: use hmac.compare_digest() for token comparison - Add X-Content-Type-Options and X-Frame-Options security headers - Sanitize error responses to prevent filesystem path disclosure - Add missing subprocess timeout on macOS policy applicator
1 parent b06dc20 commit b7ffa5d

File tree

10 files changed

+890
-21
lines changed

10 files changed

+890
-21
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ build/
1111
.DS_Store
1212
testing_setup/
1313
docs/
14+
comparison-report.md

CLAUDE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,43 @@ pip install -r requirements-dev.txt
2121
./main.py all # sync → compile → test (skips publish)
2222
```
2323

24+
## Applying Changes to the Testing VM
25+
26+
After every editing session, sync the deploy files to the OrbStack Ubuntu VM and restart services:
27+
28+
```bash
29+
cd /Users/leo/clawedr && orb -m ubuntu -u root bash -c '
30+
set -e
31+
CLAWEDR_DIR="/usr/local/share/clawedr"
32+
SRC="/Users/leo/clawedr/deploy"
33+
34+
echo "[*] Syncing deploy files to $CLAWEDR_DIR..."
35+
cp "$SRC/compiled_policy.json" "$CLAWEDR_DIR/"
36+
cp "$SRC/linux/bpf_hooks.c" "$CLAWEDR_DIR/"
37+
cp "$SRC/linux/monitor.py" "$CLAWEDR_DIR/"
38+
cp "$SRC/shared/user_rules.py" "$CLAWEDR_DIR/shared/"
39+
cp "$SRC/shared/alert_dispatcher.py" "$CLAWEDR_DIR/shared/"
40+
cp "$SRC/shared/rule_updater.py" "$CLAWEDR_DIR/shared/"
41+
cp "$SRC/shared/policy_verify.py" "$CLAWEDR_DIR/shared/"
42+
cp "$SRC/dashboard/app.py" "$CLAWEDR_DIR/dashboard/"
43+
cp "$SRC/dashboard/templates/index.html" "$CLAWEDR_DIR/dashboard/templates/"
44+
45+
echo "[*] Restarting clawedr-monitor..."
46+
systemctl restart clawedr-monitor 2>/dev/null || true
47+
48+
echo "[*] Restarting clawedr-dashboard..."
49+
systemctl restart clawedr-dashboard 2>/dev/null || true
50+
51+
sleep 3
52+
echo "[*] Status:"
53+
systemctl is-active clawedr-monitor 2>/dev/null && echo " clawedr-monitor: active" || echo " clawedr-monitor: failed"
54+
systemctl is-active clawedr-dashboard 2>/dev/null && echo " clawedr-dashboard: active" || echo " clawedr-dashboard: failed"
55+
echo "[*] Done."
56+
'
57+
```
58+
59+
Both `clawedr-monitor` and `clawedr-dashboard` should report `active`. If either reports `failed`, check `journalctl -u clawedr-monitor -n 50` or `journalctl -u clawedr-dashboard -n 50` inside the VM.
60+
2461
## Testing
2562

2663
```bash

builder/master_rules.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,18 @@ rule_metadata:
6565
PATH-LIN-011: { description: "User kubeconfig; enables Kubernetes cluster takeover", severity: critical, category: security }
6666
PATH-LIN-012: { description: "Docker socket; enables container escape and host takeover", severity: critical, category: security }
6767
PATH-LIN-013: { description: "ClawEDR config; contains exemptions and custom rules — prevents policy tampering", severity: critical, category: security }
68+
PATH-LIN-014: { description: "Netrc credentials; plaintext HTTP/FTP login credentials", severity: high, category: security }
69+
PATH-LIN-015: { description: "npm config; may contain registry auth tokens", severity: high, category: security }
70+
PATH-LIN-016: { description: "PyPI config; may contain upload credentials", severity: high, category: security }
6871
PATH-LIN-017: { description: "ClawEDR install dir; compiled policy, monitor, rules — prevents policy tampering", severity: critical, category: security }
72+
PATH-LIN-018: { description: "Docker config; may contain registry auth credentials", severity: high, category: security }
6973

7074
PATH-MAC-020: { description: "ClawEDR config; contains exemptions and custom rules — prevents policy tampering", severity: critical, category: security }
75+
PATH-MAC-021: { description: "Netrc credentials; plaintext HTTP/FTP login credentials", severity: high, category: security }
76+
PATH-MAC-022: { description: "npm config; may contain registry auth tokens", severity: high, category: security }
7177
PATH-MAC-023: { description: "ClawEDR install dir; compiled policy and rules — prevents policy tampering", severity: critical, category: security }
78+
PATH-MAC-024: { description: "PyPI config; may contain upload credentials", severity: high, category: security }
79+
PATH-MAC-025: { description: "Docker config; may contain registry auth credentials", severity: high, category: security }
7280

7381
# Blocked domains
7482
DOM-001: { description: "Monero mining pool; cryptojacking and resource theft", severity: high, category: security }
@@ -127,6 +135,7 @@ rule_metadata:
127135
BIN-025: { description: "Strace; syscall tracing, can capture secrets and inject", severity: high, category: security }
128136
BIN-026: { description: "Ltrace; library call tracing", severity: high, category: security }
129137
BIN-027: { description: "Ptrace; process tracing and injection", severity: high, category: security }
138+
BIN-028: { description: "mkfs; filesystem format — can destroy disk partitions", severity: critical, category: security }
130139

131140
# macOS custom deny rules
132141
MAC-001: { description: "Reverse-shell port 4444; common C2 callback", severity: critical, category: security }
@@ -199,6 +208,17 @@ rule_metadata:
199208
LIN-047: { description: "Kubelet API; Kubernetes recon / escape", severity: critical, category: security }
200209
LIN-048: { description: "Find SUID binaries; privilege escalation recon", severity: high, category: security }
201210
LIN-049: { description: "Getcap recursive; capability recon for priv esc", severity: high, category: security }
211+
LIN-050: { description: "dd raw disk write; can overwrite partitions and destroy data", severity: critical, category: security }
212+
LIN-051: { description: "Dotenv file access; .env files typically contain secrets and API keys", severity: high, category: security }
213+
LIN-051b: { description: "Dotenv file access (absolute path); .env files typically contain secrets and API keys", severity: high, category: security }
214+
LIN-052: { description: "PEM certificate/key access; .pem files contain private keys or certificates", severity: high, category: security }
215+
LIN-053: { description: "Private key file access; .key files contain cryptographic private keys", severity: high, category: security }
216+
LIN-054: { description: "PKCS12 keystore access; .p12/.pfx files contain certificates and private keys", severity: high, category: security }
217+
LIN-054b: { description: "PFX keystore access; .pfx files contain certificates and private keys", severity: high, category: security }
218+
LIN-055: { description: "Credentials file access; credentials.json commonly contains service account keys", severity: high, category: security }
219+
LIN-056: { description: "Secrets config access; secrets.yaml/secrets.json contain application secrets", severity: high, category: security }
220+
LIN-056b: { description: "Secrets JSON access; secrets.json contains application secrets", severity: high, category: security }
221+
LIN-057: { description: "Token file access; tokens.json commonly contains OAuth/API tokens", severity: high, category: security }
202222

203223
# ── Heuristic rules ─────────────────────────────────────────────────────────
204224
# Behavioral detection rules for AI agent skill abuse.
@@ -316,7 +336,11 @@ blocked_paths:
316336
# System
317337
PATH-MAC-019: "/Library/Preferences/SystemConfiguration"
318338
PATH-MAC-020: "/etc/clawedr"
339+
PATH-MAC-021: "~/.netrc"
340+
PATH-MAC-022: "~/.npmrc"
319341
PATH-MAC-023: "/usr/local/share/clawedr"
342+
PATH-MAC-024: "~/.pypirc"
343+
PATH-MAC-025: "~/.docker/config.json"
320344
linux:
321345
PATH-LIN-001: "/root/.ssh"
322346
PATH-LIN-002: "/etc/shadow"
@@ -333,7 +357,11 @@ blocked_paths:
333357
PATH-LIN-011: "/home/*/.kube/config"
334358
PATH-LIN-012: "/var/run/docker.sock"
335359
PATH-LIN-013: "/etc/clawedr"
360+
PATH-LIN-014: "/home/*/.netrc"
361+
PATH-LIN-015: "/home/*/.npmrc"
362+
PATH-LIN-016: "/home/*/.pypirc"
336363
PATH-LIN-017: "/usr/local/share/clawedr"
364+
PATH-LIN-018: "/home/*/.docker/config.json"
337365

338366
# ── Blocked domains ───────────────────────────────────────────────────────
339367
# Known mining pools and C2 infrastructure. The threat feed adds more.
@@ -409,6 +437,8 @@ blocked_executables:
409437
BIN-025: "strace"
410438
BIN-026: "ltrace"
411439
BIN-027: "ptrace"
440+
# Disk destruction
441+
BIN-028: "mkfs"
412442

413443
malicious_hashes: {}
414444

@@ -680,6 +710,58 @@ custom_deny_rules:
680710
match: "getcap -r /"
681711
action: "SIGKILL"
682712

713+
# ── Disk destruction ──
714+
LIN-050:
715+
rule: "disk_dd_write"
716+
match: "dd if=* of=/dev/*"
717+
executable: "dd"
718+
action: "SIGKILL"
719+
720+
# ── Sensitive file access (alert-only) ──
721+
# These catch argv-level access to files that cannot be blocked via
722+
# eBPF openat (suffix/glob patterns are infeasible with hash lookup).
723+
# Two rules for .env: relative (space-anchored) and absolute (slash-anchored).
724+
LIN-051:
725+
rule: "sensitive_dotenv_relative"
726+
match: "* .env*"
727+
action: "ALERT"
728+
LIN-051b:
729+
rule: "sensitive_dotenv_absolute"
730+
match: "*/.env*"
731+
action: "ALERT"
732+
LIN-052:
733+
rule: "sensitive_pem_file"
734+
match: "*.pem"
735+
action: "ALERT"
736+
LIN-053:
737+
rule: "sensitive_key_file"
738+
match: "*.key"
739+
action: "ALERT"
740+
LIN-054:
741+
rule: "sensitive_p12_pfx_file"
742+
match: "*.p12"
743+
action: "ALERT"
744+
LIN-054b:
745+
rule: "sensitive_pfx_file"
746+
match: "*.pfx"
747+
action: "ALERT"
748+
LIN-055:
749+
rule: "sensitive_credentials_json"
750+
match: "*credentials.json*"
751+
action: "ALERT"
752+
LIN-056:
753+
rule: "sensitive_secrets_config"
754+
match: "*secrets.yaml*"
755+
action: "ALERT"
756+
LIN-056b:
757+
rule: "sensitive_secrets_json"
758+
match: "*secrets.json*"
759+
action: "ALERT"
760+
LIN-057:
761+
rule: "sensitive_tokens_json"
762+
match: "*tokens.json*"
763+
action: "ALERT"
764+
683765
# ── Heuristics ────────────────────────────────────────────────────────────
684766
# Behavioral detection rules for AI agent skill abuse.
685767
# Enforcement hierarchy per rule: disabled → alert → enforce

0 commit comments

Comments
 (0)