
Introduction
Security is a continuous process, not a single task. This checklist gives developers practical, prioritized actions to reduce risk across the full lifecycle of a web application — design, build, deploy, and operate. Use it as a living document: automate where possible, measure continuously, and iterate after incidents or audits.
High-Level Principles
- Least Privilege: Give users, services, and components only the permissions they absolutely need.
- Defense in Depth: Apply multiple, independent controls (network, app, data, infra) so a single failure doesn’t lead to compromise.
- Fail Securely: On error, default to denying access or reducing functionality rather than revealing sensitive state.
- Shift Left: Move security earlier into design and CI/CD (SAST, dependency checks, policy gates).
Design & Architecture
- Threat Modeling: Perform a lightweight threat model for major features and data flows (identify assets, trust boundaries, and likely attacker goals).
- Data Classification: Label sensitive data (PII, credentials, payment data) and apply controls accordingly (encryption, access controls).
- API & Contract Security: Define explicit API contracts (OpenAPI/GraphQL schema) and validate inputs/outputs at the edge.
- Zero Trust Principles: Treat all network calls as untrusted; authenticate and authorize every request.
Authentication & Authorization
- Use Proven Identity Systems: Prefer established identity providers or libraries (OIDC, OAuth2, SAML) rather than rolling your own.
- Multi-Factor Authentication (MFA): Enforce MFA for privileged accounts and administrative interfaces.
- Strong Session Management: Use secure, HttpOnly cookies or short-lived bearer tokens; rotate and revoke tokens as needed.
- Role-Based & Attribute-Based Access Control: Centralize authorization logic and avoid duplicating permission checks across services.
Transport & Data Protection
- HTTPS Everywhere: Enforce TLS (minimum TLS 1.2, prefer 1.3). Redirect HTTP to HTTPS and use HSTS with an appropriate max-age once stable.
- Encrypt Sensitive Data at Rest: Use strong encryption (AES-256) for databases, backups, and object storage; manage keys with a KMS.
- Protect Secrets: Store secrets in a vault (HashiCorp Vault, cloud KMS/Secret Manager), avoid checked-in secrets, and rotate creds regularly.
Input Validation & Output Encoding
- Validate Inputs: Whitelist expected types/values server-side; never trust client-side validation alone.
- Escape & Encode Outputs: Apply context-aware encoding for HTML, JavaScript, CSS, and URL contexts to prevent XSS.
- Sanitize File Uploads: Restrict file types, scan for malware, store uploads outside the webroot, and serve via signed URLs.
Security Headers & Browser Controls
Set response headers to reduce attack surface. Example minimal header set (adapt for your app):
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-...'; object-src 'none'
Referrer-Policy: no-referrer-when-downgrade
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Permissions-Policy: geolocation=(), microphone=()
Use nonces or hashes for CSP script allowances and iterate CSP in report-only mode first to avoid breaking production.
Dependency & Supply Chain Security
- Lock and Pin Dependencies: Use lockfiles (package-lock.json / yarn.lock / pnpm-lock.yaml) and pin major versions where appropriate.
- Automated Scanning: Integrate SCA tools (Snyk, Dependabot, OSV) into CI to detect vulnerable libs and transitive dependencies.
- Build Reproducibility: Use reproducible builds and verify upstream artifacts (signed packages where available).
- Minimal Images & Packages: Use minimal base images and remove unnecessary packages to reduce attack surface.
Secure Coding & CI/CD
- SAST & Linting: Run static analysis in CI and address findings before merging.
- Secret Scanning: Block commits containing plaintext secrets and fail the build if detected.
- Immutable Artifacts: Produce versioned, immutable artifacts and deploy those rather than rebuilding in each environment.
- Least-Privilege CI Runners: Limit CI credentials and use ephemeral tokens. Avoid storing long-lived secrets in CI.
Runtime Protections & Infrastructure
- Network Segmentation: Isolate databases and internal services behind private networks and restrict inbound rules.
- WAF & Edge Protections: Use a Web Application Firewall and edge rules to block common attack patterns and bad bots.
- Rate Limiting & Throttling: Apply rate limits to APIs and auth endpoints to slow brute-force and abuse.
- Container & Cloud Hardening: Scan images, use read-only file systems where possible, and enforce minimal IAM policies.
Logging, Monitoring & Incident Response
- Centralized Logging: Collect logs (auth events, errors, anomalous API activity) centrally and retain according to policy.
- Alerting & SLOs: Define security SLOs (e.g., mean time to detect) and set alerts for unusual authentication patterns, privilege escalations, or spike in errors.
- RUM & EDR: Combine real-user monitoring and endpoint detection for broader visibility.
- Runbooks & Playbooks: Maintain step-by-step incident response runbooks for common scenarios (data leak, credential compromise, DDOS).
- Tabletop Exercises: Practice incident response quarterly to refine communications, containment, and recovery procedures.
Testing & Validation
- Penetration Testing: Schedule periodic pentests (internal and third-party) focused on high-risk areas.
- DAST: Run dynamic scans against staging environments with realistic data and authentication flows.
- Fuzzing & Chaos: Consider fuzzing inputs for critical services and chaos tests for resilience under failure.
- Continuous Verification: Re-run automated security tests in CI for every PR to prevent regressions.
Privacy & Compliance
- Data Minimization: Collect only necessary data and document retention policies.
- Privacy by Design: Provide clear consent UX and easy mechanisms for data access, export, and deletion.
- Compliance Mapping: Map controls to regulatory requirements you must meet (GDPR, PCI-DSS, HIPAA, etc.) and automate evidence collection where possible.
Operational Checklist (Quick Wins)
- Enable HTTPS and HSTS across all domains.
- Rotate secrets and enforce vault usage for production credentials.
- Pin CSP in report-only, review reports, then enforce.
- Enable MFA for all admin and contributor accounts.
- Integrate dependency scanning and SAST into CI pipelines.
- Configure centralized logging and set alerts for suspicious auth patterns.
- Review IAM roles and remove excessive privileges.
- Run a vulnerability scan and prioritize fixes by exploitability and impact.
Helpful Example: Simple Express.js Security Middleware
Quick example showing common headers and basic rate limiting (concept only):
const helmet = require('helmet');
const rateLimit = require('express-rate-limit');
app.use(helmet()); // Security headers
app.use(rateLimit({
windowMs: 15 * 60 * 1000,
max: 100 // tune per endpoint
}));
// Example: enforce HTTPS behind a proxy
app.use((req, res, next) => {
if (req.headers['x-forwarded-proto'] !== 'https') {
return res.redirect(301, 'https://' + req.hostname + req.originalUrl);
}
next();
});
Do not use this snippet as a complete solution—adapt to your auth model, deployment topology, and threat profile.
Maintaining Security as You Scale
- Security Champions: Embed security-minded engineers in product teams to keep practices practical and context-aware.
- Automate Remediation Where Safe: Auto-fix trivial issues (e.g., dependency updates) but require human review for high-risk changes.
- Measure Risk Over Time: Track mean time to remediate (MTTR) vulnerabilities, number of high-severity findings, and incident counts.
Conclusion
Securing a web application requires a combination of good architecture, strong development practices, automated tooling, and mature operations. Use this checklist to prioritize actions that reduce the biggest risks first, automate repetitive controls, and build a culture where security is part of the developer workflow. Revisit the checklist after significant product changes or incidents and keep improving.
Need help with a security review or to integrate security into your CI/CD pipeline? Check our Security & DevOps services or book a consultation.