Lesson 263 of 296
Misconfiguration, vulnerable dependencies and logging failures
What you will learn
- Common security misconfigurations
- Safe error handling and failing closed
- Software supply chain risks
- Managing dependencies safely
- Security logging and alerting
On this page
Security misconfiguration
Second in the 2025 Top 10. The code is fine; the settings are not:
| Misconfiguration | Example | Fix |
|---|---|---|
| Debug mode or stack traces in production | An error page shows SQL, file paths and library versions | Generic errors to users, details only in logs (Lesson 196) |
| Default credentials | admin/admin on a database admin panel | Change or disable all defaults |
| Public cloud storage | An S3 bucket with customer documents readable by anyone | Block Public Access, review policies (Lesson 253) |
| Open ports and services | Database or Redis reachable from the internet | Private subnets and security groups (Lesson 257) |
| Over-permissive CORS | Reflecting any origin with credentials (Lesson 199) | Allow-list exact origins |
| Missing security headers | No CSP, no HSTS (Lesson 264) | Set them centrally |
| Directory listing, exposed files | /.git/, /.env, /backup.sql downloadable | Never deploy them; block them in the web server |
| Unused features enabled | Old admin endpoints, sample apps, GraphQL introspection in production | Remove or restrict |
| Verbose headers | X-Powered-By: Express advertising versions | Disable (app.disable("x-powered-by")) |
Defences: secure defaults, configuration in code (IaC, Lesson 258), automated checks (cloud security posture tools such as AWS Security Hub), and the same hardened configuration in every environment.
Safe error handling and failing closed
The new 2025 category Mishandling of Exceptional Conditions covers errors handled badly:
- Fail closed, not open: if the permission service or token verification throws, deny the request. A
try { check() } catch { /* continue */ }around an authorisation check is a classic bug. - Do not leak details in error responses (stack traces, SQL, internal IDs).
- Handle all error paths: timeouts, partial failures, unexpected input types, resource exhaustion.
- Make multi-step operations atomic or compensating (Lessons 223 and 236), so an error halfway does not leave inconsistent data, such as an order marked paid without a payment.
Software supply chain failures
Third in the 2025 Top 10. A typical Node.js app has hundreds or thousands of dependencies, most of them indirect. Risks:
- Known vulnerabilities in packages you use (CVEs).
- Malicious packages: typosquatting (
expresss), compromised maintainer accounts publishing malware, and self-spreading npm worms that steal tokens and publish infected versions of other packages, as several 2025 incidents showed. - Install scripts (
postinstall) running arbitrary code on developer machines and CI. - Compromised build pipelines and GitHub Actions.
Defences:
| Practice | How |
|---|---|
| Lock files | Commit package-lock.json; install with npm ci in CI so exact versions are used |
| Scan | npm audit, GitHub Dependabot alerts and update pull requests, Snyk, OSV-Scanner |
| Update regularly | Small frequent updates are easier than rare big ones; test them in CI |
| Fewer dependencies | Do you need a package for 10 lines of code? |
| Vet new packages | Downloads, maintainers, recent activity, repository match; watch for typos in names |
| Restrict install scripts | npm ci --ignore-scripts where possible; newer npm and pnpm versions offer allow-lists for scripts and a minimum package age before installing new releases |
| Pin CI actions | Pin third-party GitHub Actions to full commit SHAs (Lesson 251) |
| Least-privilege tokens | CI and npm tokens scoped and short-lived; OIDC trusted publishing for your own packages |
| SBOM | A software bill of materials lists every component, so you can quickly answer "are we affected?" when a new vulnerability is announced |
| Integrity | Verify signatures and checksums of downloaded artefacts; npm provenance attestations |
Security logging and alerting
The ninth category: attacks succeed or continue because nobody noticed. Log security-relevant events:
- Logins (success and failure), password resets, MFA changes, new API keys.
- Access-denied (403/404 spikes from one user), validation failures at high rates, rate-limit hits.
- Admin actions and permission changes (audit trail, Lesson 228).
- Payment and data export events.
Rules:
- Logs include who, what, when, where (user ID, action, resource, timestamp, IP, request ID), as structured JSON.
- Never log secrets or sensitive data: passwords, tokens, full card numbers, session IDs; mask personal data where possible (UK GDPR).
- Protect logs from tampering and keep them for a defined period; centralise them (CloudWatch, Datadog, ELK).
- Alert on suspicious patterns: many failed logins (credential stuffing), impossible travel, sudden data exports, privilege changes, new admin users.
- Have an incident response plan: who is called, how to rotate credentials, how to notify users and, for personal data breaches, the ICO (UK GDPR generally requires reporting a notifiable breach within 72 hours of becoming aware of it).
How to say it in an interview
"Security misconfiguration, now second in OWASP, covers debug output in production, default credentials, public buckets, open ports, permissive CORS and missing headers; I rely on secure defaults, infrastructure as code and automated posture checks. I handle errors by failing closed, never leaking internals and keeping multi-step operations atomic. For the software supply chain I commit lock files and use npm ci, scan with npm audit and Dependabot, update regularly, minimise and vet dependencies, restrict install scripts, pin CI actions and keep an SBOM. I log security events like logins, access denials and admin actions as structured logs without secrets, and alert on patterns such as credential stuffing."
Key words
| Word | Meaning |
|---|---|
| Security misconfiguration | Unsafe settings rather than code bugs |
| Fail closed | Deny when a check cannot be completed |
| Supply chain attack | Compromising software through its dependencies or build tools |
| Typosquatting | Malicious packages with names similar to popular ones |
| Lock file | Records exact dependency versions |
| CVE | A public identifier for a known vulnerability |
| SBOM | A list of all components in a piece of software |
| Credential stuffing | Trying leaked username and password pairs on many sites |
Now prove it
This lesson is complete when you pass the quiz and all three practice levels.