Koding Siber Logo
Koding Siber
Academy CatalogAPI SecurityConfiguration and Inventory Management
Beginner Level30 minsFree Preview Module
Category: Configuration and Inventory Management

Exposed and Deprecated API Endpoints

Learn about security risks of maintaining deprecated or undocumented API endpoints.

EXPLORERINTERACTIVE
Exposed and Deprecated API Endpoints
HTTP
INFO:GET /api/v2/customers/1092/private_records [Auth: Bob]
API Consumer (Bob)(192.168.1.10)
Legitimate authenticated mobile client or developer terminal. Possesses a valid JWT token for User Bob, but tampers with URI IDs to request other users' records.
SIMULATION CONTROLSStep 1 of 5
Simulation Speed:
Simulation paused (click Play Flow or Next Step)
STEP 1 OF 5

TAMPER OBJECT IDENTIFIER

Client substitutes foreign resource ID

User 'Bob' observes legitimate endpoint structure and tampers with the object ID parameter, requesting data belonging to User 'Alice' to test for Exposed and Deprecated API Endpoints.

Payload / Code Inspector
GET /api/v2/customers/1092/private_records HTTP/1.1
Host: api.gateway.corp
Authorization: Bearer <Bob_Valid_JWT>
Defensive Mitigation
Implement object-level access control checks (validating that req.user.id === record.ownerId) on every single resource retrieval and update.

PACKET FLOW (WIRESHARK INSPECTOR)

Click any row to jump to step
NO.TIMESOURCEDESTINATIONPROTOCOLINFOSIZE
10.000s192.168.1.10api.gateway.corpHTTPGET /api/v2/customers/1092/private_records [Auth: Bob]162 B
20.015sapi.gateway.corp10.0.1.25JSONRPC: Forwarding request to Account Microservice198 B
30.028s10.0.1.2510.0.2.90SQLQUERY: SELECT * FROM customers WHERE id = 1092174 B
40.041s10.0.2.9010.0.1.25SQLDATA: [id=1092, owner=Alice, balance=$92k]270 B
50.056s10.0.1.25192.168.1.10HTTPHTTP/1.1 200 OK [Alice's Confidential Data returned to Bob]356 B
Payload Inspector
STEP 1
API Consumer (Bob)➔API Gateway
HTTP
Transmitted Data
162 B
GET /api/v2/customers/1092/private_records HTTP/1.1
Host: api.gateway.corp
Authorization: Bearer <Bob_Valid_JWT>
Client substitutes foreign resource IDINSPECTED
Vulnerability Overview

What is Exposed and Deprecated API Endpoints?

Learn about security risks of maintaining deprecated or undocumented API endpoints. In production environments, this flaw typically arises when applications process untrusted input or misconfigure architectural security controls.
Impact
Assists attackers in reconnaissance and may expose credentials.
Severity
MEDIUM
Technical Mechanism & Code Flaw

Root Cause Analysis

The vulnerability exists because user-controlled data or unhardened security flags are executed under improper security contexts.
Vulnerable Implementation (Anti-Pattern)UNSAFE
// BAD: Untrusted execution or unhardened configuration
const config = { debug: true, allowUnauthenticated: true };
app.use('/api', createService(config));
Secure Implementation (Hardened)SECURED
// GOOD: Strict hardening and defense-in-depth
const config = { debug: false, allowUnauthenticated: false, authRequired: true };
app.use('/api', authenticate, createService(config));
Detection & Penetration Testing Methodology

Detection & Penetration Testing Methodology

Tools Used in This Manual

Tool Purpose
Nikto Flags error-triggering paths, sensitive files, version banners in one pass
ffuf / gobuster Directory/file discovery for .git/, .env, backups, admin paths
git-dumper / GitTools Reconstructs a full repo from an exposed .git/ directory
TruffleHog / Gitleaks Scans JS bundles, repos, and page source for API keys/secrets automatically
crt.sh / Subfinder / Amass Certificate-transparency and subdomain reconnaissance
Google/Shodan dorking Search-engine reconnaissance for indexed sensitive content

Overview

Information disclosure is about anything the app reveals that it shouldn't -- error details that expose internals, files that were never meant to be public, secrets left in client-side code, or infrastructure details visible through public records. None of this requires breaking anything; it's mostly about looking carefully at what's already there, which is exactly what these tools automate.

This lab covers 5 steps:

Trigger errors and inspect responses for stack traces/paths/query text

Request well-known sensitive paths

Review page source, JS bundles, and headers for secrets/banners

Use search-engine and certificate-transparency recon for further exposed assets

Document each disclosed item and its source

Step 1 -- Trigger Errors and Inspect Responses

Goal: Malformed input often produces a verbose error page in a misconfigured app -- check what it reveals.

1.1 Let Nikto trigger and flag this automatically

nikto -h https://target.com

Nikto's scan includes requests designed to provoke error responses, and flags anything resembling a stack trace, path disclosure, or SQL error text directly in its output.

1.2 Manually trigger one error via Burp Repeater, to read the full detail

Capture any request, send to Repeater, and break it deliberately -- an extra unexpected parameter, a broken Content-Type, an invalid ID format. Read the response for file paths, framework/library version numbers, or raw query text.

1.3 What to look for

Full file system paths (/var/www/html/app/controllers/...)

Framework name + exact version (useful later for checking known CVEs)

Raw SQL fragments in the error text

Internal variable names or function names

Step 2 -- Well-Known Sensitive Paths

Goal: Check for files that should never be publicly served -- version control directories, environment files, backups, forgotten admin panels.

2.1 Run a focused ffuf scan with a sensitive-files wordlist

ffuf -u https://target.com/FUZZ -w sensitive-files.txt -mc 200

SecLists' Discovery/Web-Content directory has ready-made wordlists for exactly this (.git, .env, .DS_Store, backup.zip, wp-config.php.bak, etc.) -- no need to build your own list.

2.2 If .git/ is exposed, reconstruct the whole repository instead of guessing file-by-file

git-dumper https://target.com/.git/ ./dumped-repo

This tool detects the exposed .git directory and automatically pulls down the full repository history -- far more thorough than manually requesting individual git object files.

2.3 Scan the dumped repo for secrets automatically

trufflehog filesystem ./dumped-repo

TruffleHog scans the entire repo history (not just the current files) for API keys, credentials, and tokens that may have been committed and later removed -- catching secrets that wouldn't be visible in the live site at all.

2.4 Nikto also flags many of these same sensitive paths as part of its standard scan

The Step 1.1 scan already checks for several of these (.env, common backup extensions) -- cross-reference its output before running a separate dedicated pass.

Step 3 -- Page Source, JS Bundles, and Headers

Goal: Client-side code and HTTP headers often leak more than intended -- version banners, internal hostnames, hardcoded keys, leftover developer comments.

3.1 Scan all JS files for secrets automatically

trufflehog filesystem /path/to/downloaded/js/files

Or point Gitleaks at the same files:

gitleaks detect --source=/path/to/downloaded/js/files --no-git

Both tools use regex/entropy-based detection tuned for exactly this -- API keys, AWS credentials, private keys, internal URLs -- far faster and more reliable than manually reading minified JS.

3.2 Download the JS bundles first, if not already saved

wget -r -l1 -A.js https://target.com/

Or use Burp's HTTP history -- right-click any .js"Save item" for each bundle the app loaded while you browsed it.

3.3 Check HTTP headers for version banners

curl -s -I https://target.com/

Look for Server:, X-Powered-By:, and similar headers revealing exact software versions -- note these for cross-referencing against known CVEs later.

3.4 Check HTML source comments directly

curl -s https://target.com/ | grep -A 2 "<!--"

Developer comments left in production HTML sometimes include internal notes, TODOs referencing internal systems, or even commented-out credentials.

Step 4 -- Search-Engine and Certificate-Transparency Recon

Goal: Find exposed assets that exist outside the main app entirely -- forgotten subdomains, indexed sensitive pages, documents search engines have crawled.

4.1 Certificate transparency logs -- find subdomains via crt.sh

curl -s "https://crt.sh/?q=%.target.com&output=json" | jq -r '.[].name_value' | sort -u

Certificate transparency logs record every SSL certificate ever issued for the domain -- this often reveals subdomains (staging, internal, dev environments) that were never meant to be discoverable, since a cert had to be issued for them at some point regardless of whether DNS/robots.txt hides them.

4.2 Automated subdomain enumeration, combining multiple sources at once

subfinder -d target.com -silent

or

amass enum -passive -d target.com

Both aggregate crt.sh plus many other passive sources (DNS databases, search engines) in one run -- much broader than checking crt.sh alone.

4.3 Google dorking for indexed sensitive content

Run these searches directly in Google (or via a dorking tool like Pagodo, which automates a whole dork list against a target):

site:target.com filetype:pdf

site:target.com filetype:env

site:target.com intitle:"index of"

site:target.com inurl:admin

site:target.com ext:log

pagodo -d target.com -g dorks.txt -l 50 -s

4.4 Shodan for exposed infrastructure beyond the web app itself

shodan search hostname:target.com

Reveals any additional exposed services (databases, admin panels, IoT devices) tied to the organization's IP ranges that might not be linked from the main site at all.

Step 5 -- Document Each Disclosed Item

Goal: Export directly from each tool's native output.

5.1 Nikto report

nikto -h https://target.com -o evidence_nikto.html -Format html

5.2 ffuf results

ffuf -u https://target.com/FUZZ -w sensitive-files.txt -mc 200 -o evidence_ffuf_sensitive.json -of json

5.3 TruffleHog/Gitleaks findings

Both print found secrets directly to the terminal with file location and line number -- redirect to a file:

trufflehog filesystem ./dumped-repo --json > evidence_trufflehog.json

5.4 Subdomain/certificate transparency results

subfinder -d target.com -silent -o evidence_subdomains.txt

5.5 Manual confirmations

For anything confirmed by hand (a specific error page, a header), save the raw curl output or Burp Repeater request/response pair.

Evidence Table Template:

No. Item Disclosed Source Tool Used Sensitivity Conclusion
1 Full stack trace with file paths Malformed API request Burp Repeater Medium Confirmed
2 .git/ directory exposed, full repo reconstructed /.git/ git-dumper High Confirmed
3 AWS access key in committed repo history Reconstructed repo TruffleHog Critical Confirmed
4 API key hardcoded in JS bundle /static/app.js Gitleaks Critical Confirmed
5 Server version banner Response headers curl -I Low Confirmed (minor, useful for CVE lookup)
6 Internal staging subdomain Certificate transparency crt.sh / subfinder Medium-High Confirmed
7 Indexed internal PDF with employee data Google search Dork: site:target.com filetype:pdf High Confirmed

Proof of Concept

[Insert the exact request and payload that demonstrate the vulnerability, and the resulting response.]

Evidence

[Insert screenshot or HTTP request/response excerpt -- Figure F-27-1.]

Remediation

Return generic error messages to clients; log detailed errors only to a secured, server-side logging system.

Remove sensitive files (.git, .env, backups) from the web root and from the deployment artifact.

Strip version banners and internal identifiers from responses and headers where feasible.

Rotate any credentials or keys found to be exposed.

Re-test the identified disclosure points after remediation.

Retest Notes

[ ] Not yet retested [ ] Retested -- Resolved [ ] Retested -- Not resolved. [Retest date and tester name.]

References

CWE-200 CWE-209 OWASP Top 10:2021 OWASP WSTG

Hands-on Lab Exercise

Lab Scenario

Launch your local laboratory environment (e.g., OWASP Juice Shop, DVWA, or crAPI) to verify this vulnerability.

$ curl -X POST http://127.0.0.1:8080/api/target \ -d "probe=api-exposed-deprecated-endpoints"
• Goal: Verify vulnerable state behavior and apply defense
• Solution: Enforce defense-in-depth and strict validation
Knowledge Check
ASSESSMENT

What is the primary, most effective defense mechanism against Exposed and Deprecated API Endpoints?