@gpzhang2001/sharpkit-skills 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -0
  3. package/THIRD_PARTY_NOTICES.md +48 -0
  4. package/lib/index.d.ts +2027 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/index.js +70 -0
  7. package/lib/index.js.map +1 -0
  8. package/package.json +46 -0
  9. package/skills/analysis/counterevidence.md +185 -0
  10. package/skills/analysis/fix_verification.md +129 -0
  11. package/skills/analysis/severity_calibration.md +130 -0
  12. package/skills/analysis/source_aware_discovery.md +211 -0
  13. package/skills/cloud/aws.md +231 -0
  14. package/skills/cloud/azure.md +262 -0
  15. package/skills/cloud/gcp.md +194 -0
  16. package/skills/cloud/kubernetes.md +223 -0
  17. package/skills/coordination/root_agent.md +105 -0
  18. package/skills/coordination/source_aware_whitebox.md +47 -0
  19. package/skills/custom/api_spec_testing.md +61 -0
  20. package/skills/custom/dependency_cve_scanning.md +341 -0
  21. package/skills/custom/npx_confusion.md +233 -0
  22. package/skills/custom/source_aware_sast.md +192 -0
  23. package/skills/frameworks/django.md +214 -0
  24. package/skills/frameworks/fastapi.md +191 -0
  25. package/skills/frameworks/nestjs.md +225 -0
  26. package/skills/frameworks/nextjs.md +228 -0
  27. package/skills/protocols/graphql.md +276 -0
  28. package/skills/protocols/oauth.md +185 -0
  29. package/skills/reconnaissance/asset_discovery.md +150 -0
  30. package/skills/reconnaissance/infrastructure_lifecycle.md +226 -0
  31. package/skills/scan_modes/deep.md +164 -0
  32. package/skills/scan_modes/diff.md +86 -0
  33. package/skills/scan_modes/quick.md +68 -0
  34. package/skills/scan_modes/standard.md +99 -0
  35. package/skills/technologies/active_directory.md +233 -0
  36. package/skills/technologies/auth0.md +188 -0
  37. package/skills/technologies/electron_desktop_apps.md +181 -0
  38. package/skills/technologies/firebase.md +263 -0
  39. package/skills/technologies/grafana_prometheus.md +189 -0
  40. package/skills/technologies/llm_applications.md +257 -0
  41. package/skills/technologies/supabase.md +268 -0
  42. package/skills/tooling/agent_browser.md +551 -0
  43. package/skills/tooling/ffuf.md +72 -0
  44. package/skills/tooling/httpx.md +82 -0
  45. package/skills/tooling/hurl.md +99 -0
  46. package/skills/tooling/hypothesis.md +100 -0
  47. package/skills/tooling/katana.md +102 -0
  48. package/skills/tooling/naabu.md +68 -0
  49. package/skills/tooling/nmap.md +66 -0
  50. package/skills/tooling/nuclei.md +67 -0
  51. package/skills/tooling/python.md +109 -0
  52. package/skills/tooling/semgrep.md +72 -0
  53. package/skills/tooling/sqlmap.md +67 -0
  54. package/skills/tooling/subfinder.md +66 -0
  55. package/skills/vulnerabilities/agentic_system_security.md +207 -0
  56. package/skills/vulnerabilities/argument_injection.md +157 -0
  57. package/skills/vulnerabilities/authentication_jwt.md +166 -0
  58. package/skills/vulnerabilities/broken_function_level_authorization.md +154 -0
  59. package/skills/vulnerabilities/browser_security.md +192 -0
  60. package/skills/vulnerabilities/business_logic.md +178 -0
  61. package/skills/vulnerabilities/csrf.md +198 -0
  62. package/skills/vulnerabilities/header_injection.md +216 -0
  63. package/skills/vulnerabilities/http_request_smuggling.md +255 -0
  64. package/skills/vulnerabilities/idor.md +217 -0
  65. package/skills/vulnerabilities/information_disclosure.md +187 -0
  66. package/skills/vulnerabilities/insecure_deserialization.md +210 -0
  67. package/skills/vulnerabilities/insecure_file_uploads.md +194 -0
  68. package/skills/vulnerabilities/llm_prompt_injection.md +187 -0
  69. package/skills/vulnerabilities/mass_assignment.md +153 -0
  70. package/skills/vulnerabilities/nosql_injection.md +288 -0
  71. package/skills/vulnerabilities/open_redirect.md +165 -0
  72. package/skills/vulnerabilities/path_traversal_lfi_rfi.md +218 -0
  73. package/skills/vulnerabilities/prototype_pollution.md +142 -0
  74. package/skills/vulnerabilities/race_conditions.md +181 -0
  75. package/skills/vulnerabilities/rce.md +250 -0
  76. package/skills/vulnerabilities/semantic_confusion.md +189 -0
  77. package/skills/vulnerabilities/sql_injection.md +190 -0
  78. package/skills/vulnerabilities/ssrf.md +186 -0
  79. package/skills/vulnerabilities/ssti.md +270 -0
  80. package/skills/vulnerabilities/subdomain_takeover.md +167 -0
  81. package/skills/vulnerabilities/weak_password_detection.md +200 -0
  82. package/skills/vulnerabilities/xss.md +206 -0
  83. package/skills/vulnerabilities/xxe.md +223 -0
  84. package/src/index.ts +89 -0
@@ -0,0 +1,225 @@
1
+ ---
2
+ name: nestjs
3
+ description: Security testing playbook for NestJS applications covering guards, pipes, decorators, module boundaries, and multi-transport auth
4
+ ---
5
+
6
+ # NestJS
7
+
8
+ 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.
9
+
10
+ ## Attack Surface
11
+
12
+ **Decorator Pipeline**
13
+ - Guards: `@UseGuards`, `CanActivate`, execution context (HTTP/WS/RPC), `Reflector` metadata
14
+ - Pipes: `ValidationPipe` (whitelist, transform, forbidNonWhitelisted), `ParseIntPipe`, custom pipes
15
+ - Interceptors: response mapping, caching, logging, timeout — can modify request/response flow
16
+ - Filters: exception filters that may leak information
17
+ - Metadata: `@SetMetadata`, `@Public()`, `@Roles()`, `@Permissions()`
18
+
19
+ **Module System**
20
+ - `@Module` boundaries, provider scoping (DEFAULT/REQUEST/TRANSIENT)
21
+ - Dynamic modules: `forRoot`/`forRootAsync`, global modules
22
+ - DI container: provider overrides, custom providers
23
+
24
+ **Controllers & Transports**
25
+ - REST: `@Controller`, versioning (URI/Header/MediaType)
26
+ - GraphQL: `@Resolver`, playground/sandbox exposure
27
+ - WebSocket: `@WebSocketGateway`, gateway guards, room authorization
28
+ - Microservices: TCP, Redis, NATS, MQTT, gRPC, Kafka — often lack HTTP-level auth
29
+
30
+ **Data Layer**
31
+ - TypeORM: repositories, QueryBuilder, raw queries, relations
32
+ - Prisma: `$queryRaw`, `$queryRawUnsafe`
33
+ - Mongoose: operator injection, `$where`, `$regex`
34
+
35
+ **Auth & Config**
36
+ - `@nestjs/passport` strategies, `@nestjs/jwt`, session-based auth
37
+ - `@nestjs/config`, ConfigService, `.env` files
38
+ - `@nestjs/throttler`, rate limiting with `@SkipThrottle`
39
+
40
+ **API Documentation**
41
+ - `@nestjs/swagger`: OpenAPI exposure, DTO schemas, auth schemes
42
+
43
+ ## High-Value Targets
44
+
45
+ - Swagger/OpenAPI endpoints in production (`/api`, `/api-docs`, `/api-json`, `/swagger`)
46
+ - Auth endpoints: login, register, token refresh, password reset, OAuth callbacks
47
+ - Admin controllers decorated with `@Roles('admin')` — test with user-level tokens
48
+ - File upload endpoints using `FileInterceptor`/`FilesInterceptor`
49
+ - WebSocket gateways sharing business logic with HTTP controllers
50
+ - Microservice handlers (`@MessagePattern`, `@EventPattern`) — often unguarded
51
+ - CRUD generators (`@nestjsx/crud`) with auto-generated endpoints
52
+ - Background jobs and scheduled tasks (`@nestjs/schedule`)
53
+ - Health/metrics endpoints (`@nestjs/terminus`, `/health`, `/metrics`)
54
+ - GraphQL playground/sandbox in production (`/graphql`)
55
+
56
+ ## Reconnaissance
57
+
58
+ **Swagger Discovery**
59
+ ```
60
+ GET /api
61
+ GET /api-docs
62
+ GET /api-json
63
+ GET /swagger
64
+ GET /docs
65
+ GET /v1/api-docs
66
+ GET /api/v2/docs
67
+ ```
68
+
69
+ 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.
70
+
71
+ **Guard Mapping**
72
+
73
+ For each controller and method, identify:
74
+ - Global guards (applied in `main.ts` or app module)
75
+ - Controller-level guards (`@UseGuards` on the class)
76
+ - Method-level guards (`@UseGuards` on individual handlers)
77
+ - `@Public()` or `@SkipThrottle()` decorators that bypass protection
78
+
79
+ ## Key Vulnerabilities
80
+
81
+ ### Guard Bypass
82
+
83
+ **Decorator Stack Gaps**
84
+ - Guards execute: global → controller → method. A method missing `@UseGuards` when siblings have it is the #1 finding.
85
+ - `@Public()` metadata causing global `AuthGuard` to skip enforcement — check if applied too broadly.
86
+ - New methods added to existing controllers without inheriting the expected guard.
87
+
88
+ **ExecutionContext Switching**
89
+ - Guards handling only HTTP context (`getRequest()`) may fail silently on WebSocket or RPC, returning `true` by default.
90
+ - Test same business logic through alternate transports to find context-specific bypasses.
91
+
92
+ **Reflector Mismatches**
93
+ - Guard reads `SetMetadata('roles', [...])` but decorator sets `'role'` (singular) — guard sees no metadata, defaults to allow.
94
+ - `applyDecorators()` compositions accidentally overriding stricter guards with permissive ones.
95
+
96
+ ### Validation Pipe Exploits
97
+
98
+ **Whitelist Bypass**
99
+ - `whitelist: true` without `forbidNonWhitelisted: true`: extra properties silently stripped but may have been processed by earlier middleware/interceptors.
100
+ - Missing `@Type(() => ChildDto)` on nested objects: `@ValidateNested()` without `@Type` means nested payload is never validated.
101
+ - Array elements: `@IsArray()` doesn't validate elements without `@ValidateNested({ each: true })` and `@Type`.
102
+
103
+ **Type Coercion**
104
+ - `transform: true` enables implicit coercion: strings → numbers, `"true"` → `true`, `"null"` → `null`.
105
+ - Exploit truthiness assumptions in business logic downstream.
106
+
107
+ **Conditional Validation**
108
+ - `@ValidateIf()` and validation groups creating paths where fields skip validation entirely.
109
+
110
+ **Missing Parse Pipes**
111
+ - `@Param('id')` without `ParseIntPipe`/`ParseUUIDPipe` — string values reach ORM queries directly.
112
+
113
+ ### Auth & Passport
114
+
115
+ **JWT Strategy**
116
+ - Check `ignoreExpiration` is false, `algorithms` is pinned (no `none` or HS/RS confusion)
117
+ - Weak `secretOrKey` values
118
+ - Cross-service token reuse when audience/issuer not enforced
119
+
120
+ **Passport Strategy Issues**
121
+ - `validate()` return value becomes `req.user` — if it returns full DB record, sensitive fields leak downstream
122
+ - Multiple strategies (JWT + session): one may bypass restrictions of the other
123
+ - Custom guards returning `true` for unauthenticated as "optional auth"
124
+
125
+ **Timing Attacks**
126
+ - Plain string comparison instead of bcrypt/argon2 in local strategy
127
+
128
+ ### Serialization Leaks
129
+
130
+ **Missing ClassSerializerInterceptor**
131
+ - If not applied globally, `@Exclude()` fields (passwords, internal IDs) returned in responses.
132
+ - `@Expose()` with groups: admin-only fields exposed when groups not enforced per-request.
133
+
134
+ **Circular Relations**
135
+ - Eager-loaded TypeORM/Prisma relations exposing entire object graph without careful serialization.
136
+
137
+ ### Interceptor Abuse
138
+
139
+ **Cache Poisoning**
140
+ - `CacheInterceptor` without user/tenant identity in cache key — responses from one user served to another.
141
+ - Test: authenticated request, then unauthenticated request returning cached data.
142
+
143
+ **Response Mapping**
144
+ - Transformation interceptors may leak internal entity fields if mapping is incomplete.
145
+
146
+ ### Module Boundary Leaks
147
+
148
+ **Global Module Exposure**
149
+ - `@Global()` modules expose all providers to every module without explicit imports.
150
+ - Sensitive services (admin operations, internal APIs) accessible from untrusted modules.
151
+
152
+ **Config Leaks**
153
+ - `forRoot`/`forRootAsync` configuration secrets accessible via `ConfigService` injection in any module.
154
+
155
+ **Scope Issues**
156
+ - Request-scoped providers (`Scope.REQUEST`) incorrectly scoped as DEFAULT (singleton) — request context leaks across concurrent requests.
157
+
158
+ ### WebSocket Gateway
159
+
160
+ - HTTP guards don't automatically apply to WebSocket gateways — `@UseGuards` must be explicit.
161
+ - Authentication deferred from `handleConnection` to message handlers allows unauthenticated message sending.
162
+ - Room/namespace authorization: users joining rooms they shouldn't access.
163
+ - `@SubscribeMessage()` handlers relying on connection-level auth instead of per-message validation.
164
+
165
+ ### Microservice Transport
166
+
167
+ - `@MessagePattern`/`@EventPattern` handlers often lack guards (considered "internal").
168
+ - If transport (Redis, NATS, Kafka) is network-accessible, messages can be injected bypassing all HTTP security.
169
+ - `ValidationPipe` may only be configured for HTTP — microservice payloads skip validation.
170
+
171
+ ### ORM Injection
172
+
173
+ **TypeORM**
174
+ - `QueryBuilder` and `.query()` with template literal interpolation → SQL injection.
175
+ - Relations: API allowing specification of which relations to load via query params.
176
+
177
+ **Mongoose**
178
+ - Query operator injection: `{ password: { $gt: "" } }` via unsanitized request body.
179
+ - `$where` and `$regex` operators from user input.
180
+
181
+ **Prisma**
182
+ - `$queryRaw`/`$executeRaw` with string interpolation (but not tagged template).
183
+ - `$queryRawUnsafe` usage.
184
+
185
+ ### Rate Limiting
186
+
187
+ - `@SkipThrottle()` on sensitive endpoints (login, password reset, OTP).
188
+ - In-memory throttler storage: resets on restart, doesn't work across instances.
189
+ - Behind proxy without `trust proxy`: all requests share same IP, or header spoofable.
190
+
191
+ ### CRUD Generators
192
+
193
+ - Auto-generated CRUD endpoints may not inherit manual guard configurations.
194
+ - Bulk operations (`createMany`, `updateMany`) bypassing per-entity authorization.
195
+ - Query parameter injection in CRUD libraries: `filter`, `sort`, `join`, `select` exposing unauthorized data.
196
+
197
+ ## Bypass Techniques
198
+
199
+ - `@Public()` / skip-metadata applied via composed decorators at method level causing global guards to skip via `Reflector` metadata checks
200
+ - Route param pollution: `/users/123?id=456` — which `id` wins in guards vs handlers?
201
+ - Version routing: v1 of endpoint may still be registered without the guard added to v2
202
+ - `X-HTTP-Method-Override` or `_method` processed by Express before guards
203
+ - Content-type switching: `application/x-www-form-urlencoded` instead of JSON to bypass JSON-specific validation
204
+ - Exception filter differences: guard throwing results in generic error that leaks route existence info
205
+
206
+ ## Testing Methodology
207
+
208
+ 1. **Enumerate** — Fetch Swagger/OpenAPI, map all controllers, resolvers, and gateways
209
+ 2. **Guard audit** — Map decorator stack per method: which guards, pipes, interceptors are applied at each level
210
+ 3. **Matrix testing** — Test each endpoint across: unauth/user/admin × HTTP/WS/microservice
211
+ 4. **Validation probing** — Send extra fields, wrong types, nested objects, arrays to find pipe gaps
212
+ 5. **Transport parity** — Same operation via HTTP, WebSocket, and microservice transport
213
+ 6. **Module boundaries** — Check if providers from one module are accessible without proper imports
214
+ 7. **Serialization check** — Compare raw entity fields with API response fields
215
+
216
+ ## Validation Requirements
217
+
218
+ - Guard bypass: request to guarded endpoint succeeding without auth, showing guard chain break point
219
+ - Validation bypass: payload with extra/malformed fields affecting business logic
220
+ - Cross-transport inconsistency: same action authorized via HTTP but exploitable via WebSocket/microservice
221
+ - Module boundary leak: accessing provider or data across unauthorized module boundaries
222
+ - Serialization leak: response containing excluded fields (passwords, internal metadata)
223
+ - IDOR: side-by-side requests from different users showing unauthorized data access
224
+ - ORM injection: raw query with user-controlled input returning unauthorized data, or error-based evidence of query structure
225
+ - Cache poisoning: response from unauthenticated or different-user request matching a prior authenticated user's cached response
@@ -0,0 +1,228 @@
1
+ ---
2
+ name: nextjs
3
+ description: Security testing playbook for Next.js covering App Router, Server Actions, RSC, and Edge runtime vulnerabilities
4
+ ---
5
+
6
+ # Next.js
7
+
8
+ Security testing for Next.js applications. Focus on authorization drift across runtimes (Edge/Node), caching boundaries, server actions, and middleware bypass.
9
+
10
+ ## Attack Surface
11
+
12
+ **Routers**
13
+ - App Router (`app/`) and Pages Router (`pages/`) often coexist
14
+ - Route Handlers (`app/api/**`) and API routes (`pages/api/**`)
15
+ - Middleware: `middleware.ts` at project root
16
+
17
+ **Runtimes**
18
+ - Node.js (full API access)
19
+ - Edge (V8 isolates, restricted APIs)
20
+
21
+ **Rendering & Caching**
22
+ - SSR, SSG, ISR, on-demand revalidation
23
+ - RSC (React Server Components) with fetch cache
24
+ - Draft/preview mode
25
+
26
+ **Data Paths**
27
+ - Server Components, Client Components
28
+ - Server Actions (streamed POST with `Next-Action` header)
29
+ - `getServerSideProps`, `getStaticProps`
30
+
31
+ **Integrations**
32
+ - NextAuth.js (callbacks, CSRF, callbackUrl)
33
+ - `next/image` optimization and remote loaders
34
+
35
+ ## High-Value Targets
36
+
37
+ - Middleware-protected routes (auth, geo, A/B)
38
+ - Admin/staff paths, draft/preview content, on-demand revalidate endpoints
39
+ - RSC payloads and flight data, streamed responses
40
+ - Image optimizer and custom loaders, remotePatterns/domains
41
+ - NextAuth callbacks (`/api/auth/callback/*`), sign-in providers
42
+ - Edge-only features (bot protection, IP gates) and their Node equivalents
43
+
44
+ ## Reconnaissance
45
+
46
+ **Route Discovery**
47
+
48
+ ```javascript
49
+ // Browser console - list all routes
50
+ console.log(__BUILD_MANIFEST.sortedPages.join('\n'))
51
+
52
+ // Inspect server-fetched data
53
+ JSON.parse(document.getElementById('__NEXT_DATA__').textContent).props.pageProps
54
+
55
+ // List public environment variables
56
+ Object.keys(process.env).filter(k => k.startsWith('NEXT_PUBLIC_'))
57
+ ```
58
+
59
+ **Build Artifacts**
60
+ ```
61
+ GET /_next/static/<buildId>/_buildManifest.js
62
+ GET /_next/static/<buildId>/_ssgManifest.js
63
+ GET /_next/static/chunks/pages/
64
+ GET /_next/static/chunks/app/
65
+ ```
66
+ Chunk filenames map to routes (e.g., `admin.js` → `/admin`).
67
+
68
+ **Source Maps**
69
+
70
+ Check `/_next/static/` for exposed `.map` files revealing route structure, server action IDs, and internal functions.
71
+
72
+ **Client Bundle Mining**
73
+
74
+ Search main-*.js for: `pathname:`, `href:`, `__next_route__`, `serverActions`, API endpoints. Grep for `API_KEY`, `SECRET`, `TOKEN`, `PASSWORD` to find accidentally leaked credentials.
75
+
76
+ **Server Action Discovery**
77
+
78
+ Inspect Network tab for POST requests with `Next-Action` header. Extract action IDs from response streams and hydration data.
79
+
80
+ **Additional Leakage**
81
+ - `/sitemap.xml`, `/robots.txt`, `/sitemap-*.xml` for unintended admin/internal/preview paths
82
+ - Client bundles/env for secret paths and preview/admin flags (many teams hide routes via UI only)
83
+
84
+ ## Key Vulnerabilities
85
+
86
+ ### Middleware Bypass
87
+
88
+ **Known Techniques**
89
+ - `x-middleware-subrequest` header crafting (CVE-class bypass)
90
+ - `x-nextjs-data` probing
91
+ - Look for 307 + `x-middleware-rewrite`/`x-nextjs-redirect` headers
92
+
93
+ **Path Normalization**
94
+ ```
95
+ /api/users
96
+ /api/users/
97
+ /api//users
98
+ /api/./users
99
+ ```
100
+ Middleware may normalize differently than route handlers. Test double slashes, trailing slashes, dot segments.
101
+
102
+ **Parameter Pollution**
103
+ ```
104
+ ?id=1&id=2
105
+ ?filter[]=a&filter[]=b
106
+ ```
107
+ Middleware checks first value, handler uses last or array.
108
+
109
+ ### Server Actions
110
+
111
+ - Invoke actions outside UI flow with alternate content-types
112
+ - Authorization assumed from client state rather than enforced server-side
113
+ - IDOR via object references in action payloads
114
+ - Map action IDs from source maps to discover hidden actions
115
+
116
+ ### RSC & Caching
117
+
118
+ **Cache Boundary Failures**
119
+ - User-bound data cached without identity keys (ETag/Set-Cookie unaware)
120
+ - Personalized content served from shared cache/CDN
121
+ - Missing `no-store` on sensitive fetches
122
+
123
+ **Flight Data Leakage**
124
+
125
+ Inspect streamed RSC payloads for serialized sensitive fields in props.
126
+
127
+ **ISR Issues**
128
+ - Stale-while-revalidate responses containing user-specific or tenant-dependent data
129
+ - Weak secrets in on-demand revalidation endpoint URLs
130
+ - Referer-disclosed tokens or unvalidated hosts triggering `revalidatePath`/`revalidateTag`
131
+ - Header-smuggling or method variations to trigger revalidation
132
+
133
+ ### Authentication
134
+
135
+ **NextAuth Pitfalls**
136
+ - Missing/relaxed state/nonce/PKCE per provider (login CSRF, token mix-up)
137
+ - Open redirect in `callbackUrl` or mis-scoped allowed hosts
138
+ - JWT audience/issuer not enforced across routes
139
+ - Cross-service token reuse
140
+ - Session hijacking by forcing callbacks
141
+
142
+ **Session Boundaries**
143
+ - Different auth enforcement between App Router and Pages Router
144
+ - API routes vs Route Handlers authorization inconsistency
145
+
146
+ ### Data Exposure
147
+
148
+ **__NEXT_DATA__ Over-fetching**
149
+
150
+ Server-fetched data passed to client but not rendered:
151
+ - Full user objects when only username needed
152
+ - Internal IDs, tokens, admin-only fields
153
+ - ORM select-all patterns exposing entire records
154
+ - API responses forwarded without sanitization (metadata, cursors, debug info)
155
+
156
+ **Environment-Dependent Exposure**
157
+ - Staging/dev accidentally exposes more fields than production
158
+ - Inconsistent serialization logic across environments
159
+
160
+ **Props Inspection**
161
+ ```javascript
162
+ // Check for sensitive data in page props
163
+ JSON.parse(document.getElementById('__NEXT_DATA__').textContent).props
164
+ ```
165
+ Look for `_metadata`, `_internal`, `__typename` (GraphQL), nested sensitive objects.
166
+
167
+ ### Image Optimizer SSRF
168
+
169
+ **Remote Patterns**
170
+ - Broad `images.domains`/`remotePatterns` in `next.config.js`
171
+ - Test: internal hosts, IPv4/IPv6 variants, DNS rebinding
172
+
173
+ **Custom Loaders**
174
+ - Protocol smuggling via redirect chains
175
+ - Cache poisoning via URL normalization differences affecting other users
176
+
177
+ ### Runtime Divergence
178
+
179
+ **Edge vs Node**
180
+ - Defenses relying on Node-only modules skipped on Edge
181
+ - Header trust differs (`x-forwarded-*` handling)
182
+ - Same route may behave differently across runtimes
183
+
184
+ ### Client-Side
185
+
186
+ **XSS Vectors**
187
+ - `dangerouslySetInnerHTML`
188
+ - Markdown renderers
189
+ - User-controlled href/src attributes
190
+ - Validate CSP/Trusted Types coverage for SSR/CSR/hydration
191
+
192
+ **Hydration Mismatches**
193
+
194
+ Server vs client render differences can enable gadget-based XSS.
195
+
196
+ ### Draft/Preview Mode
197
+
198
+ - Secret URLs/cookies enabling preview
199
+ - Preview secrets leaked in client bundles/env
200
+ - Setting preview cookies from subdomains or via open redirects
201
+
202
+ ## Bypass Techniques
203
+
204
+ - Content-type switching: `application/json` ↔ `multipart/form-data` ↔ `application/x-www-form-urlencoded`
205
+ - Method override: `_method`, `X-HTTP-Method-Override`, GET on endpoints accepting writes
206
+ - Case/param aliasing and query duplication affecting middleware vs handler parsing
207
+ - Cache key confusion at CDN/proxy (lack of Vary on auth cookies/headers)
208
+
209
+ ## Testing Methodology
210
+
211
+ 1. **Enumerate** - Use `__BUILD_MANIFEST`, source maps, build artifacts, sitemap/robots to map all routes
212
+ 2. **Runtime matrix** - Test each route under Edge and Node runtimes
213
+ 3. **Role matrix** - Test as unauth/user/admin across SSR, API routes, Route Handlers, Server Actions
214
+ 4. **Cache probing** - Verify caching respects identity (strip cookies, alter Vary headers, check ETags)
215
+ 5. **Middleware validation** - Test path variants and header manipulation for bypass
216
+ 6. **Cross-router** - Compare authorization between App Router and Pages Router paths
217
+
218
+ ## Validation Requirements
219
+
220
+ - Side-by-side requests showing cross-user/tenant access
221
+ - Cache boundary failure proof (response diffs, ETag collisions)
222
+ - Server action invocation outside UI with insufficient auth
223
+ - Middleware bypass with explicit headers showing protected content access
224
+ - Runtime parity checks (Edge vs Node inconsistent enforcement)
225
+ - Discovered routes verified as deployed (200/403) not just build artifacts (404)
226
+ - Leaked credentials tested with minimal read-only calls; filter placeholders
227
+ - `__NEXT_DATA__` exposure: verify cross-user (User A's props shouldn't contain User B's PII), confirm exposed fields not in DOM
228
+ - Path normalization bypasses: show differential responses (403 vs 200), redirects don't count