一键导入
nestjs-security-testing
Security testing playbook for NestJS applications covering guards, pipes, decorators, module boundaries, and multi-transport auth
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Security testing playbook for NestJS applications covering guards, pipes, decorators, module boundaries, and multi-transport auth
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Authorized AI penetration testing assistant for web applications, APIs, and infrastructure. Performs reconnaissance, vulnerability assessment, PoC validation, exploit chaining, and professional reporting. Use when the user asks for pentest, penetration test, security assessment, vulnerability scan, bug bounty research, authorized hacking, SQLi/XSS/IDOR/SSRF testing, API security audit, or exploit validation.
Authorized AI penetration testing for web apps, APIs, cloud, and infrastructure. Full kill-chain methodology with PoC validation, vulnerability chaining, and professional reporting. Triggers on: pentest, penetration test, security assessment, vuln scan, bug bounty, red team, authorized hack, SQL injection test, XSS test, IDOR, SSRF, API security, exploit validation, security audit.
Authorized AI penetration testing assistant — full-spectrum security testing with deep exploitation skills and integrated tooling. Use for web app pentests, API security, vuln validation, PoC development, bug bounty, and security assessments. Triggers on pentest, penetration test, security audit, exploit, SQLi, XSS, IDOR, SSRF.
API安全测试的专业技能和方法论
JWT and OIDC security testing covering token forgery, algorithm confusion, and claim manipulation
AWS cloud security testing covering IAM misconfigurations, S3 exposure, metadata abuse, and privilege escalation paths
| name | nestjs-security-testing |
| description | Security testing playbook for NestJS applications covering guards, pipes, decorators, module boundaries, and multi-transport auth |
penkit51 AI — professional penetration testing skill pack. Authorized testing only.
Security testing for NestJS applications. Focus on guard gaps across decorator stacks, validation pipe bypasses, module boundary leaks, and inconsistent auth enforcement across HTTP, WebSocket, and microservice transports.
Decorator Pipeline
@UseGuards, CanActivate, execution context (HTTP/WS/RPC), Reflector metadataValidationPipe (whitelist, transform, forbidNonWhitelisted), ParseIntPipe, custom pipes@SetMetadata, @Public(), @Roles(), @Permissions()Module System
@Module boundaries, provider scoping (DEFAULT/REQUEST/TRANSIENT)forRoot/forRootAsync, global modulesControllers & Transports
@Controller, versioning (URI/Header/MediaType)@Resolver, playground/sandbox exposure@WebSocketGateway, gateway guards, room authorizationData Layer
$queryRaw, $queryRawUnsafe$where, $regexAuth & Config
@nestjs/passport strategies, @nestjs/jwt, session-based auth@nestjs/config, ConfigService, .env files@nestjs/throttler, rate limiting with @SkipThrottleAPI Documentation
@nestjs/swagger: OpenAPI exposure, DTO schemas, auth schemes/api, /api-docs, /api-json, /swagger)@Roles('admin') — test with user-level tokensFileInterceptor/FilesInterceptor@MessagePattern, @EventPattern) — often unguarded@nestjsx/crud) with auto-generated endpoints@nestjs/schedule)@nestjs/terminus, /health, /metrics)/graphql)Swagger Discovery
GET /api
GET /api-docs
GET /api-json
GET /swagger
GET /docs
GET /v1/api-docs
GET /api/v2/docs
Extract: paths, parameter schemas, DTOs, auth schemes, example values. Swagger may reveal internal endpoints, deprecated routes, and admin-only paths not visible in the UI.
Guard Mapping
For each controller and method, identify:
main.ts or app module)@UseGuards on the class)@UseGuards on individual handlers)@Public() or @SkipThrottle() decorators that bypass protectionDecorator Stack Gaps
@UseGuards when siblings have it is the #1 finding.@Public() metadata causing global AuthGuard to skip enforcement — check if applied too broadly.ExecutionContext Switching
getRequest()) may fail silently on WebSocket or RPC, returning true by default.Reflector Mismatches
SetMetadata('roles', [...]) but decorator sets 'role' (singular) — guard sees no metadata, defaults to allow.applyDecorators() compositions accidentally overriding stricter guards with permissive ones.Whitelist Bypass
whitelist: true without forbidNonWhitelisted: true: extra properties silently stripped but may have been processed by earlier middleware/interceptors.@Type(() => ChildDto) on nested objects: @ValidateNested() without @Type means nested payload is never validated.@IsArray() doesn't validate elements without @ValidateNested({ each: true }) and @Type.Type Coercion
transform: true enables implicit coercion: strings → numbers, "true" → true, "null" → null.Conditional Validation
@ValidateIf() and validation groups creating paths where fields skip validation entirely.Missing Parse Pipes
@Param('id') without ParseIntPipe/ParseUUIDPipe — string values reach ORM queries directly.JWT Strategy
ignoreExpiration is false, algorithms is pinned (no none or HS/RS confusion)secretOrKey valuesPassport Strategy Issues
validate() return value becomes req.user — if it returns full DB record, sensitive fields leak downstreamtrue for unauthenticated as "optional auth"Timing Attacks
Missing ClassSerializerInterceptor
@Exclude() fields (passwords, internal IDs) returned in responses.@Expose() with groups: admin-only fields exposed when groups not enforced per-request.Circular Relations
Cache Poisoning
CacheInterceptor without user/tenant identity in cache key — responses from one user served to another.Response Mapping
Global Module Exposure
@Global() modules expose all providers to every module without explicit imports.Config Leaks
forRoot/forRootAsync configuration secrets accessible via ConfigService injection in any module.Scope Issues
Scope.REQUEST) incorrectly scoped as DEFAULT (singleton) — request context leaks across concurrent requests.@UseGuards must be explicit.handleConnection to message handlers allows unauthenticated message sending.@SubscribeMessage() handlers relying on connection-level auth instead of per-message validation.@MessagePattern/@EventPattern handlers often lack guards (considered "internal").ValidationPipe may only be configured for HTTP — microservice payloads skip validation.TypeORM
QueryBuilder and .query() with template literal interpolation → SQL injection.Mongoose
{ password: { $gt: "" } } via unsanitized request body.$where and $regex operators from user input.Prisma
$queryRaw/$executeRaw with string interpolation (but not tagged template).$queryRawUnsafe usage.@SkipThrottle() on sensitive endpoints (login, password reset, OTP).trust proxy: all requests share same IP, or header spoofable.createMany, updateMany) bypassing per-entity authorization.filter, sort, join, select exposing unauthorized data.@Public() / skip-metadata applied via composed decorators at method level causing global guards to skip via Reflector metadata checks/users/123?id=456 — which id wins in guards vs handlers?X-HTTP-Method-Override or _method processed by Express before guardsapplication/x-www-form-urlencoded instead of JSON to bypass JSON-specific validationpenkit51 AI — professional penetration testing skill pack. Authorized testing only.
Security testing for NestJS applications. Focus on guard gaps across decorator stacks, validation pipe bypasses, module boundary leaks, and inconsistent auth enforcement across HTTP, WebSocket, and microservice transports.
Decorator Pipeline
@UseGuards, CanActivate, execution context (HTTP/WS/RPC), Reflector metadataValidationPipe (whitelist, transform, forbidNonWhitelisted), ParseIntPipe, custom pipes@SetMetadata, @Public(), @Roles(), @Permissions()Module System
@Module boundaries, provider scoping (DEFAULT/REQUEST/TRANSIENT)forRoot/forRootAsync, global modulesControllers & Transports
@Controller, versioning (URI/Header/MediaType)@Resolver, playground/sandbox exposure@WebSocketGateway, gateway guards, room authorizationData Layer
$queryRaw, $queryRawUnsafe$where, $regexAuth & Config
@nestjs/passport strategies, @nestjs/jwt, session-based auth@nestjs/config, ConfigService, .env files@nestjs/throttler, rate limiting with @SkipThrottleAPI Documentation
@nestjs/swagger: OpenAPI exposure, DTO schemas, auth schemes/api, /api-docs, /api-json, /swagger)@Roles('admin') — test with user-level tokensFileInterceptor/FilesInterceptor@MessagePattern, @EventPattern) — often unguarded@nestjsx/crud) with auto-generated endpoints@nestjs/schedule)@nestjs/terminus, /health, /metrics)/graphql)Swagger Discovery
GET /api
GET /api-docs
GET /api-json
GET /swagger
GET /docs
GET /v1/api-docs
GET /api/v2/docs
Extract: paths, parameter schemas, DTOs, auth schemes, example values. Swagger may reveal internal endpoints, deprecated routes, and admin-only paths not visible in the UI.
Guard Mapping
For each controller and method, identify:
main.ts or app module)@UseGuards on the class)@UseGuards on individual handlers)@Public() or @SkipThrottle() decorators that bypass protectionDecorator Stack Gaps
@UseGuards when siblings have it is the #1 finding.@Public() metadata causing global AuthGuard to skip enforcement — check if applied too broadly.ExecutionContext Switching
getRequest()) may fail silently on WebSocket or RPC, returning true by default.Reflector Mismatches
SetMetadata('roles', [...]) but decorator sets 'role' (singular) — guard sees no metadata, defaults to allow.applyDecorators() compositions accidentally overriding stricter guards with permissive ones.Whitelist Bypass
whitelist: true without forbidNonWhitelisted: true: extra properties silently stripped but may have been processed by earlier middleware/interceptors.@Type(() => ChildDto) on nested objects: @ValidateNested() without @Type means nested payload is never validated.@IsArray() doesn't validate elements without @ValidateNested({ each: true }) and @Type.Type Coercion
transform: true enables implicit coercion: strings → numbers, "true" → true, "null" → null.Conditional Validation
@ValidateIf() and validation groups creating paths where fields skip validation entirely.Missing Parse Pipes
@Param('id') without ParseIntPipe/ParseUUIDPipe — string values reach ORM queries directly.JWT Strategy
ignoreExpiration is false, algorithms is pinned (no none or HS/RS confusion)secretOrKey valuesPassport Strategy Issues
validate() return value becomes req.user — if it returns full DB record, sensitive fields leak downstreamtrue for unauthenticated as "optional auth"Timing Attacks
Missing ClassSerializerInterceptor
@Exclude() fields (passwords, internal IDs) returned in responses.@Expose() with groups: admin-only fields exposed when groups not enforced per-request.Circular Relations
Cache Poisoning
CacheInterceptor without user/tenant identity in cache key — responses from one user served to another.Response Mapping
Global Module Exposure
@Global() modules expose all providers to every module without explicit imports.Config Leaks
forRoot/forRootAsync configuration secrets accessible via ConfigService injection in any module.Scope Issues
Scope.REQUEST) incorrectly scoped as DEFAULT (singleton) — request context leaks across concurrent requests.@UseGuards must be explicit.handleConnection to message handlers allows unauthenticated message sending.@SubscribeMessage() handlers relying on connection-level auth instead of per-message validation.@MessagePattern/@EventPattern handlers often lack guards (considered "internal").ValidationPipe may only be configured for HTTP — microservice payloads skip validation.TypeORM
QueryBuilder and .query() with template literal interpolation → SQL injection.Mongoose
{ password: { $gt: "" } } via unsanitized request body.$where and $regex operators from user input.Prisma
$queryRaw/$executeRaw with string interpolation (but not tagged template).$queryRawUnsafe usage.@SkipThrottle() on sensitive endpoints (login, password reset, OTP).trust proxy: all requests share same IP, or header spoofable.createMany, updateMany) bypassing per-entity authorization.filter, sort, join, select exposing unauthorized data.@Public() / skip-metadata applied via composed decorators at method level causing global guards to skip via Reflector metadata checks/users/123?id=456 — which id wins in guards vs handlers?X-HTTP-Method-Override or _method processed by Express before guardsapplication/x-www-form-urlencoded instead of JSON to bypass JSON-specific validationrecord_vulnerability when running inside the penkit51 platformrecord_vulnerability when running inside the penkit51 platform