Today’s Lesson
Security for Legal SaaS — Episode 52: Day Zero — Bootstrapping Security for a New Project
The Decisions You Make Before Writing Code
Day one is too late. The security posture of your legal SaaS platform is largely determined by decisions made before the first feature is built: which framework, which authentication library, which hosting provider, how secrets are stored, whether logging exists. These choices compound. A good foundation makes every subsequent security decision easier. A poor one creates debt that grows faster than feature code — because every feature built on an insecure foundation inherits its weaknesses.
OWASP's Secure by Design Framework formalises this principle: security controls should be embedded at the design phase, not bolted on after deployment.1 The framework's checklist covers trust boundaries (the points where data crosses from one trust level to another, as we introduced in Episode 1), encryption requirements, authentication and authorisation design, and incident readiness — all before a single line of application code is written.
For a legal tech team bootstrapping a new case management system, contract review tool, or e-filing platform, the question isn't "when do we add security?" It's "which security decisions do we make right now so we don't have to rewrite everything in six months?"
Tech Stack Choices with Security Implications
Your framework and library choices have security consequences that persist for the lifetime of the project.
| Decision | Secure Default | Insecure Default |
|---|---|---|
| Web framework | Frameworks with built-in CSRF protection, XSS escaping, and parameterised queries (Django, Rails, Next.js) | Minimal frameworks that leave all security to the developer (Express without middleware) |
| ORM vs raw SQL | ORM (Object-Relational Mapper — a library that generates database queries from code, as covered in Episode 7) with parameterised queries by default | Raw SQL string concatenation |
| Authentication | Established library (NextAuth, Passport.js, Django Auth) with MFA support | Hand-rolled authentication logic |
| Hosting provider | Provider with managed TLS, DDoS protection, and compliance certifications (SOC 2, ISO 27001) | Self-hosted on unmanaged infrastructure |
| Secrets management | Dedicated secrets manager (AWS Secrets Manager, HashiCorp Vault, as covered in Episode 30) | `.env` files committed to version control |
Framework defaults matter more than you think. Django auto-escapes template variables (preventing XSS — cross-site scripting, as covered in Episode 9), enables CSRF middleware by default, and uses parameterised queries through its ORM. A developer has to actively opt out of these protections. Express.js, by contrast, provides none of these by default — each must be added manually. The framework's opinion on security becomes your application's baseline.
The First-Commit Security Checklist
Before your first user, before your first feature branch, these controls must exist:
1. Repository Hygiene
`.gitignore` from commit one. Include `.env`, `.pem`, `.key`, `credentials.json`, and any framework-specific secret files. Secrets committed to Git history are nearly impossible to fully remove — even after deletion, they exist in the repository's history forever.
Pre-commit hooks. Install automated hooks (scripts that run before code is saved to version control) that scan for secrets. Tools like `git-secrets`, `detect-secrets`, or `trufflehog` catch API keys and credentials before they enter the repository. This is the safety net for human error.
Branch protection. Require pull request reviews before merging to the main branch. No direct pushes. This ensures at least one other person reviews every change — including changes to security-critical code.
2. HTTPS Everywhere
TLS (Transport Layer Security, as covered in Episode 13) must be active from the first deployment. Not "we'll add it before launch" — from the first time anyone accesses the application. Let's Encrypt provides free, automated certificates. Most modern hosting platforms (Vercel, Railway, Fly.io, AWS App Runner) provide TLS by default. There is no excuse for HTTP in 2026.
3. Authentication Library, Not Custom Code
Do not build your own authentication system. Use an established, well-audited library or service. For legal SaaS specifically, choose one that supports:
- Multi-factor authentication (as covered in Episode 21)
- OAuth 2.0 / OpenID Connect for enterprise SSO (as covered in Episode 20)
- Session management with proper expiry and re-keying (as covered in Episode 19)
- Audit logging of all authentication events
4. Secrets Manager from Day One
Never store secrets in code, configuration files, or environment variables committed to version control. Use a secrets manager — a dedicated service that stores, rotates, and provides access-controlled access to sensitive values. Set this up before you have secrets to store, so there's never a temptation to "just put it in `.env` for now."
5. Structured Logging
Configure structured logging (logs in a consistent, machine-readable format like JSON) from the start. Log authentication events, authorisation decisions, data access patterns, and errors. Not for debugging — for security. When (not if) you need to investigate an incident, logs are the evidence. OWASP's Logging Cheat Sheet provides detailed guidance on what to log and what not to log (never log passwords, tokens, or full credit card numbers).2
6. Dependency Scanning in CI
Add dependency scanning to your CI/CD pipeline (the automated system that builds and deploys your code, as we covered in Episode 46) from the first pull request. Tools like `npm audit`, `pip audit`, Snyk, or Dependabot continuously check your dependencies for known vulnerabilities. OWASP's Software Composition Analysis (SCA) project provides open-source options.3
The Minimum Viable Security Posture
What must exist before your first user accesses the system?
| Control | Why It Can't Wait |
|---|---|
| HTTPS / TLS | Data in transit is readable without it; compliance requirement for any platform handling PII |
| Authentication with MFA | Single-factor auth on a platform storing client legal matters is a breach waiting to happen |
| Role-based access control | Without it, every user has the same permissions — including access to other clients' data |
| Input validation on all endpoints | First external request without validation is the first potential injection |
| Secrets in a secrets manager | First committed secret is a secret you'll spend days trying to remove from Git history |
| Automated dependency scanning | First unscanned dependency is a potential known-vulnerability in your supply chain |
| Structured security logging | First incident without logs is an incident you can't investigate |
The legal standard: NYC Bar Formal Opinion 2024-3 clarified that lawyers' ethical obligations regarding cybersecurity extend to the technology platforms they choose. Selecting a platform that lacks basic security controls — or building one without them — is not a defensible "reasonable efforts" position under ABA Model Rule 1.6(c).4
Security Debt Compounds Faster Than Technical Debt
Technical debt — shortcuts in code quality that slow future development — is well understood. Security debt is worse. Every day a vulnerability exists in production is a day it can be exploited. And unlike technical debt, where the cost is developer time, security debt can cost you your clients' data, your professional obligations, and your business.
Consider a concrete example. Your team builds a case management system. On day one, authentication is username/password only, stored in a single database table. Six months later, a law firm customer asks for SSO integration with their Azure AD. You discover that your authentication system is so tightly coupled to the rest of the application that adding SSO requires rewriting the login flow, the session management, the permission checks, and the audit logging. A three-day integration becomes a three-month rewrite.
If you'd started with an authentication library that supported SSO from day one, the integration would have been configuration, not architecture.
OWASP SAMM (Software Assurance Maturity Model) provides a structured framework for measuring and improving your security posture over time, with maturity levels that scale from "getting started" to "optimised."5 Starting at Level 1 on day zero is realistic. Starting at Level 0 and trying to catch up later is where projects fail.
The Day-Zero Mindset
Bootstrapping security doesn't mean building a fortress before writing features. It means making choices that don't foreclose security later:
- Choose frameworks with secure defaults — so developers fall into the safe path
- Set up secret management before you have secrets — so there's no "temporary" plaintext
- Install pre-commit hooks before the first commit — so secrets never enter history
- Add dependency scanning before the first dependency — so nothing slips through unchecked
- Configure logging before the first user — so the evidence exists when you need it
- Pick an auth library that supports MFA and SSO — so you don't rewrite login in six months
The decisions you make before writing code determine how hard everything else will be. Make them well.
Next episode: we shift from building to watching — monitoring and alerting design for detecting attacks in progress.
Sources & references
- OWASP, Secure by Design Framework.
- OWASP, Logging Cheat Sheet.
- OWASP, Dependency-Check: Software Composition Analysis.
- NYC Bar Association, Formal Opinion 2024-3: Ethical Obligations Relating to a Cybersecurity Incident.
- OWASP, Software Assurance Maturity Model (SAMM).
- OWASP, Establishing a Modern Application Security Program — OWASP Top 10:2025.
- OWASP, Secure Development and Integration — Developer Guide.
- OWASP, OWASP in SDLC — Integration Standards.
- ABA, Cybersecurity for Law Firms: ABA Compliance Guide.
- NIST, SP 800-218: Secure Software Development Framework.