Security Audit
Priority: P0 (CRITICAL)
📋 Security Probing Protocol
1. Hardcoded Secrets (Critical)
Scan for plain-text keys, passwords, and tokens in code.
grep -riE "(password|apiKey|api_key|secret|private_key|token)\s*=\s*['\"][^'\"]{6,}" \
. --exclude-dir={node_modules,dist,build,.git} -l
2. Data Leakage in Logs (PII/Secrets)
Identify sensitive info printed to logs or stdout.
- Node/TS:
grep -rE "console\.(log|error|warn)" . --include="*.ts" --include="*.js" | grep -iE "password|token|secret|private"
- Go:
grep -rE "log\.(Print|Printf|Println|Fatal)" . --include="*.go" | grep -iE "password|token|secret"
- Dart/Flutter:
grep -rE "print\(|debugPrint\(" . --include="*.dart" | grep -iE "password|token|secret"
- Java/Spring:
grep -rE "log(ger)?\.(info|debug|warn|error)" . --include="*.java" | grep -iE "password|token|secret"
3. Injection Surface (SQL / Command)
Detect raw string concatenation in queries or system commands.
grep -rE "\+.*SELECT|\+.*INSERT|\+.*UPDATE|\+.*DELETE|query\(.*\+|fmt\.Sprintf.*SELECT" \
. --include="*.ts" --include="*.js" --include="*.go" --include="*.java" --include="*.py"
4. Auth Coverage vs Exposure
Compare total routes vs protected endpoints.
- NestJS:
total=$(grep -r "@(Get|Post|Put|Delete|Patch)" . | wc -l); guarded=$(grep -r "@(UseGuards|Auth)" . | wc -l)
- Spring:
total=$(grep -r "@(GetMapping|PostMapping|PutMapping)" . | wc -l); guarded=$(grep -r "@(PreAuthorize|Secured)" . | wc -l)
- Go:
total=$(grep -rE "(GET|POST|PUT|DELETE)" . | wc -l); guarded=$(grep -rE "(middleware|auth|jwt|guard)" . | wc -l)
5. Dependency Audit (CVE Scan)
- Node:
npm audit --audit-level=high
- Dart/Flutter:
dart pub outdated --json
- Go:
go list -m -u all | grep "\["
- Java:
mvn dependency:list or ./gradlew dependencies
- Python:
pip-audit
- Rust:
cargo audit
6. Infrastructure Hardening
grep -rE "^FROM .+:latest|^USER root|curl.*sh.*|ADD http" . --include="Dockerfile"
⚖️ Scoring Impact
| Finding |
Threshold |
Severity |
Deduction |
| Hardcoded Secrets |
Any match |
🔴 P0 |
-25 |
| Plain-text PII in Logs |
Any match |
🔴 P0 |
-20 |
| Unguarded Routes > 20% |
> 0.2 |
🔴 P0 |
-15 |
| Raw SQL Concatenation |
Any match |
🟠 P1 |
-10 |
| Response Leakage (Stack) |
> 0 |
🟠 P1 |
-10 |
[!CAUTION]
A 🔴 P0 finding immediately caps the Security score at 40/100.
📚 Reference Links
- Vulnerability Remediation Protocols
1---
2name: security-audit-4
3description: Adversarial security probing and vulnerability assessments across Node, Go, Dart, Java, Python, and Rust.
4metadata:
5 source: https://skillmd.com/skills/hoangnguyen0403/security-audit-4
6 labels: [security, audit, pentest, vulnerability, cve, secrets, injection]
7 triggers:
8 files: ['package.json', 'go.mod', 'pubspec.yaml', 'pom.xml', 'Dockerfile']
9 keywords:
10 [
11 security audit,
12 vulnerability scan,
13 secrets detection,
14 injection probe,
15 pentest,
16 ]
17---
18
19# Security Audit
20
21## **Priority: P0 (CRITICAL)**
22
23## 📋 Security Probing Protocol
24
25### 1. Hardcoded Secrets (Critical)
26
27Scan for plain-text keys, passwords, and tokens in code.
28
29```bash
30grep -riE "(password|apiKey|api_key|secret|private_key|token)\s*=\s*['\"][^'\"]{6,}" \
31 . --exclude-dir={node_modules,dist,build,.git} -l
32```
33
34### 2. Data Leakage in Logs (PII/Secrets)
35
36Identify sensitive info printed to logs or stdout.
37
38- **Node/TS**: `grep -rE "console\.(log|error|warn)" . --include="*.ts" --include="*.js" | grep -iE "password|token|secret|private"`
39- **Go**: `grep -rE "log\.(Print|Printf|Println|Fatal)" . --include="*.go" | grep -iE "password|token|secret"`
40- **Dart/Flutter**: `grep -rE "print\(|debugPrint\(" . --include="*.dart" | grep -iE "password|token|secret"`
41- **Java/Spring**: `grep -rE "log(ger)?\.(info|debug|warn|error)" . --include="*.java" | grep -iE "password|token|secret"`
42
43### 3. Injection Surface (SQL / Command)
44
45Detect raw string concatenation in queries or system commands.
46
47```bash
48grep -rE "\+.*SELECT|\+.*INSERT|\+.*UPDATE|\+.*DELETE|query\(.*\+|fmt\.Sprintf.*SELECT" \
49 . --include="*.ts" --include="*.js" --include="*.go" --include="*.java" --include="*.py"
50```
51
52### 4. Auth Coverage vs Exposure
53
54Compare total routes vs protected endpoints.
55
56- **NestJS**: `total=$(grep -r "@(Get|Post|Put|Delete|Patch)" . | wc -l); guarded=$(grep -r "@(UseGuards|Auth)" . | wc -l)`
57- **Spring**: `total=$(grep -r "@(GetMapping|PostMapping|PutMapping)" . | wc -l); guarded=$(grep -r "@(PreAuthorize|Secured)" . | wc -l)`
58- **Go**: `total=$(grep -rE "(GET|POST|PUT|DELETE)" . | wc -l); guarded=$(grep -rE "(middleware|auth|jwt|guard)" . | wc -l)`
59
60### 5. Dependency Audit (CVE Scan)
61
62- **Node**: `npm audit --audit-level=high`
63- **Dart/Flutter**: `dart pub outdated --json`
64- **Go**: `go list -m -u all | grep "\["`
65- **Java**: `mvn dependency:list` or `./gradlew dependencies`
66- **Python**: `pip-audit`
67- **Rust**: `cargo audit`
68
69### 6. Infrastructure Hardening
70
71```bash
72grep -rE "^FROM .+:latest|^USER root|curl.*sh.*|ADD http" . --include="Dockerfile"
73```
74
75## ⚖️ Scoring Impact
76
77| Finding | Threshold | Severity | Deduction |
78| ---------------------------- | --------- | -------- | --------- |
79| **Hardcoded Secrets** | Any match | 🔴 P0 | -25 |
80| **Plain-text PII in Logs** | Any match | 🔴 P0 | -20 |
81| **Unguarded Routes > 20%** | > 0.2 | 🔴 P0 | -15 |
82| **Raw SQL Concatenation** | Any match | 🟠 P1 | -10 |
83| **Response Leakage (Stack)** | > 0 | 🟠 P1 | -10 |
84
85> [!CAUTION]
86> A **🔴 P0 finding** immediately caps the Security score at **40/100**.
87
88## 📚 Reference Links
89
90- [Vulnerability Remediation Protocols](references/REMEDIATION.md)
91