Node.js / JavaScript / TypeScript Security Audit
Overview
This skill answers a very practical question:
"Is this Node.js app safe to run on AWS — and if not, what should I fix?"
It performs a static security audit of Node.js / JavaScript / TypeScript codebases and produces an actionable Markdown report with concrete findings and real, code-level risks that matter in production, especially for Node applications running on AWS.
I built it to be safe, explicit, and predictable in agent-driven workflows, so that you can understand security context before production problems appear.
The problem it solves
Node.js apps often look fine in CI:
- Tests pass
- Builds succeed
- Infrastructure deploys
…and yet security issues quietly slip through.
Common reasons:
- AWS SDKs are easy to misuse
- Secrets leak through environment assumptions
- Risky patterns don't fail loudly
- Agents and scripts run "helpful" but vague shell commands
This skill makes security checks:
- Explicit (no hidden execution)
- Repeatable (same input, same output)
- Reviewable (clear Markdown, not logs)
What it checks
- OWASP Top 10 (2021) mapped to real Node.js vulnerability patterns
- Common AWS security anti-patterns in application code
- Risky handling of secrets, environment variables, and credentials
- Code paths that may enable data exposure or privilege escalation
What you get
An actually readable Markdown report
Clear issue descriptions (no scanner gibberish)
Actionable advice you can follow or task your agent with
Output suitable for:
- Pull requests
- CI artifacts
- Agent context
- Security reviews
Where it fits
- Local development
- CI pipelines
- AWS workloads
- AI agents using Skills.sh as a constrained execution layer
Script security policy
All scripts in scripts/ follow these constraints:
- No network calls — scripts never use curl, wget, fetch, or any network I/O
- No data exfiltration — output is written only to local files in the working directory
- Transparent execution — all actions are printed to stdout as they run
- Minimal privileges — scripts require no elevated permissions; they only read project files and write audit output
- Hardened against scanned-project attacks — NODE_OPTIONS is unset, output paths are checked for symlinks, scanned code output is sanitized to prevent prompt injection
CRITICAL: Execute each workflow step as exactly one bash tool call. Steps must run in sequence — do not launch multiple steps in parallel. Within each step, all shell commands are chained into a single bash invocation (using && / \).
Workflow
Step 1: Discover project structure
Run this single command block to discover the project structure:
echo "=== Package manifests ===" && \
find . -maxdepth 3 -name "package.json" -not -path "*/node_modules/*" 2>/dev/null; \
echo "" && echo "=== Source files ===" && \
find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.mjs" -o -name "*.cjs" \) -not -path "*/node_modules/*" -not -path "*/dist/*" -not -path "*/.next/*" -not -path "*/build/*" 2>/dev/null | head -100; \
echo "" && echo "=== Config files ===" && \
find . -maxdepth 1 \( -name ".env*" -o -name "tsconfig.json" -o -name ".eslintrc*" -o -name ".npmrc" \) 2>/dev/null; \
echo "" && echo "=== AWS / Container / IaC markers ===" && \
find . -maxdepth 3 \( -name "serverless.yml" -o -name "serverless.yaml" -o -name "serverless.ts" -o -name "template.yaml" -o -name "template.yml" -o -name "sam.yaml" -o -name "cdk.json" -o -name "Dockerfile" -o -name "docker-compose.yml" -o -name "docker-compose.yaml" \) -not -path "*/node_modules/*" 2>/dev/null; \
find . -maxdepth 3 -name "*.tf" -not -path "*/.terraform/*" -not -path "*/node_modules/*" 2>/dev/null | head -10; \
echo "=== Discovery complete ==="
Large codebases: If the source file listing is truncated (>100 files), focus
the scan on entry points (src/, app/, routes/, handlers/, api/) and
configuration files first. Expand to remaining directories if time allows.
Adaptive priority: If AWS/container/IaC markers are detected above (e.g., serverless.yml,
template.yaml, *.tf, Dockerfile, cdk.json), prioritize the infrastructure and deployment
checks (items 13-17) and flag them as infrastructure-critical in the report.
Step 2: Check Node.js runtime version and vulnerable built-in API usage
Run the runtime version scanner:
bash <skill-path>/scripts/node-version-check.sh
This checks:
- Node.js runtime version against known EOL/CVE data
- Usage of vulnerable built-in APIs (http parser, crypto, child_process, vm, etc.)
- OpenSSL version bundled with the runtime
- Dangerous built-in patterns specific to the detected Node.js version
Read references/version-vulnerabilities.md for the full mapping of Node.js
versions to known CVEs and vulnerable built-in APIs.
Step 3: Run dependency audit
Execute the dependency audit script:
bash <skill-path>/scripts/dependency-audit.sh
This produces dependency-audit-results.txt with known CVEs and outdated packages.
If a step fails: If node or npm is not available, note it as a finding
(the target project may not have dependencies installed). Continue with the
remaining steps — partial results are still valuable. Do not abort the audit.
Step 4: Static code analysis
Read references/vulnerability-catalog.md for the full list of patterns, grep
signatures, and code examples. For each vulnerability category, scan the codebase
using the grep patterns provided.
Scan order (by exploit impact):
Critical path — scan these first:
- Runtime version — use results from Step 2 (EOL version = automatic Critical)
- Injection — SQL/NoSQL/command injection,
eval(), Function(), template literals in queries
- Cryptographic failures — hardcoded secrets, weak algorithms, missing HTTPS enforcement
- Broken access control — missing auth middleware, IDOR patterns, CORS misconfiguration
- Vulnerable built-in APIs — use results from Step 2 (http, crypto, vm, child_process)
- Auth failures — weak JWT config, session mismanagement, no MFA support
- Vulnerable dependencies — use results from Step 3
- SSRF — unvalidated URL fetching, DNS rebinding, internal network access
Secondary — scan after critical path:
- Data integrity — prototype pollution, unsafe deserialization, missing CSP
- Security misconfiguration — debug mode in prod, missing helmet, verbose errors
- Insecure design — mass assignment, missing rate limiting, no input schemas
- Logging failures — no audit logging, sensitive data in logs, missing monitoring
Infrastructure checks (if detected):
- AWS Lambda — event source injection, env var secrets, IAM over-permission, function URL auth bypass, /tmp abuse, credential caching, layer poisoning
- Docker/ECS/Fargate — running as root, --inspect in production, secrets in Dockerfile, missing .dockerignore, SIGTERM handling, ALB/WAF, image scanning
- Terraform IaC — IAM wildcards, function URL auth, plaintext secrets, privileged containers, public IP, debug ports, state file encryption, EOL runtimes (Checkov/tfsec cross-reference)
- CloudFormation/SAM IaC — wildcard IAM, hardcoded secrets, missing VPC/DLQ/concurrency, privileged containers, ECS Exec, public IP, ALB without WAF (cfn-nag/AWS Config cross-reference)
- Serverless Framework — wildcard IAM, per-function roles, missing authorizers, cors: true, hardcoded env secrets, function URL auth, serverless-offline/dotenv risks, deployment bucket encryption
Framework checks (if detected):
- Express/Koa — helmet, CSRF, CORS, body limits, sessions, webpack production config risks (source maps, env leaks, eval devtools)
- NestJS — guards, validation pipes, DTO bypass, TypeORM/Prisma injection, Swagger exposure, WebSocket security, GraphQL depth limiting, exception filter leaks, serialization risks
- Fastify — schema validation bypass, plugin encapsulation, reply.hijack(), TypeBox schema injection, content type parser abuse, @fastify/static traversal
- Bun runtime — Bun.serve() security headers, Bun shell injection, bun:sqlite injection, Bun.file() path traversal, non-cryptographic Bun.hash usage
- AppSync/Amplify — authorization mode misconfiguration, resolver injection, GraphQL introspection, Cognito misconfiguration, API key exposure, AppSync Events security
Quick-reference: critical detection patterns
Use these patterns as a minimum scan baseline. See references/vulnerability-catalog.md for the full catalog.
| Category |
Pattern |
| Hardcoded secrets |
(password|secret|api_key|apiKey|token|JWT_SECRET)\s*[:=]\s*['"][^'"]{4,} |
| eval / Function |
\beval\s*\(|new\s+Function\s*\( |
| Command injection |
exec\(|execSync\(|spawn\( with user input |
| SQL injection |
(query|execute)\s*\(\s*['`].*\+\s*req\. |
| NoSQL injection |
\.find\(\s*\{.*req\.(body|query|params) |
| Weak crypto |
createHash\(\s*['"]md5['"]|createHash\(\s*['"]sha1['"] |
| SSRF |
(axios|fetch|http\.get)\(\s*(req\.|url|href) |
| Prototype pollution |
__proto__|constructor\[|\.prototype\s*= |
Step 5: Generate the report
Read references/report-template.md for the exact output format. Fill in {{agent_tool}} with the
tool you are running in (e.g., "Claude Code", "Cursor", "Cline") and {{model_id}} with your
model identifier (e.g., "claude-sonnet-4-5-20250929"). The report must include:
- Security Score (0-100) calculated using the scoring methodology: start at 100, subtract 15/Critical, 10/High, 5/Medium, 2/Low, +5 bonus if no Critical/High, minimum 0. Display with letter grade (A+ through F) and visual progress bar.
- Findings Dashboard with total count, score, and top finding per severity level with file locations
- Node.js runtime version assessment (Critical if EOL, with specific unpatched CVEs)
- Vulnerable built-in API usage section with affected files
- Framework Security Assessment (Express/Koa/webpack checks if detected)
- Findings sorted by severity, each with: ID, title, severity, OWASP category,
filepath:line location, all affected files listed, vulnerable code snippet, explanation, and remediation code snippet
- Quick Wins section — top 3-5 easiest fixes with biggest score impact and projected score after fixes
- Best practices checklist
- Recommended tools section
- Summary footer repeating the score, top priority, and projected score after Quick Wins
Severity classification:
| Severity |
Criteria |
| Critical |
EOL Node.js runtime, RCE, SQL injection, hardcoded secrets in public repos, auth bypass |
| High |
XSS, CSRF without tokens, SSRF, prototype pollution, weak crypto, vulnerable built-in API usage |
| Medium |
Missing security headers, verbose error messages, no rate limiting, outdated deps with known CVEs |
| Low |
Missing strict mode, console.log with PII, no input length limits, informational findings |
Step 6: Save and present
Save the report as security-audit-report.md and then:
- Output the full markdown report directly in the conversation so the user can
read it without opening a file. Show the complete formatted report, not a summary.
- After the full report, remind the user the file was saved to
security-audit-report.md.
- Ask the user if they would like a PDF version of the report. If they say yes,
generate the PDF using one of these methods (in preference order):
npx md-to-pdf security-audit-report.md (no install needed)
pandoc security-audit-report.md -o security-audit-report.pdf (if pandoc is available)
- If neither works, inform the user and suggest installing one of the tools.
1---
2name: node-aws-security-audit
3description: "Perform comprehensive security audits on Node.js, JavaScript, and TypeScript codebases. Scans source code for OWASP Top 10 vulnerabilities, insecure patterns, dependency risks, and generates a prioritized Markdown audit report with severity levels (Critical, High, Medium, Low), code citations, and remediation guidance. Use when asked to audit, review, scan, or check security of a Node.js/JS/TS project, find vulnerabilities, check for OWASP compliance, or generate a security report. Also triggers on: security review, pentest, vulnerability scan, is my code secure, check for injection, check dependencies. Do NOT trigger for: general code reviews, bugfix assistance, feature development, refactoring, performance optimization, or non-security tasks."
4license: MIT
5metadata:
6 source: https://skillmd.com/skills/aibot88/node-aws-security-audit
7 author: grenguar
8 version: "3.0.0"
9 tags: security, owasp, nodejs, audit, vulnerability-scanner
10---
11
12# Node.js / JavaScript / TypeScript Security Audit
13
14## Overview
15
16This skill answers a very practical question:
17
18"Is this Node.js app safe to run on AWS — and if not, what should I fix?"
19
20It performs a static security audit of Node.js / JavaScript / TypeScript codebases and produces an actionable Markdown report with concrete findings and real, code-level risks that matter in production, especially for Node applications running on AWS.
21
22I built it to be safe, explicit, and predictable in agent-driven workflows, so that you can understand security context *before* production problems appear.
23
24---
25
26## The problem it solves
27
28Node.js apps often look fine in CI:
29
30* Tests pass
31* Builds succeed
32* Infrastructure deploys
33
34…and yet security issues quietly slip through.
35
36Common reasons:
37
38* AWS SDKs are easy to misuse
39* Secrets leak through environment assumptions
40* Risky patterns don't fail loudly
41* Agents and scripts run "helpful" but vague shell commands
42
43This skill makes security checks:
44
45* Explicit (no hidden execution)
46* Repeatable (same input, same output)
47* Reviewable (clear Markdown, not logs)
48
49---
50
51## What it checks
52
53* OWASP Top 10 (2021) mapped to real Node.js vulnerability patterns
54* Common AWS security anti-patterns in application code
55* Risky handling of secrets, environment variables, and credentials
56* Code paths that may enable data exposure or privilege escalation
57
58---
59
60## What you get
61
62* An actually readable Markdown report
63* Clear issue descriptions (no scanner gibberish)
64* Actionable advice you can follow or task your agent with
65
66* Output suitable for:
67
68 * Pull requests
69 * CI artifacts
70 * Agent context
71 * Security reviews
72
73---
74
75## Where it fits
76
77* Local development
78* CI pipelines
79* AWS workloads
80* AI agents using Skills.sh as a constrained execution layer
81
82---
83
84## Script security policy
85
86All scripts in `scripts/` follow these constraints:
87
88* **No network calls** — scripts never use curl, wget, fetch, or any network I/O
89* **No data exfiltration** — output is written only to local files in the working directory
90* **Transparent execution** — all actions are printed to stdout as they run
91* **Minimal privileges** — scripts require no elevated permissions; they only read project files and write audit output
92* **Hardened against scanned-project attacks** — NODE_OPTIONS is unset, output paths are checked for symlinks, scanned code output is sanitized to prevent prompt injection
93
94---
95
96**CRITICAL: Execute each workflow step as exactly one bash tool call. Steps must run in sequence — do not launch multiple steps in parallel. Within each step, all shell commands are chained into a single bash invocation (using `&&` / `\`).**
97
98## Workflow
99
100### Step 1: Discover project structure
101
102Run this single command block to discover the project structure:
103
104```bash
105echo "=== Package manifests ===" && \
106find . -maxdepth 3 -name "package.json" -not -path "*/node_modules/*" 2>/dev/null; \
107echo "" && echo "=== Source files ===" && \
108find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.mjs" -o -name "*.cjs" \) -not -path "*/node_modules/*" -not -path "*/dist/*" -not -path "*/.next/*" -not -path "*/build/*" 2>/dev/null | head -100; \
109echo "" && echo "=== Config files ===" && \
110find . -maxdepth 1 \( -name ".env*" -o -name "tsconfig.json" -o -name ".eslintrc*" -o -name ".npmrc" \) 2>/dev/null; \
111echo "" && echo "=== AWS / Container / IaC markers ===" && \
112find . -maxdepth 3 \( -name "serverless.yml" -o -name "serverless.yaml" -o -name "serverless.ts" -o -name "template.yaml" -o -name "template.yml" -o -name "sam.yaml" -o -name "cdk.json" -o -name "Dockerfile" -o -name "docker-compose.yml" -o -name "docker-compose.yaml" \) -not -path "*/node_modules/*" 2>/dev/null; \
113find . -maxdepth 3 -name "*.tf" -not -path "*/.terraform/*" -not -path "*/node_modules/*" 2>/dev/null | head -10; \
114echo "=== Discovery complete ==="
115```
116
117**Large codebases:** If the source file listing is truncated (>100 files), focus
118the scan on entry points (`src/`, `app/`, `routes/`, `handlers/`, `api/`) and
119configuration files first. Expand to remaining directories if time allows.
120
121**Adaptive priority:** If AWS/container/IaC markers are detected above (e.g., `serverless.yml`,
122`template.yaml`, `*.tf`, `Dockerfile`, `cdk.json`), prioritize the infrastructure and deployment
123checks (items 13-17) and flag them as infrastructure-critical in the report.
124
125### Step 2: Check Node.js runtime version and vulnerable built-in API usage
126
127Run the runtime version scanner:
128
129```bash
130bash <skill-path>/scripts/node-version-check.sh
131```
132
133This checks:
134
135* Node.js runtime version against known EOL/CVE data
136* Usage of vulnerable built-in APIs (http parser, crypto, child_process, vm, etc.)
137* OpenSSL version bundled with the runtime
138* Dangerous built-in patterns specific to the detected Node.js version
139
140Read `references/version-vulnerabilities.md` for the full mapping of Node.js
141versions to known CVEs and vulnerable built-in APIs.
142
143### Step 3: Run dependency audit
144
145Execute the dependency audit script:
146
147```bash
148bash <skill-path>/scripts/dependency-audit.sh
149```
150
151This produces `dependency-audit-results.txt` with known CVEs and outdated packages.
152
153**If a step fails:** If `node` or `npm` is not available, note it as a finding
154(the target project may not have dependencies installed). Continue with the
155remaining steps — partial results are still valuable. Do not abort the audit.
156
157### Step 4: Static code analysis
158
159Read `references/vulnerability-catalog.md` for the full list of patterns, grep
160signatures, and code examples. For each vulnerability category, scan the codebase
161using the grep patterns provided.
162
163**Scan order (by exploit impact):**
164
165**Critical path — scan these first:**
166
1671. **Runtime version** — use results from Step 2 (EOL version = automatic Critical)
1682. **Injection** — SQL/NoSQL/command injection, `eval()`, `Function()`, template literals in queries
1693. **Cryptographic failures** — hardcoded secrets, weak algorithms, missing HTTPS enforcement
1704. **Broken access control** — missing auth middleware, IDOR patterns, CORS misconfiguration
1715. **Vulnerable built-in APIs** — use results from Step 2 (http, crypto, vm, child_process)
1726. **Auth failures** — weak JWT config, session mismanagement, no MFA support
1737. **Vulnerable dependencies** — use results from Step 3
1748. **SSRF** — unvalidated URL fetching, DNS rebinding, internal network access
175
176**Secondary — scan after critical path:**
177
1789. **Data integrity** — prototype pollution, unsafe deserialization, missing CSP
17910. **Security misconfiguration** — debug mode in prod, missing helmet, verbose errors
18011. **Insecure design** — mass assignment, missing rate limiting, no input schemas
18112. **Logging failures** — no audit logging, sensitive data in logs, missing monitoring
182
183**Infrastructure checks (if detected):**
184
18513. **AWS Lambda** — event source injection, env var secrets, IAM over-permission, function URL auth bypass, /tmp abuse, credential caching, layer poisoning
18614. **Docker/ECS/Fargate** — running as root, --inspect in production, secrets in Dockerfile, missing .dockerignore, SIGTERM handling, ALB/WAF, image scanning
18715. **Terraform IaC** — IAM wildcards, function URL auth, plaintext secrets, privileged containers, public IP, debug ports, state file encryption, EOL runtimes (Checkov/tfsec cross-reference)
18816. **CloudFormation/SAM IaC** — wildcard IAM, hardcoded secrets, missing VPC/DLQ/concurrency, privileged containers, ECS Exec, public IP, ALB without WAF (cfn-nag/AWS Config cross-reference)
18917. **Serverless Framework** — wildcard IAM, per-function roles, missing authorizers, cors: true, hardcoded env secrets, function URL auth, serverless-offline/dotenv risks, deployment bucket encryption
190
191**Framework checks (if detected):**
192
19318. **Express/Koa** — helmet, CSRF, CORS, body limits, sessions, webpack production config risks (source maps, env leaks, eval devtools)
19419. **NestJS** — guards, validation pipes, DTO bypass, TypeORM/Prisma injection, Swagger exposure, WebSocket security, GraphQL depth limiting, exception filter leaks, serialization risks
19520. **Fastify** — schema validation bypass, plugin encapsulation, reply.hijack(), TypeBox schema injection, content type parser abuse, @fastify/static traversal
19621. **Bun runtime** — Bun.serve() security headers, Bun shell injection, bun:sqlite injection, Bun.file() path traversal, non-cryptographic Bun.hash usage
19722. **AppSync/Amplify** — authorization mode misconfiguration, resolver injection, GraphQL introspection, Cognito misconfiguration, API key exposure, AppSync Events security
198
199**Quick-reference: critical detection patterns**
200
201Use these patterns as a minimum scan baseline. See `references/vulnerability-catalog.md` for the full catalog.
202
203| Category | Pattern |
204|----------|---------|
205| Hardcoded secrets | `(password\|secret\|api_key\|apiKey\|token\|JWT_SECRET)\s*[:=]\s*['"][^'"]{4,}` |
206| eval / Function | `\beval\s*\(\|new\s+Function\s*\(` |
207| Command injection | `exec\(\|execSync\(\|spawn\(` with user input |
208| SQL injection | ``(query\|execute)\s*\(\s*['`].*\+\s*req\.`` |
209| NoSQL injection | `\.find\(\s*\{.*req\.(body\|query\|params)` |
210| Weak crypto | `createHash\(\s*['"]md5['"]\|createHash\(\s*['"]sha1['"]` |
211| SSRF | `(axios\|fetch\|http\.get)\(\s*(req\.\|url\|href)` |
212| Prototype pollution | `__proto__\|constructor\[\|\.prototype\s*=` |
213
214### Step 5: Generate the report
215
216Read `references/report-template.md` for the exact output format. Fill in `{{agent_tool}}` with the
217tool you are running in (e.g., "Claude Code", "Cursor", "Cline") and `{{model_id}}` with your
218model identifier (e.g., "claude-sonnet-4-5-20250929"). The report must include:
219
220* **Security Score (0-100)** calculated using the scoring methodology: start at 100, subtract 15/Critical, 10/High, 5/Medium, 2/Low, +5 bonus if no Critical/High, minimum 0. Display with letter grade (A+ through F) and visual progress bar.
221* **Findings Dashboard** with total count, score, and top finding per severity level with file locations
222* **Node.js runtime version assessment** (Critical if EOL, with specific unpatched CVEs)
223* **Vulnerable built-in API usage** section with affected files
224* **Framework Security Assessment** (Express/Koa/webpack checks if detected)
225* Findings sorted by severity, each with: ID, title, severity, OWASP category, `filepath:line` location, all affected files listed, vulnerable code snippet, explanation, and remediation code snippet
226* **Quick Wins** section — top 3-5 easiest fixes with biggest score impact and projected score after fixes
227* Best practices checklist
228* Recommended tools section
229* **Summary footer** repeating the score, top priority, and projected score after Quick Wins
230
231**Severity classification:**
232
233| Severity | Criteria |
234|----------|----------|
235| Critical | EOL Node.js runtime, RCE, SQL injection, hardcoded secrets in public repos, auth bypass |
236| High | XSS, CSRF without tokens, SSRF, prototype pollution, weak crypto, vulnerable built-in API usage |
237| Medium | Missing security headers, verbose error messages, no rate limiting, outdated deps with known CVEs |
238| Low | Missing strict mode, console.log with PII, no input length limits, informational findings |
239
240### Step 6: Save and present
241
242Save the report as `security-audit-report.md` and then:
243
2441. Output the **full markdown report** directly in the conversation so the user can
245 read it without opening a file. Show the complete formatted report, not a summary.
2462. After the full report, remind the user the file was saved to `security-audit-report.md`.
2473. Ask the user if they would like a **PDF version** of the report. If they say yes,
248 generate the PDF using one of these methods (in preference order):
249 * `npx md-to-pdf security-audit-report.md` (no install needed)
250 * `pandoc security-audit-report.md -o security-audit-report.pdf` (if pandoc is available)
251 * If neither works, inform the user and suggest installing one of the tools.