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.

Lesson 36 of 69 · 10 min read · practice only with authorization

Diagram

Configuration checks against a staging API

Follow the path. One example at a time.

Step 1 of 4

Errors

A malformed body returns a stack trace.

Illustration: Errors
{"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.

  1. 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.
  2. 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.
  3. 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 credentials

Write 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.

1 / 3

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.

  1. MapAPI security as an environmentModern products are APIs with a few front ends.
  1. 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.
  2. 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.
  3. 03Unsafe consumption of third-party APIs: treating partner data as trustedWhen your service calls a partner or SaaS API, its responses are input too.
  4. 04API inventory gaps: shadow, zombie, and undocumented endpointsYou cannot protect APIs you do not know about.
  5. 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.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.

Glossary

  1. CardAPI security misconfigurationDebug routes, default accounts, or verbose errors ship with the API.