Threat Modeling with STRIDE
How to run a lightweight STRIDE threat model before writing code, with a data-flow diagram and worked example for this static site, localStorage, and its RSS inbox workflow.
TL;DR
STRIDE (Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege) is a 30-minute design check before writing code. Draw a data-flow diagram (DFD), mark trust boundaries, and ask what can go wrong at each crossing.
Why it exists
Most severe flaws (A06:2025 Insecure Design) cannot be fixed by a linter—they are missing controls at design time. A lightweight threat model before building a feature catches trust-boundary bugs while they are still cheap to change on a whiteboard.
1. What are we building? (Worked DFD: Mengty Learns)
Mengty Learns has two distinct data flows:
- Reader flow: Visitor browser loads static HTML/JS from CDN/Pages and stores flashcard/quiz progress in
localStorage(mt-*-v1). - Inbox flow (
.github/workflows/inbox.yml): A scheduled GitHub Action fetches external RSS feeds viascripts/inbox.mjsand writes a private GitHub Issue (permissions: issues: write).
2. What can go wrong? (STRIDE on this site)
| Threat | Example on this site | Mitigation |
|---|---|---|
| Spoofing | Spoofed CDN origin or fake GitHub Action dependency. | HTTPS + HSTS at edge; pin GitHub Actions to full 40-char SHAs (supply-chain). |
| Tampering | User edits localStorage (mt-*-v1); malicious RSS <title> injects markdown/links into the inbox issue. | localStorage holds only personal study state (no auth/trust); sanitize/truncate RSS fields and never auto-publish inbox.yml output. |
| Repudiation | Unclear who changed security-critical content or workflows. | Signed/reviewed PRs on main and Git commit history. |
| Information Disclosure | Accidental NEXT_PUBLIC_* secret or private inbox/*.json published in out/. | Keep inbox.yml writing to GitHub Issues (not public/); never put secrets in client bundles. |
| Denial of Service | Oversized RSS feed hangs inbox.mjs in CI; huge SVG/diagram stalls browser. | Fetch timeouts + size bounds in inbox.mjs; build-time diagram node/step caps (DIAGRAM-RULES). |
| Elevation of Privilege | Compromised inbox.yml token pushes code to main. | inbox.yml sets permissions: issues: write only—it cannot write repository contents. |
Do it: 4-step threat model in 30 minutes
- Draw the DFD: Boxes for processes/stores/externals, arrows for data flows, dashed lines for trust boundaries.
- Walk each boundary with STRIDE: Spend 5 minutes per crossing—skip categories that don't apply.
- Decide mitigations: Mitigate, accept (document why), transfer, or eliminate (for example, keeping this site static eliminates server auth threats entirely).
- Verify in PRs: Turn the top 2–3 mitigations into automated tests, CI permission checks, or checklist items.
Gotchas
- Threat modeling after launch: Waiting until a pen test turns architectural flaws into expensive rewrites.
- Listing generic threats ("someone hacks the DB"): Always tie each STRIDE item to a specific DFD edge and trust boundary.
- Forgetting
localStorageis attacker-controlled: Never trustlocalStoragevalues for authorization or render raw strings fromlocalStorageintoinnerHTML.
Production checklist
- Every new feature with a new trust boundary (auth, upload, webhook, external fetch) gets a 30-minute STRIDE review.
- All external inputs (RSS feeds, user URLs,
localStorageJSON) are validated/sanitized at the boundary. - CI workflows declare minimal
permissions:so a compromised job cannot escalate privileges. - Accepted risks are recorded in an ADR or design doc with owner and date.
Check yourself
Check Yourself
1. In STRIDE, which threat category is mitigated by setting permissions: issues: write (and not contents: write) on .github/workflows/inbox.yml?
2. Why is 'Tampering with localStorage' low-impact for Mengty Learns' flashcard progress, yet critical if an app stores role='admin' in localStorage?
Sources
Related Notes
OWASP ASVS 5.0 Overview
What OWASP ASVS 5.0 is, how L1–L3 levels work, all 17 chapters in one line each, and how to scope it on a real static site.
Authentication vs Authorization (RBAC, ABAC, ReBAC & BOLA)
How authentication and authorization differ, how RBAC, ABAC, and ReBAC model permissions, and how to prevent Broken Object-Level Authorization (BOLA).