Skip to content
mentoor

Topic 5 of 5 · 4 min read

Security misconfiguration and loosened settings

Goal: Find the unsafe settings in a generated configuration and tighten them without breaking the feature.

When an agent hits a blocking error, it often loosens a setting until the error goes away; your job is to notice the loosening and put back the narrowest setting that works. Security Misconfiguration is A02 in the OWASP Top 10 (2025).

Check yourself · 1 of 3

A browser shows a cross-origin error and the agent sets Access-Control-Allow-Origin: *. What is the better fix?

Choose one answer

Why it matters

A browser blocks a request with a cross-origin error. The agent adds Access-Control-Allow-Origin: *. The error vanishes, the demo works and the diff looks small. The same happens with disabled certificate checks, permissive file permissions and debug flags. The change solves the symptom and widens the attack surface.

Settings to scan for

  1. CORS. A wildcard origin, or reflecting the request's Origin back, together with credentials.
  2. Debug and verbose errors. DEBUG=true or stack traces returned to the client leak paths, versions and queries.
  3. TLS checks turned off. verify=False, rejectUnauthorized: false.
  4. Security headers missing. No Content-Security-Policy, Strict-Transport-Security or X-Content-Type-Options.
  5. Cookies. Missing HttpOnly, Secure or SameSite.
  6. Access defaults. Public storage buckets, admin routes open, default credentials, a server listening on 0.0.0.0 that was meant for localhost.
  7. Broad permissions. A container running as root, a role with * actions.

How to review

  • Read config files and the diff of any file named config, settings, Dockerfile or *.yaml.
  • Ask for every relaxed setting: "what error was this hiding?" Then fix the cause.
  • Check that production values differ from development values, and that dev defaults do not ship.

Before and after

// Before: made the browser error disappear
app.use(cors({ origin: '*', credentials: true }));

// After: only the real front end
app.use(cors({ origin: ['https://app.example.com'], credentials: true }));

Browsers will not allow a wildcard origin with credentials, which is a sign the first version was wrong from the start.

What goes wrong

  • Shipping dev settings. A debug flag survives into the production build.
  • Fixing the symptom. TLS verification is turned off instead of installing the missing certificate.
  • Reviewing code but not config. The unsafe line is in a YAML file nobody opened.

Examples

The silenced certificate error

resp = requests.get(url, verify=False)

The agent added verify=False after a certificate error. Traffic can now be intercepted. Fix: install the correct CA bundle or certificate chain and keep verification on.

Key points

  • Agents often relax a setting to clear an error, so look for loosened values in every config diff.
  • Restrict CORS to the exact origins that need access, especially when credentials are involved.
  • Never ship debug mode, stack traces to clients or disabled TLS verification.
  • Check cookie flags and security headers on anything that serves a browser.
  • For every relaxed setting, ask what error it was hiding and fix that cause.

Common mistakes

  • Accepting a wildcard CORS rule because it makes the error go away.
  • Leaving debug mode or detailed error pages on in production.
  • Disabling TLS verification to get past a certificate problem.
  • Reviewing only source code and skipping config, Dockerfile and infrastructure files.

Check yourself · 2 of 3

Which setting should never reach production?

Choose one answer

Check yourself · 3 of 3

An agent adds verify=False to an HTTPS request after a certificate error. What should you do?

Choose one answer

Practice items, not counted towards your mastery.

Start here