API security misconfiguration: defaults, debug modes, and permissive CORS
The configuration mistakes that turn a sound API into an exposed one: debug endpoints, verbose errors, wildcard CORS with credentials, open documentation consoles, and missing TLS settings, with a scan-and-fix workflow.
Diagram
Configuration checks against a staging API
Step 1 of 4
Errors
A malformed body returns a stack trace.
{"error":"TypeError: Cannot read properties of undefined (reading 'id')",
"stack":"at /srv/app/routes/orders.js:41:18 ..."}The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Verbose errors
- What fails
- Stack traces and SQL errors reveal paths, versions, and queries.
- Who is affected
- The owner, whose internals become a map for attackers.
- What you would notice
- Response bodies with file paths or framework names after bad input.
- What you change
- Return generic errors with a request id and log the detail.
CORS reflecting origins
- What fails
- Echoing the Origin header with credentials allowed lets any site read signed-in responses.
- Who is affected
- Users who visit another site while signed in.
- What you would notice
- Access-Control-Allow-Origin equal to whatever Origin you send.
- What you change
- Use a fixed allow-list of origins.
Management endpoints
- What fails
- Framework actuators and admin consoles ship enabled.
- Who is affected
- Everything those endpoints expose, such as environment variables.
- What you would notice
- /actuator, /debug, /metrics, or /_admin answering publicly.
- What you change
- Expose only health checks publicly and move the rest behind authentication.
A quick authorized sweep
Against a staging host you are allowed to test, send a few requests that reveal configuration: a bad body, an OPTIONS request with a foreign Origin, and requests to common management paths. The CORS page has more detail on reading preflight responses.
$ curl -si -X OPTIONS https://api.staging.lab.test/orders -H "Origin: https://not-ours.example" \
-H "Access-Control-Request-Method: GET" | grep -i access-control
access-control-allow-origin: https://not-ours.example
access-control-allow-credentials: true
# finding: origin reflected with credentialsWrite the baseline down
Misconfiguration returns because each new service starts from framework defaults. Keep a short baseline per stack and check it in CI with a config test or policy tool so drift is caught before deploy.
Check yourself
Recognition and the fix. Nothing here is a procedure.
An API reflects any Origin with Access-Control-Allow-Credentials: true. What can another site do?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.
- 01Broken API authentication: tokens, keys, and the checks that get skippedCommon API authentication failures: unvalidated JWT claims, API keys in URLs, missing rate limits on token endpoints, and long-lived tokens.
- 02Injection through API fields: JSON bodies reaching SQL, NoSQL, and shellsWhy JSON APIs are still injection targets: operator injection in MongoDB-style queries, typed fields that are never type-checked, and filter parameters passed to query builders.
- 03Unsafe consumption of third-party APIs: treating partner data as trustedWhen your service calls a partner or SaaS API, its responses are input too.
- 04API inventory gaps: shadow, zombie, and undocumented endpointsYou cannot protect APIs you do not know about.
- 05GraphQL security: introspection, resolver authorization, and query costWhere GraphQL APIs go wrong — missing authorization in resolvers, unbounded nested queries, batching that defeats rate limits, and injection in resolver code — and how to review a schema and test it with a tool like InQL or graphql-cop.