์น API Pentesting
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
API Pentesting ๋ฐฉ๋ฒ๋ก ์์ฝ
API Pentesting์ ์ทจ์ฝ์ ์ ๋ฐ๊ฒฌํ๊ธฐ ์ํ ๊ตฌ์กฐํ๋ ์ ๊ทผ์ ํ์๋ก ํ๋ค. ์ด ๊ฐ์ด๋๋ ์ค๋ฌด ์ค์ฌ์ ๊ธฐ๋ฒ๊ณผ ๋๊ตฌ๋ฅผ ๊ฐ์กฐํ๋ ํฌ๊ด์ ์ธ ๋ฐฉ๋ฒ๋ก ์ ์์ฝํ๋ค.
API ์ ํ ์ดํด
- SOAP/XML Web Services: ๋ฌธ์ํ์ WSDL ํ์์ ์ฌ์ฉํ๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก
?wsdl๊ฒฝ๋ก์์ ์ฐพ์ ์ ์๋ค. SOAPUI ๋ฐ WSDLer(Burp Suite Extension) ๊ฐ์ ๋๊ตฌ๋ ์์ฒญ์ ํ์ฑํ๊ณ ์์ฑํ๋ ๋ฐ ์ ์ฉํ๋ค. ์์ ๋ฌธ์๋ DNE Online์์ ํ์ธํ ์ ์๋ค. - REST APIs (JSON): ๋ฌธ์๋ ์ข ์ข WADL ํ์ผ๋ก ์ ๊ณต๋์ง๋ง, Swagger UI ๊ฐ์ ๋๊ตฌ๊ฐ ๋ ์น์ํ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ๋ค. Postman์ ์์ ์์ฒญ์ ์์ฑํ๊ณ ๊ด๋ฆฌํ๋ ๋ฐ ์ ์ฉํ๋ค.
- GraphQL: API์ฉ ์ฟผ๋ฆฌ ์ธ์ด๋ก, API์ ๋ฐ์ดํฐ์ ๋ํด ์์ ํ๊ณ ์ดํดํ๊ธฐ ์ฌ์ด ์ค๋ช ์ ์ ๊ณตํ๋ค.
์ค์ต ๋ฉ
- VAmPI: ์ค์ต์ ์ํ ์๋์ ์ผ๋ก ์ทจ์ฝํ API๋ก, OWASP top 10 API ์ทจ์ฝ์ ์ ๋ค๋ฃฌ๋ค.
API Pentesting์ ์ํ ํจ๊ณผ์ ์ธ ํธ๋ฆญ
- SOAP/XML Vulnerabilities: DTD ์ ์ธ์ ์ข ์ข ์ ํ๋์ง๋ง, XML์ด ์ ํจํ๋ค๋ฉด CDATA ํ๊ทธ๊ฐ ํ์ด๋ก๋ ์ฝ์ ์ ํ์ฉํ ์ ์์ด XXE ์ทจ์ฝ์ ์ ํ์ํด๋ณด๋ผ.
- Privilege Escalation: ๊ถํ ์์ค์ด ๋ค๋ฅธ ๊ณ์ ์ผ๋ก ์๋ํฌ์ธํธ๋ฅผ ํ ์คํธํด ๋ฌด๋จ ์ ๊ทผ ๊ฐ๋ฅ์ฑ์ ํ์ธํ๋ผ.
- CORS Misconfigurations: ์ธ์ฆ๋ ์ธ์ ์์ CSRF ๊ณต๊ฒฉ์ ํตํด ์ ์ฉ๋ ์ ์๋์ง CORS ์ค์ ์ ์กฐ์ฌํ๋ผ.
- Endpoint Discovery: API ํจํด์ ํ์ฉํด ์จ๊ฒจ์ง ์๋ํฌ์ธํธ๋ฅผ ์ฐพ์๋ผ. fuzzers ๊ฐ์ ๋๊ตฌ๊ฐ ์ด ๊ณผ์ ์ ์๋ํํ ์ ์๋ค.
- Parameter Tampering: ์์ฒญ์ ํ๋ผ๋ฏธํฐ๋ฅผ ์ถ๊ฐํ๊ฑฐ๋ ๊ต์ฒดํด ๋ฌด๋จ ๋ฐ์ดํฐ ๋๋ ๊ธฐ๋ฅ์ ์ ๊ทผํ ์ ์๋์ง ์คํํด๋ณด๋ผ.
- HTTP Method Testing: ์์ฒญ ๋ฉ์๋(GET, POST, PUT, DELETE, PATCH)๋ฅผ ๋ณ๊ฒฝํด ์์์น ๋ชปํ ๋์์ด๋ ์ ๋ณด ๋์ถ์ ์ฐพ์๋ผ.
- Content-Type Manipulation: ๋ค์ํ content type(x-www-form-urlencoded, application/xml, application/json)์ ์ค๊ฐ๋ฉฐ ํ์ฑ ๋ฌธ์ ๋ ์ทจ์ฝ์ ์ ํ ์คํธํ๋ผ.
- Advanced Parameter Techniques: JSON ํ์ด๋ก๋์ ์์์น ๋ชปํ ๋ฐ์ดํฐ ํ์ ์ ๋ฃ์ด๋ณด๊ฑฐ๋ XXE ์ฃผ์ ์ ์ํด XML ๋ฐ์ดํฐ๋ฅผ ์กฐ์ํด๋ณด๋ผ. ๋ํ parameter pollution๊ณผ ์์ผ๋์นด๋ ๋ฌธ์๋ฅผ ์๋ํด ๊ด๋ฒ์ํ ํ ์คํธ๋ฅผ ์ํํ๋ผ.
- Version Testing: ์ค๋๋ API ๋ฒ์ ์ด ๋ ์ทจ์ฝํ ์ ์๋ค. ํญ์ ์ฌ๋ฌ API ๋ฒ์ ์ ํ์ธํ๊ณ ํ ์คํธํ๋ผ.
๊ถํ ๋ฐ ๋น์ฆ๋์ค ๋ก์ง (AuthN != AuthZ) โ tRPC/Zod protectedProcedure pitfalls
ํ๋ TypeScript ์คํ์ ์
๋ ฅ ๊ฒ์ฆ์ ์ํด tRPC์ Zod๋ฅผ ํํ ์ฌ์ฉํ๋ค. tRPC์์ protectedProcedure๋ ์ผ๋ฐ์ ์ผ๋ก ์์ฒญ์ด ์ ํจํ ์ธ์
(์ธ์ฆ)์ ๊ฐ์ก๋์ง ํ์ธํ์ง๋ง, ํธ์ถ์๊ฐ ์ ์ ํ ์ญํ /๊ถํ(์ธ๊ฐ)์ ๊ฐ์ถ์๋์ง๋ ๋ณด์ฅํ์ง ์๋๋ค. ์ด ๋ถ์ผ์น๋ ๋ฏผ๊ฐํ ์ ์ฐจ๊ฐ ๋จ์ง protectedProcedure๋ก๋ง ์ ํ๋ ๊ฒฝ์ฐ Broken Function Level Authorization/BOLA๋ก ์ด์ด์ง ์ ์๋ค.
- Threat model: ์ญํ ๊ฒ์ฌ๊ฐ ์์ผ๋ฉด ๊ถํ์ด ๋ฎ์ ์ธ์ฆ ์ฌ์ฉ์๋ผ๋ admin-grade ์ ์ฐจ๋ฅผ ํธ์ถํ ์ ์๋ค(์: background migrations, feature flags, tenant-wide maintenance, job control).
- Black-box signal:
POST /api/trpc/<router>.<procedure>์๋ํฌ์ธํธ๊ฐ ๊ธฐ๋ณธ ๊ณ์ ์ผ๋ก๋ ์ฑ๊ณตํ๋ ๊ฒฝ์ฐ โ ๊ด๋ฆฌ ์ ์ฉ์ด์ด์ผ ํ๋ค. Self-serve signups๋ exploitability๋ฅผ ํฌ๊ฒ ์ฆ๊ฐ์ํจ๋ค. - Typical tRPC route shape (v10+): JSON body๊ฐ
{"input": {...}}ํํ๋ก ๋ํ๋๋ค.
Example vulnerable pattern (no role/permission gate):
// The endpoint for retrying a migration job
// This checks for a valid session (authentication)
retry: protectedProcedure
// but not for an admin role (authorization).
.input(z.object({ name: z.string() }))
.mutation(async ({ input, ctx }) => {
// Logic to restart a sensitive migration
}),
์ค์ exploitation (black-box)
- ์ผ๋ฐ ๊ณ์ ์ ๋ฑ๋กํ๊ณ ์ธ์ฆ๋ ์ธ์ ์ ํ๋ํฉ๋๋ค (cookies/headers).
- โlistโ/โallโ/โstatusโ ์ ์ฐจ๋ฅผ ํตํด ๋ฐฑ๊ทธ๋ผ์ด๋ ์์ ๋๋ ๊ธฐํ ๋ฏผ๊ฐํ ๋ฆฌ์์ค๋ฅผ ์ด๊ฑฐํฉ๋๋ค.
curl -s -X POST 'https://<tenant>/api/trpc/backgroundMigrations.all' \
-H 'Content-Type: application/json' \
-b '<AUTH_COOKIES>' \
--data '{"input":{}}'
- ์์ ์ฌ์์๊ณผ ๊ฐ์ ๊ถํ ์๋ ์์ ์ ํธ์ถ:
curl -s -X POST 'https://<tenant>/api/trpc/backgroundMigrations.retry' \
-H 'Content-Type: application/json' \
-b '<AUTH_COOKIES>' \
--data '{"input":{"name":"<migration_name>"}}'
Impact to assess
- ๋น๋ฉฑ๋ฑ ์ฌ์์์ผ๋ก ์ธํ ๋ฐ์ดํฐ ์์: ๋ง์ด๊ทธ๋ ์ด์ /์์ปค์ ๋์ ์คํ์ ๊ฐ์ ํ๋ฉด ๊ฒฝ์ ์ํ(race conditions)์ ๋ถ์ผ์นํ ๋ถ๋ถ ์ํ(๋ฌด์ ๋ฐ์ดํฐ ์์ค, ๋ถ์ ๊ฒฐ๊ณผ ์์)๋ฅผ ์ด๋ํ ์ ์์ต๋๋ค.
- DoS via worker/DB ๊ณ ๊ฐ: ๋ฌด๊ฑฐ์ด ์์ ์ ๋ฐ๋ณต์ ์ผ๋ก ํธ๋ฆฌ๊ฑฐํ๋ฉด ์์ปค ํ๊ณผ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฐ๊ฒฐ์ด ์์ง๋์ด ํ ๋ํธ ์ ์ฒด ์ฅ์ ๋ฅผ ์ผ์ผํฌ ์ ์์ต๋๋ค.
API Pentesting์ ์ํ ๋๊ตฌ ๋ฐ ์๋ฃ
- kiterunner: API ์๋ํฌ์ธํธ ๋ฐ๊ฒฌ์ ๋งค์ฐ ์ ์ฉํฉ๋๋ค. ๋์ API์ ๋ํด ๊ฒฝ๋ก์ ํ๋ผ๋ฏธํฐ๋ฅผ ์ค์บํ๊ณ brute force๋ก ์๋ํด ๋ณด์ธ์.
kr scan https://domain.com/api/ -w routes-large.kite -x 20
kr scan https://domain.com/api/ -A=apiroutes-220828 -x 20
kr brute https://domain.com/api/ -A=raft-large-words -x 20 -d=0
kr brute https://domain.com/api/ -w /tmp/lang-english.txt -x 20 -d=0
- https://github.com/BishopFox/sj: sj๋ ๊ด๋ จ API ์๋ํฌ์ธํธ์ ์ฝํ ์ธ์ฆ์ ํ์ธํ์ฌ exposed Swagger/OpenAPI definition files์ ๊ฐ์ฌ๋ฅผ ๋๋๋ก ์ค๊ณ๋ ๋ช ๋ น์ค ๋๊ตฌ์ ๋๋ค. ๋ํ ์๋ ์ทจ์ฝ์ ํ ์คํธ์ฉ ์ปค๋งจ๋ ํ ํ๋ฆฟ์ ์ ๊ณตํฉ๋๋ค.
- Additional tools like automatic-api-attack-tool, Astra, and restler-fuzzer offer tailored functionalities for API security testing, ranging from attack simulation to fuzzing and vulnerability scanning.
- Cherrybomb: Cherrybomb๋ OAS ํ์ผ์ ๊ธฐ๋ฐ์ผ๋ก API๋ฅผ ๊ฐ์ฌํ๋ API ๋ณด์ ๋๊ตฌ์ ๋๋ค(๋๊ตฌ๋ rust๋ก ์์ฑ๋จ).
ํ์ต ๋ฐ ์ค์ต ์๋ฃ
- OWASP API Security Top 10: ์ผ๋ฐ์ ์ธ API ์ทจ์ฝ์ ์ ์ดํดํ๋ ๋ฐ ํ์ ์๋ฃ (OWASP Top 10).
- API Security Checklist: API๋ฅผ ๋ณดํธํ๊ธฐ ์ํ ํฌ๊ด์ ์ธ ์ฒดํฌ๋ฆฌ์คํธ (GitHub link).
- Logger++ Filters: API ์ทจ์ฝ์ ํ์์ ์ํด Logger++๋ ์ ์ฉํ ํํฐ๋ฅผ ์ ๊ณตํฉ๋๋ค (GitHub link).
- API Endpoints List: ํ ์คํธ์ฉ ์ ์ฌ API ์๋ํฌ์ธํธ๋ฅผ ์ ๋ณํ ๋ชฉ๋ก (GitHub gist).
์ฐธ๊ณ ์๋ฃ
- https://github.com/Cyber-Guy1/API-SecurityEmpire
- How An Authorization Flaw Reveals A Common Security Blind Spot: CVE-2025-59305 Case Study
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


