Catalog My learning Blog
Full-Stack Developer Course: React, .NET and SQL Server · Phase 5 · Lesson 41 · 7 min read

STRIDE Threat Modeling for React and .NET Apps

On this page
  1. Learning Objective
  2. Concept Explanation
  3. Worked Example: Threat Modeling the Invite Member Feature
  4. Real-World Examples
  5. Review Questions & Answers

Learning Objective

Draw the trust boundaries of a React, API and database system, apply the STRIDE categories to each boundary crossing, record threats with concrete mitigations and owners, and use a lightweight threat model to decide what security work to do first.

Concept Explanation

Security work without a model tends to be either a checklist copied from a blog post or a panic after an incident. Threat modeling is the habit of asking four questions in order: what are we building, what can go wrong, what are we going to do about it, and did we do a good enough job. It does not need special tools or a security background. A whiteboard sketch of the system and thirty focused minutes at the start of each significant feature find design flaws that no scanner will ever detect, because the flaw is in the design, such as a missing ownership check or a token stored in the wrong place, not in a line of code.

Start with a data flow sketch. Draw the actors, such as an anonymous visitor, a signed-in user, an administrator, and a background job. Draw the components: the React app in the browser, the API, the SQL Server database, the identity provider, and any third-party service such as email or payments. Draw arrows for the data flows between them, and then draw trust boundaries, the lines where the level of trust changes. The browser boundary is the most important: everything on the far side of it is controlled by the user, including the React code they are running. Every arrow that crosses a boundary is a place where something can go wrong and where a control is needed.

STRIDE is a mnemonic that keeps you from forgetting categories of threat. Spoofing is pretending to be someone else, addressed by authentication. Tampering is modifying data in transit or at rest, addressed by integrity controls such as TLS, signatures, and constraints. Repudiation is denying an action took place, addressed by audit logs. Information disclosure is leaking data, addressed by authorization, encryption, and careful responses. Denial of service is making the system unavailable, addressed by rate limits, quotas, and timeouts. Elevation of privilege is gaining rights you should not have, addressed by authorization checks and least privilege. For each boundary-crossing flow, walk through the six letters and write down what applies. Most will be quickly dismissed, and a few will be uncomfortable discoveries.

Record each threat in a simple register with the threat, the affected asset, the mitigation, the status, and an owner, then rank by likelihood and impact so effort goes to the top of the list. Mitigations should point to concrete work: a lesson in this course, a ticket, a test. Then keep it alive, revisiting the model when the design changes, for instance when you add file uploads, a new integration, or a public API. The artifact matters less than the conversation, which is why teams that review a feature's threat model together find gaps that individuals miss. Later lessons in this phase implement most of the mitigations you will list.

STRIDE letterThreatExample in this stackTypical control
SpoofingPretending to be a userStolen session cookie or JWTStrong authentication, MFA, short lifetimes
TamperingChanging dataEdited request body, altered priceServer-side validation, TLS, DB constraints
RepudiationDenying an actionUser denies deleting a projectAudit log with identity and time
Information disclosureLeaking dataFetching another user's note by idObject-level authorization, DTOs, generic errors
Denial of serviceExhausting resourcesUnbounded page size, huge uploadsRate limits, size limits, timeouts
Elevation of privilegeGaining rightsSetting isAdmin through mass assignmentAuthorization policies, least privilege

Worked Example: Threat Modeling the Invite Member Feature

Suppose the Task Board adds a feature where a project admin invites a colleague by email, the colleague follows a link, and joins the project. The flow is React to API to database, plus an email service and a link that is clicked from an inbox. The register below is the output of thirty minutes of STRIDE applied to that flow.

Code
Flow: Admin (browser) -> API: POST /api/projects/{id}/invitations {email, role}
      API -> DB: store invitation (tokenHash, expiresAt, role)
      API -> Email service: send link https://app.example.com/join?token=...
      Invitee (browser) -> API: POST /api/invitations/accept {token}

Trust boundaries: browser | API | database | email provider | invitee's inbox

ID  STRIDE  Threat                                             Mitigation                                           Status
T1  S       Attacker guesses or brute-forces an invite token   256-bit random token, hash stored, rate limit        Planned
T2  T       Invitee edits role in the accept request           Role is read from the stored invitation, not body    Planned
T3  E       Non-admin member invites others as admin           Policy: only project admins may invite; cap role     Planned
T4  I       Response reveals whether an email has an account   Same response for all emails, send mail either way   Planned
T5  I       Token appears in logs or Referer header            POST body not URL for accept, referrer policy        Planned
T6  D       Attacker floods the invite endpoint to spam mail   Per-user and per-project rate limit, daily quota     Planned
T7  R       Admin denies sending an invitation                 Audit log: actor, project, email hash, timestamp     Planned
T8  S       Reused or stolen link lets a stranger join         Single use, 7 day expiry, bound to invited email     Planned
C#
// The register drives tests, not just a document. Each threat becomes an assertion.
[Fact] public async Task T3_non_admin_cannot_invite() =>
    Assert.Equal(HttpStatusCode.Forbidden, (await MemberClient.PostAsJsonAsync($"/api/projects/{Id}/invitations", Invite("x@y.z", role: "admin"))).StatusCode);

[Fact] public async Task T2_role_comes_from_the_invitation_not_the_request() { /* send role=admin in accept body, assert membership role is the invited role */ }

[Fact] public async Task T8_token_is_single_use() { /* accept twice, second returns 400 or 410 */ }

[Fact] public async Task T4_unknown_and_known_emails_get_identical_responses() { /* compare status and body */ }

The most useful outcome is often a design change made before writing code. Here T4 and T8 changed the design: the token is bound to the invited email address, and the endpoint's response does not depend on whether an account exists. Fixing either after release would have meant a breaking change.

An admin invites a colleague. Each flow that crosses a trust boundary is walked through STRIDE, and each threat gets a concrete mitigation such as hashed random tokens, role read from the stored invitation, single use, and identical responses.
An admin invites a colleague. Each flow that crosses a trust boundary is walked through STRIDE, and each threat gets a concrete mitigation such as hashed random tokens, role read from the stored invitation, single use, and identical responses.

Real-World Examples

  • STRIDE was developed at Microsoft in the late 1990s by Loren Kohnfelder and Praerit Garg and became a core technique of the Microsoft Security Development Lifecycle, which the company introduced in 2004 after a series of high-profile worms. The categories have proved durable because they are simple enough to apply during a design meeting and broad enough to cover most classes of flaw.
  • In 2020 a group of practitioners published the Threat Modeling Manifesto, stating values such as doing threat modeling early and continuously, and prioritizing a culture of finding and fixing over checkbox compliance. OWASP maintains free tools, such as Threat Dragon, and cheat sheets that make it practical for small teams without a dedicated security staff.
Key TakeawaysThreat modeling is asking what can go wrong with a feature before writing the code, while the fixes are still cheap and the design can still change. Sketch the data flows and trust boundaries, walk each boundary-crossing flow through STRIDE, record threats with concrete mitigations, turn the important ones into tests, and revisit the model whenever the design changes.

Review Questions & Answers

Everything running in the browser, including your own JavaScript, is controlled by the user or by anyone who has compromised their machine or injected script into your page. The server therefore cannot rely on any client-side check, value, or identity claim. Every request crossing that boundary must be authenticated, authorized, and validated as if it came from an attacker.

It turns a vague question, is this secure, into six specific questions to ask about each data flow. Even without deep expertise, walking through spoofing, tampering, repudiation, disclosure, denial of service, and elevation of privilege surfaces common issues such as missing ownership checks, unbounded requests, and absent audit trails. The structure compensates for the lack of a specialist's intuition.

Each entry names a concrete mitigation, an owner, and a status, and the important ones link to tests or tickets so they are verified continuously. It is reviewed when the design changes, and it is used to prioritize work. A register that nobody updates or ties to actual tests quickly becomes outdated and stops reflecting the system.

The threats of guessable, reusable, and forwardable tokens and of account enumeration come from the shape of the flow. Solving them required binding the token to the invited email, making it single use and expiring, and returning identical responses regardless of whether an account exists. Those are decisions about the contract and data model, so it is far cheaper to make them before implementation.