Unit 7: The network from the host · Lesson 3 of 7 · 18 min
Talking to a local service
Use curl to read a status API's headers, health and a debug page that should not exist.
mission
- You are
- You are reviewing the shop's internal status API on port 8081.
- Situation
- It only listens on 127.0.0.1, so the team calls it internal. Anything on the machine can still reach it, including a compromised web process.
- Goal
- Query each endpoint and decide what it exposes.
- Hand in
- The service version and any endpoint that leaks secrets.
Ask what it is
curl -s localhost:8081/ {"service": "shop-status", "version": "1.4.2", "status": "ok"} curl -si localhost:8081/ | head -n 2 HTTP/1.0 200 OK Server: shop-status/1.4.2
you should see -s hides the progress bar, -i includes headers. The Server header gives the version away too.
Probe the likely endpoints
for p in / /health /debug /admin /status; do printf '%s %s\n' $(curl -s -o /dev/null -w '%{http_code}' localhost:8081$p) $p; done
200 /
200 /health
200 /debug
404 /admin
404 /status
you should see Three endpoints answer. -w '%{http_code}' prints only the status code.
Read the debug page
curl -s localhost:8081/debug
{"config": {"app_env": "production", "db_host": "10.20.0.12", "db_user": "shop_app", "db_password": "lab-only-not-a-real-secret", "debug": true}}
you should see The full config with the database password, in production.
defender tip Local-only is not a security boundary. Remove debug routes from production builds instead.
What a defender takes away
- 1curl -s and -i are your first look at any HTTP service.
- 2Loop over likely paths and read the status codes.
- 3Debug endpoints in production leak secrets.
Questions
0 of 3 solved
Answer each one from what you find on your lab machine.