Skip to the content

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:

MisconfigurationExampleFix
Debug mode or stack traces in productionAn error page shows SQL, file paths and library versionsGeneric errors to users, details only in logs (Lesson 196)
Default credentialsadmin/admin on a database admin panelChange or disable all defaults
Public cloud storageAn S3 bucket with customer documents readable by anyoneBlock Public Access, review policies (Lesson 253)
Open ports and servicesDatabase or Redis reachable from the internetPrivate subnets and security groups (Lesson 257)
Over-permissive CORSReflecting any origin with credentials (Lesson 199)Allow-list exact origins
Missing security headersNo CSP, no HSTS (Lesson 264)Set them centrally
Directory listing, exposed files/.git/, /.env, /backup.sql downloadableNever deploy them; block them in the web server
Unused features enabledOld admin endpoints, sample apps, GraphQL introspection in productionRemove or restrict
Verbose headersX-Powered-By: Express advertising versionsDisable (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:

PracticeHow
Lock filesCommit package-lock.json; install with npm ci in CI so exact versions are used
Scannpm audit, GitHub Dependabot alerts and update pull requests, Snyk, OSV-Scanner
Update regularlySmall frequent updates are easier than rare big ones; test them in CI
Fewer dependenciesDo you need a package for 10 lines of code?
Vet new packagesDownloads, maintainers, recent activity, repository match; watch for typos in names
Restrict install scriptsnpm 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 actionsPin third-party GitHub Actions to full commit SHAs (Lesson 251)
Least-privilege tokensCI and npm tokens scoped and short-lived; OIDC trusted publishing for your own packages
SBOMA software bill of materials lists every component, so you can quickly answer "are we affected?" when a new vulnerability is announced
IntegrityVerify 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

WordMeaning
Security misconfigurationUnsafe settings rather than code bugs
Fail closedDeny when a check cannot be completed
Supply chain attackCompromising software through its dependencies or build tools
TyposquattingMalicious packages with names similar to popular ones
Lock fileRecords exact dependency versions
CVEA public identifier for a known vulnerability
SBOMA list of all components in a piece of software
Credential stuffingTrying 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.