Threat-Led API Security Testing: Threat Models, Semgrep, ZAP, Schemathesis and Fixes That Stay Fixed

Take the role of the application security engineer who replaces an annual review with threat-led testing for a multi-tenant claims API: a STRIDE threat model kept as code and tied to tests, custom Semgrep rules, authenticated ZAP scans and Schemathesis fuzzing from the OpenAPI description, abuse-case tests for the OWASP API Top 10, and a security gate that proves ten seeded flaws are caught.

Application Security Engineer. Advanced.

What you will build and explain

  • Model a multi-tenant API's data flows, trust boundaries and STRIDE threats as code, and tie each threat to its mitigation and the checks that prove it.
  • Find and fix the OWASP API Security Top 10 in real code: broken object, property and function level authorization, broken authentication, SSRF, misconfiguration and inventory, plus injection and path traversal.
  • Write custom Semgrep taint and structural rules with their own tests, and explain what single-function analysis cannot see.
  • Run authenticated OWASP ZAP and Schemathesis scans from the OpenAPI description, and read their alerts and failures.
  • Build a security gate with a detection matrix that shows which check catches which flaw, and a risk register whose acceptances expire.

Before you begin

  • Reading and writing Python 3, calling an HTTP API with curl, reading SQL, using Git to apply a patch, and running services with Docker Compose. Threat modelling, the OWASP API Security Top 10, Semgrep, ZAP, Schemathesis, OSV-Scanner and Gitleaks are taught
  • A machine with Docker Engine 27 or later with Compose v2, 4 CPUs, 8 GB of free memory and about 6 GB of disk, plus Git, bash, curl and jq; no cloud account is needed

Who this is for

For backend engineers and application security engineers who read Python, call HTTP APIs with curl, read SQL and run Docker Compose, and want to replace a once-a-year review with threat-led testing: a threat model kept as code and tied to its checks, the project's own Semgrep rules, authenticated ZAP and Schemathesis scans from the OpenAPI description, abuse-case tests that know who may do what, and a gate that measures which check catches which seeded flaw.

Curriculum

Learning topics (17)
  1. Read the security lead's notes and prepare a machine that can run the lab

    Calder Claims' security lead hands you a page of notes from the past year. A broker changed a number in a URL and read another firm's client's claim. A penetration tester added one field to an update and set a payout. A researcher made the document import fetch the cloud metadata address and read the server's credentials. A version-0 endpoint, retired a year earlier, still answered without authentication. And the annual review found the same classes of bug again, with nobody

  2. Follow a request through the claims API and a change through the security gate

    Calder Claims' security lead keeps a list of the year's incidents. Each one was found by a customer, a penetration tester or a researcher; none was found by anything the team runs. This page explains the system built in answer, as one design: a small multi-tenant claims API with the controls those incidents lacked, a threat model that names every threat and the check that proves its control, and a security gate that runs those checks on every change. The diagrams are the ones

  3. Data flows, trust boundaries and STRIDE, kept as code and tied to tests

    The last line of the security lead's notes is the one this lesson answers: the annual review found the same classes of bug again, and nobody could say which test protects against which threat. A threat model is the list that answers that question. Most teams have one somewhere, drawn in a workshop and never opened again, so it describes the system as it was the week it was drawn. This lesson builds one that cannot fall behind the code without a test failing. By the end you ca

  4. Passwords, JWTs and brute force: what a token must prove

    Every other control in the API trusts one thing: the identity in the caller's token. If a token can be forged, altered or replayed after it should have expired, the firm filter filters by the attacker's chosen firm and the role check admits the attacker's chosen role. This lesson covers the three threats at the start of that chain: a password guessed by repetition (T02), responses that reveal which usernames exist (T03), and a token accepted without proof (T01). By the end yo

  5. Whose claim is it? Object, property and function level authorization

    Three incidents in the security lead's notes had a correctly signed-in user doing something they should not: a broker read another firm's claim by changing a number, a penetration tester set a payout by adding a field, and (in the threat model, if not yet in the notes) a broker could call a route meant for adjusters. The OWASP API Security Top 10 puts these first, third and fifth: broken object level authorization (BOLA, API1), broken object property level authorization (API3

  6. When request text becomes SQL or a file path

    Two routes take free text from a broker and hand it to something powerful: the claim search passes a search string to PostgreSQL, and the statement download passes a file name to the file system. Both cross the second trust boundary, from the API to its data, and both fail the same way when the text is allowed to become part of the instruction instead of staying data. This lesson covers SQL injection (T07) and path traversal (T08): what goes wrong, the two-layer fix each rout

  7. A document import that must never reach the metadata service

    A broker attaches a repair estimate by giving its URL; the API fetches it and shows a preview. In the incident, a researcher gave it http://169.254.169.254/latest/meta-data/iam/security-credentials/ instead, and the preview showed the server's cloud credentials. That is server-side request forgery (SSRF, API7): the attacker cannot reach the internal address, but the server can, and the server will fetch whatever it is asked. This lesson explains why the metadata service is th

  8. Writing, testing and trusting custom Semgrep rules

    Three of the incidents had a recognisable shape in code: a token decoded without verification, a URL from a request handed to an HTTP client, a route with no authentication. A reviewer who knows the shape can spot it in a diff; a rule can spot it in every diff, before anything runs. This lesson teaches Semgrep, a static analyser that matches code by its structure, through the seven rules written for this API. By the end you can read and write a structural rule and a taint rul

  9. An authenticated ZAP scan driven by the OpenAPI description

    Semgrep reads code and never sees the running API. A dynamic application security test (DAST) does the opposite: it sends requests to the running API, the way an attacker would, and judges the answers. It sees what static analysis cannot, the effect of configuration, middleware and the database together, and misses what it never reaches. This lesson configures OWASP ZAP to scan the claims API as a signed-in broker, explains what its alerts mean, and shows the one check every

  10. Schemathesis: properties, stateful sequences and ignored authentication

    ZAP attacks parameters with known payloads. Schemathesis asks a different question: does the API behave the way its own description says it does, for any input the description allows and many it forbids? It reads /openapi.json, generates thousands of requests, and checks every answer against the description. That catches server errors, undocumented answers, input the API accepts but should not, and, with two identities, one user reading another's objects. This lesson explains

  11. Known-vulnerable packages and committed secrets

    The threat model's fourth boundary is not a network path. It is the change that gets built: the code, the packages it pulls in, and anything that should never have been in the repository at all. Two threats live there: a dependency with a published vulnerability is shipped (T15), and a secret is committed with the code (T16). Neither is caught by tests of the API's behaviour, because neither changes what the API does until someone exploits it. This lesson covers pinning, OSV-

  12. One gate, a detection matrix and a risk register with expiry dates

    Each lesson so far added a check. On its own, each check is an opinion: a test that passed, a scanner that found nothing. A gate turns the opinions into a decision, the same way every time, and records why. This lesson explains the gate's design (the order of its stages, why a failure does not stop it, and the one way to accept a finding), then the detection matrix, which measures what each check can actually see by breaking the code on purpose ten times.

  13. From a lab to a programme: identity providers, gateways and keeping the model alive

    The lab is deliberately small: one API that issues its own tokens, one database, one partner, a gate you run by hand. A real claims platform has an identity provider, several services, a gateway in front, a CI system, monitoring and people on call. This lesson goes through what changes on the way there, control by control, and what stays the same. None of it is built in this project; it is the reasoning you would bring to a design review, and to an interview.

  14. Run the lab from an empty Docker machine to the detection matrix

    This runbook takes the lab from a machine with Docker and nothing else to a gate run on the fixed API, a seeded flaw caught, and the detection matrix that shows which check catches which flaw. Cleanup then removes everything it created. Every command runs on your own machine; nothing here touches a cloud account and nothing is billed. Each section says what exists before it, what it creates, where the command runs, what a good result looks like and what to check when yours di

  15. Reason from a failing stage to the control behind it

    Most problems in this project show up as a stage that fails, or one that passes when it should not. The scenarios are written as an interviewer would pose them: a symptom, what was observed, and "what would you check?" This page is how to practise them.

  16. Explain the threat model, the controls and what each check can see

    The questions cover the whole project: the architecture and threat model, authentication and authorization, injection, traversal and SSRF, the testing tools, and running the gate as a programme. Each has a model answer grounded in this project, and a follow-up that changes a constraint.

  17. Remove the lab and check nothing is left

    The lab is a handful of containers, four Docker networks, two volumes, four images it built, and the files it wrote into your copy of the source. This page removes the Docker resources completely, keeps the files until you decide, and ends with a check that exits 0 only when nothing named or labelled atlst remains. Nothing here is billed, and nothing outside Docker on your machine is touched. You can run it at any point, including after a failed or interrupted milestone.

Practical build steps (7)
  1. Prepare the machine and the secrets

    Nothing runs yet. This milestone checks that Docker can carry the lab and the scanners beside it, and creates the one file the whole lab depends on: .lab/lab.env, with the key that signs tokens, the database passwords and a password for each of the five lab users.

  2. Run the local checks

    Before anything listens on a port, check the code: the API's unit tests against a throwaway database, the tests that keep the threat model and the register honest, the Semgrep rules against their own test cases, and lint. None of it starts the lab.

  3. Start the lab and call it as each role

    The lab starts: PostgreSQL, the seed and certificate jobs, the claims API, the partner host and the fake metadata service. Then you call the API yourself, as a broker and as an adjuster, and watch each control answer before any scanner does.

  4. Run the security gate on the fixed API

    The gate is the check every change must pass: eight stages, one summary. This milestone runs it on the fixed API, where every stage should pass, and shows where to look in the run folder.

  5. Seed a flaw and read what caught it

    Each flaw is a patch that re-introduces one bug from the incident list. This milestone applies one to a copy of the source, runs the gate there, and reads which stages caught it and why the others did not.

  6. Build the detection matrix

    The matrix runs the gate on the fixed API and once per flaw, and writes one table: which stage caught which flaw. It turns "we run five scanners" into a statement you can check.

  7. Remove the lab

    Everything the lab created in Docker goes, by name, and a final check proves it. Your secrets and evidence stay until you delete them.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

This project runs entirely in Docker Compose on your own machine: the claims API, PostgreSQL, two internal lab services and the scanning tools. It creates no cloud resources and costs nothing beyond your machine and network; pulling the images downloads about 6 GB. Every attack in the exercises targets the lab's own services, and the cloud metadata service it protects is a fake that returns invented values. Calder Claims, its firms, users and claims are fictional and synthetic. This is a learning reference, not a hosted service or a production deployment.

Licence and completion

Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. Third-party components, such as FastAPI, Semgrep, ZAP, Schemathesis, OSV-Scanner and Gitleaks, retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.

Can I read the code with Learning Access?

Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.

Are cloud charges included?

No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.

Does the project include troubleshooting and interview preparation?

The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.

How long can I use the project?

The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy