Knowledge base for finding security misconfiguration in application and infrastructure code - permissive CORS, weak headers and cookie flags, debug mode and verbose errors in production, default credentials, exposed admin and actuator endpoints, directory listing, and permissive Terraform, CloudFormation, Kubernetes, Helm, Docker and compose settings. Use when hunting config-level weaknesses or reviewing IaC and framework settings. CWE-16, CWE-942, CWE-1004, CWE-614, CWE-732, CWE-489, CWE-209...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Sh Kb Misconfig?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/dmdhrumilmistry-sh-kb-misconfig)
---
name: sh-kb-misconfig
description: "Knowledge base for finding security misconfiguration in application and infrastructure code - permissive CORS, weak headers and cookie flags, debug mode and verbose errors in production, default credentials, exposed admin and actuator endpoints, directory listing, and permissive Terraform, CloudFormation, Kubernetes, Helm, Docker and compose settings. Use when hunting config-level weaknesses or reviewing IaC and framework settings. CWE-16, CWE-942, CWE-1004, CWE-614, CWE-732, CWE-489, CWE-209, CWE-250, OWASP A05:2021-Security Misconfiguration."
---
# Security Misconfiguration - Hunter Knowledge Base
The code is fine, the settings are not: a default left on, a guard turned off, a scope widened. The bug sits in
config files, framework settings, IaC and container specs, so hunt by reading them against a secure baseline
and asking whether the **production** value is the insecure one.
## When to hunt this
Always present: framework settings files, env and sample configs, reverse proxy configs, Dockerfiles and compose,
Kubernetes manifests and Helm charts, Terraform, CloudFormation, Pulumi, Ansible, serverless configs. Find the
production overlay: `settings/prod.py`, `application-prod.yml`, `values-prod.yaml`, `*.tfvars`, `.env.production`.
A dev-only setting in a dev file is not a finding; the same setting in a shared base file or the prod overlay is.
## Sources (what controls the setting)
Config files and environment variables, command-line flags in Dockerfile `CMD` and manifests, IaC variables and
defaults, Helm `values.yaml` defaults, framework defaults when a setting is absent, and sample configs that
operators copy verbatim. Sample files (`config.example.*`) matter when the docs tell users to deploy them.
## Application and web configuration (grep targets)
- **CORS**: reflecting `Origin` into `Access-Control-Allow-Origin` together with
`Access-Control-Allow-Credentials: true`; allowing the `null` origin; allowlist checks by `startsWith`,
`endsWith`, `contains` or a loose regex (`evilexample.com`, `example.com.evil.net`); `cors()` or
`CORS(app)` with defaults, `allow_origins=["*"]`, `AllowAnyOrigin()`, `@CrossOrigin` with no origins,
`CORS_ALLOW_ALL_ORIGINS = True`. A literal `*` with credentials is rejected by browsers, but `*` on an
endpoint that serves private data without cookies (internal network, token in header) can still matter.
- **Cookies and sessions**: `Secure`, `HttpOnly` and `SameSite` absent or false on session and auth cookies
(`SESSION_COOKIE_SECURE`, `SESSION_COOKIE_HTTPONLY`, `cookie: { secure: false }`, `httpOnly: false`,
`SameSite=None` without need); long or non-expiring sessions; weak or default `secret_key` values.
- **Headers**: missing `Content-Security-Policy`, `Strict-Transport-Security`, `X-Content-Type-Options: nosniff`,
framing control (`X-Frame-Options` or CSP `frame-ancestors`), `Referrer-Policy`; CSP with `unsafe-inline`,
`unsafe-eval` or wildcard script sources; `Server` and `X-Powered-By` disclosure (low). Check helmet,
`SecurityMiddleware`, `SECURE_*` settings, nginx and Apache `add_header` for the real set.
- **Debug and error detail**: Django `DEBUG = True`, `ALLOWED_HOSTS = ["*"]`; Flask `app.run(debug=True)` or
`FLASK_DEBUG` (the Werkzeug debugger can execute code); Laravel `APP_DEBUG=true`; Rails
`consider_all_requests_local`; ASP.NET `UseDeveloperExceptionPage`, `customErrors mode="Off"`; PHP
`display_errors=On`; Express returning `err.stack`; Spring `server.error.include-stacktrace=always`;
GraphQL introspection and playgrounds, Swagger UI, `/debug`, `/phpinfo`, profilers enabled in production.
- **Exposed management endpoints**: Spring Boot `management.endpoints.web.exposure.include=*` or exposing `env`,
`heapdump`, `threaddump`, `loggers`, `shutdown`; Django admin on a public path; Jenkins, Tomcat manager, phpMyAdmin,
Kibana, Grafana, Prometheus, Redis, Elasticsearch, etcd and Docker API on public interfaces with no auth.
- **Defaults and sample credentials**: `admin/admin`, `changeme`, `password`, default DB or broker users,
seeded admin accounts created in migrations, default API keys or JWT secrets in sample configs (also `secrets`).
- **Listing and files**: nginx `autoindex on`, Apache `Options +Indexes`, static roots covering the app dir, `.git`,
`.env`, backups, source maps served in production.
- **TLS and transport**: `verify=False`, `rejectUnauthorized: false`, `InsecureSkipVerify: true`, TLS 1.0 or 1.1
or weak ciphers in proxy config, plain HTTP listeners without redirect, wildcard trust of proxies
(`X-Forwarded-*` accepted from anyone, `TRUSTED_PROXIES=*`).
## Infrastructure as code (grep targets)
- **Terraform and CloudFormation**: S3 `acl = "public-read"` or public access block settings false; a bucket
policy with `Principal: "*"`; security groups with `0.0.0.0/0` (or `::/0`) on 22, 3389, database and admin ports;
IAM `Action: "*"` or `Resource: "*"`, `iam:PassRole` on `*`, AdministratorAccess to workloads; RDS
`publicly_accessible = true`; `storage_encrypted = false`, unencrypted EBS, S3, SQS or SNS; versioning and
access logging off; CloudTrail or flow logs disabled; metadata service `http_tokens = "optional"`; public
snapshots or AMIs; Lambda or API Gateway with no authorizer; hardcoded secrets in `.tf` or state.
- **Kubernetes and Helm**: `privileged: true`, `allowPrivilegeEscalation: true`, `hostPath`, `hostNetwork`,
`hostPID`, `hostIPC`, added capabilities (`SYS_ADMIN`, `NET_ADMIN`), no `runAsNonRoot` or `runAsUser: 0`,
no `readOnlyRootFilesystem`, no resource limits, `automountServiceAccountToken` left on, `cluster-admin`
bindings or wildcard RBAC verbs and resources, no `NetworkPolicy` in a namespace, secrets in plain `env`,
mutable `:latest` images, exposed dashboards, `LoadBalancer` or `NodePort` for internal services, no Pod
Security admission labels. Helm: insecure defaults in `values.yaml` that templates pass through.
- **Docker and compose**: no `USER` (root), `privileged: true`, mounting `/var/run/docker.sock`, `network_mode:
host`, published ports on `0.0.0.0` for databases, `cap_add`, secrets in `ENV` or `ARG`, `COPY . .` bringing in
`.env` and `.git`, `:latest` bases. Build-chain issues belong to `ci-cd`.
- **Other**: Ansible and shell provisioning with `chmod 777`, world-writable paths, `0777` modes in code
(CWE-732), SSH `PermitRootLogin yes` and `PasswordAuthentication yes`, default database bind to all interfaces.
## Detection recipe
1. Inventory config surfaces: framework settings, proxy configs, IaC, manifests, Dockerfiles, env samples.
Identify which are production (deploy scripts, CI, Helm environment overlays, README deployment steps).
2. For each framework, check the secure-baseline list above against the **effective** value, including the
default when the key is missing and environment overrides (`os.environ.get("DEBUG", "True")` defaults to on).
3. Quick sweep: `rg -n -i "debug\s*[=:]\s*(true|1)|allow_origins|AllowAnyOrigin|Access-Control-Allow"` then
`rg -n "0\.0\.0\.0/0|privileged:\s*true|hostPath|publicly_accessible|public-read|autoindex|exposure\.include"`.
4. For CORS, read the origin-decision code, not just the setting: is the origin reflected, compared exactly,
and is `Allow-Credentials` set together with it? Is the endpoint authenticated by cookie?
5. For IaC, read each resource for network exposure, identity scope, encryption, logging and backup, and see
whether a module hides the insecure default (module `variables.tf` defaults).
6. Cross-check: an exposed endpoint is only critical if reachable and unauthenticated; confirm routing, ingress,
security group and auth middleware together.
7. Compare environments: a safe prod overlay can hide an insecure base, and the reverse.
## PoC templates (illustrative, authorized review only)
- CORS: `curl -s -I -H 'Origin: https://evil.example' https://target/api/me` and look for the origin echoed in
`Access-Control-Allow-Origin` plus `Access-Control-Allow-Credentials: true`; also try `Origin: null`.
- Debug: request a route that raises an error and look for stack traces, settings dumps or the debugger page.
- Actuator: `GET /actuator/env`, `/actuator/heapdump` (large), `/actuator/health` (usually benign alone).
- Listing: request a directory path and look for an index page; fetch `/.env`, `/.git/HEAD`.
- Cookies: inspect `Set-Cookie` for missing `Secure`, `HttpOnly`, `SameSite`.
- IaC: cite the resource and attribute (`aws_security_group.admin` ingress `0.0.0.0/0` port 22); runtime
confirmation is optional because the file is the evidence.
## Variant hunting
- Every other environment file, module, chart and region that copies the same resource block.
- Sibling services in a monorepo using the same base image, chart or Terraform module.
- Other cookies, endpoints and CORS paths: admin, API, websocket and static asset routes often differ.
- Same setting through other mechanisms: env var, CLI flag, config server, feature flag.
- Test and demo configs that the Dockerfile or deploy script actually copies into the release image.
## False-positive filters
- The setting is in a dev, test or local-only file that never ships, and production overrides it. Cite the
override or the deploy path to prove it.
- CORS `*` on a public, unauthenticated, read-only endpoint with no credentials is intended behaviour. Reflected
origin without credentials and without private data is low.
- The "public" resource is intentionally public (static site bucket, public docs) and holds no sensitive data.
- `0.0.0.0/0` on 80 or 443 for a public web tier is normal; on admin, database or internal ports it is not.
- A privileged container is a required system component (CNI, node agent) in a hardened namespace; note it, but
confirm it is justified and isolated.
- Internal-only management endpoints bound to localhost or a private network with authentication in front.
- Missing low-value headers alone (`Server`, `X-Powered-By`) are informational, not findings.
## CWE / OWASP / severity
CWE-16 (configuration), CWE-942 (permissive cross-domain policy with untrusted domains), CWE-1004 (cookie without
HttpOnly), CWE-614 (cookie without Secure), CWE-732 (incorrect permission assignment), CWE-489 (active debug
code), CWE-209 (error message with sensitive information), CWE-250 (unnecessary privileges), CWE-548 (directory
listing), CWE-1021 (clickjacking). OWASP A05:2021 Security Misconfiguration. Severity: **critical** for
unauthenticated admin or debugger exposure, public sensitive buckets, wildcard IAM on reachable workloads;
**high** for credentialed CORS reflection or default credentials on reachable services; **medium** for weak
cookie flags on session cookies and verbose errors; **low** for missing hardening headers.
## Chaining hints
Credentialed CORS reflection -> cross-site read of authenticated data -> account data theft; debug page -> code execution;
actuator `env` or heapdump -> `secrets` -> database or cloud access; public bucket -> data leak or
`file-upload` and hosted content abuse; privileged pod or wildcard IAM -> cluster or account takeover; missing
frame control -> clickjacking of `csrf`-protected actions.
## Detection signals (for defenders)
- **Web and proxy logs**: requests with `Origin` headers from unfamiliar sites to authenticated routes; hits on
`/actuator/*`, `/debug`, `/.env`, `/.git/`, `/phpinfo`, `/admin` from outside expected networks; error
responses with large bodies or stack traces.
- **Cloud audit logs** (CloudTrail, GCP and Azure activity): policy, ACL and security-group changes that open
`0.0.0.0/0` or public access, bucket policy edits, logging disabled, public snapshot sharing; anonymous
object reads on buckets that should be private.
- **Kubernetes audit and runtime**: creation of privileged or hostPath pods, new cluster-admin bindings,
exec into pods, service account token use from unusual sources.
- **Config drift and scanning**: IaC and CSPM drift reports; external scans showing new open ports.
- **Behavior-based ideas**: (1) alert on any change that makes a storage or network resource world-reachable;
(2) alert on first successful access to a management endpoint from a non-admin source network.
- ATT&CK: T1190 Exploit Public-Facing Application; T1530 Data from Cloud Storage; T1078.001 Valid Accounts:
Default Accounts.
## Mitigation
Ship secure defaults and fail closed: debug off, generic errors, authenticated and network-restricted admin and
management endpoints, no default credentials. Allowlist CORS origins by exact match and avoid credentials
unless needed. Set Secure, HttpOnly and SameSite on session cookies and a baseline of security headers with a
restrictive CSP. In IaC, deny public access by default, scope security groups and IAM to least privilege,
encrypt and log, and enforce with policy-as-code (OPA, tfsec/checkov class tools, admission control). In
Kubernetes, run non-root, drop capabilities, read-only root filesystem, apply NetworkPolicies and Pod
Security standards. Review config in code review as strictly as code.