Chapters & contents Lesson 20 of 20
3 min read
Defensive security foundationsExpanded reading

Draw the boundary before adding a security control

Protect a progress API by separating identity, permission, and untrusted input.

What you’ll learn

  • Distinguish authentication from authorization
  • Trace an ownership check for a learner record
  • Convert a threat assumption into a verifiable control

Name the assets and actors

For a learning platform, public lessons and private progress records have different protection needs. List what matters: account identifiers, session credentials, progress updates, contributor edits, and service availability. Then list the actors and components that handle them, such as a browser, an account API, a database, and an identity provider. Draw where data crosses from one component’s control into another. A threat model begins with a concrete system and its assumptions, rather than a shopping list of security products.

Identity does not grant every permission

Authentication establishes the identity associated with a request under a chosen mechanism. Authorization decides whether that identity may perform a particular action on a particular resource. A signed-in learner should be able to read their own private progress, but not another learner’s progress merely by changing an identifier in a URL. Hiding the identifier in the interface does not enforce this rule. The service receiving the request must make the access decision using trusted session information and the actual resource relationship.

Trace a request with a changed identifier

Suppose Mira’s authenticated session belongs to account 17. Her browser requests /api/progress/29. If the endpoint trusts the path identifier alone, it may expose account 29. Instead, derive the requester identity from the validated session and require an explicit rule allowing the requested operation. A self-progress endpoint can avoid accepting an arbitrary account identifier at all. Administrators, if supported, need separately defined privileges and auditability. Test the denied case with two controlled accounts, not with real strangers’ data.

Match each control to a threat

Input validation can reject an impossible lesson identifier, but it does not replace authorization. Transport encryption protects data in transit, but it does not repair an overly privileged database credential. Parameterized queries address a different boundary from HTML output encoding. For each identified threat, record the control, the component that enforces it, and a test or review that checks it. Prefer narrowly scoped service credentials and deny access when the system cannot establish the required permission. Avoid exposing internal diagnostics or secrets through user-facing errors.

Keep the model alive as the product changes

Adding file uploads, third-party embeds, or an AI assistant introduces new data paths and assumptions. Revisit the diagram when those capabilities arrive. Keep security tests focused on meaningful boundaries: no session, expired session, another account’s resource, a malformed identifier, and a permitted request. Log enough to investigate denied operations without recording tokens or private lesson notes unnecessarily. A small model that matches the deployed system and receives regular updates is more useful than a large document nobody can relate to the current code.

Try it yourself

A progress API validates that accountId is a positive integer and requires Google sign-in, but accepts any accountId from the browser. Explain the missing control and give a two-account test.

Show a possible solution

The endpoint is missing authorization tying the authenticated identity to the requested account. Sign in as controlled account A, request controlled account B’s private progress, and require denial without exposing B’s data; then verify A can read its own progress.

Check your understanding

Try 14 questions across defensive security foundations. Read each explanation and revisit anything that needs another pass.

Practise this subject

Go to the source

Use these primary references to check details and explore the topic further.

Saved in this browser. Signed-in progress syncs to your account.