Security Regression Testing
Purpose
Make security durable: every fixed vulnerability and every important threat becomes an automated test that fails if the protection is removed — so a refactor or new feature can't silently reopen a closed hole. The security counterpart to ../../testing/regression-testing.
When to Use
- After any security fix, and to encode threat-model mitigations as tests.
- As the enforcement arm of the security skills and
../../security-review.
- Not as a substitute for the review itself — it locks in what the review found.
Inputs
- Security findings + fixes (from the security skills), threat-model mitigations (
threat-modeling).
- Test infrastructure (
../../testing/api-integration-testing, ../../testing/integration-testing) with personas (../../testing/test-data-management).
Discovery Questions
- For each fixed vulnerability: what test fails on the vulnerable code and passes once fixed?
- Which threats are testable as negative tests (access denied, input rejected, abuse throttled)?
- Are the personas (user A/B, admin, other-tenant) available to express authorization negatives (
../../testing/test-data-management)?
Responsibilities
- Write a test per fixed vulnerability: reproduces the exploit against the vulnerable code (fails), passes after the fix — at the lowest level that captures it (
../../testing/regression-testing discipline, security-focused).
- Encode negative security tests for the standing threats:
- authorization: cross-user, non-admin→admin, client-supplied-ID-ignored, cross-tenant-rejected (
authorization-security, ../../backend/backend-integration-testing);
- injection/validation: malicious inputs (SQLi/NoSQL-operator/XSS payloads) rejected/encoded (
api-security, web-security);
- abuse: limits trip, CAPTCHA required on the right flows (
abuse-prevention);
- auth: tampered/expired/reused tokens rejected, enumeration resisted (
authentication-security).
- Enforce in CI: these tests run on every change (
../../devops/ci-cd) — a security test that isn't run guards nothing.
- Keep tests behavioral so they survive refactors and still catch reintroduction.
- Feed incident postmortems back into tests (
../../devops/incident-readiness) — every security incident leaves a regression test.
Required Workflow
- For each finding/mitigation, define the failing-first test + its level.
- Confirm each fails on vulnerable code, passes after fix.
- Add the standing negative-test suites (authz/injection/abuse/auth).
- Wire all into the CI-gated suite.
- Feed incident learnings back as new tests.
Decision Rules
- A security fix without a test invites its return — the test is part of the fix.
- Failing-first: a security regression test that passed before the fix proves nothing.
- Lowest capturing level (unit/integration/API) for speed and stability.
- Behavioral assertions over brittle snapshots, so refactors don't erase the guard.
Rules
- Every security fix lands with a failing-first regression test.
- Negative security tests run in CI, not on demand.
- Postmortem findings become tests.
Anti-Patterns
- Fixing a vulnerability with no test locking it closed.
- Security tests that never failed (prove nothing).
- Authorization "covered" by happy-path tests with no denial cases.
- A security suite that exists but isn't in CI.
- Incidents resolved with no regression test, inviting recurrence.
Validation Checklist
Definition of Done
Every fixed vulnerability and key threat guarded by a failing-first, behavioral security test — authorization, injection, abuse, and auth negatives included — running in CI so security regressions cannot silently return, with incidents feeding new tests.
Related Skills
../../testing/regression-testing, authorization-security, authentication-security, api-security, web-security, mobile-security, abuse-prevention, threat-modeling, ../../testing/api-integration-testing, ../../testing/test-data-management, ../../devops/ci-cd, ../../devops/incident-readiness, ../../security-review.
Related Knowledge
../../../knowledge/ (past vulnerabilities, threat mitigations).
Related References
../../../references/security/ (security test patterns, when populated).
Context Loading Guidance
- Requires: the findings/mitigations to encode, test infra + personas.
- Does not require: re-running the reviews, unrelated app code.
- May load:
../../testing/api-integration-testing, authorization-security.
- Stop when: failing-first tests + standing negatives are CI-gated.
Token Efficiency Guidance
The finding/threat → test table (level, failing-first, CI) is the artifact; one test per finding at the right level.
1---2name: security-regression-testing3description: Use to turn security findings and threats into automated tests that stay green — negative tests for authorization/injection/abuse, a test per fixed vulnerability, and CI enforcement so security regressions can't silently return. Security's regression discipline.4---56# Security Regression Testing78## Purpose910Make security durable: every fixed vulnerability and every important threat becomes an **automated test** that fails if the protection is removed — so a refactor or new feature can't silently reopen a closed hole. The security counterpart to `../../testing/regression-testing`.1112## When to Use1314- After any security fix, and to encode threat-model mitigations as tests.15- As the enforcement arm of the security skills and `../../security-review`.16- **Not** as a substitute for the review itself — it locks in what the review found.1718## Inputs1920- Security findings + fixes (from the security skills), threat-model mitigations (`threat-modeling`).21- Test infrastructure (`../../testing/api-integration-testing`, `../../testing/integration-testing`) with personas (`../../testing/test-data-management`).2223## Discovery Questions2425- For each fixed vulnerability: what test **fails on the vulnerable code** and passes once fixed?26- Which threats are testable as **negative tests** (access denied, input rejected, abuse throttled)?27- Are the personas (user A/B, admin, other-tenant) available to express authorization negatives (`../../testing/test-data-management`)?2829## Responsibilities3031- Write a **test per fixed vulnerability**: reproduces the exploit against the vulnerable code (fails), passes after the fix — at the lowest level that captures it (`../../testing/regression-testing` discipline, security-focused).32- Encode **negative security tests** for the standing threats:33 - **authorization**: cross-user, non-admin→admin, client-supplied-ID-ignored, cross-tenant-rejected (`authorization-security`, `../../backend/backend-integration-testing`);34 - **injection/validation**: malicious inputs (SQLi/NoSQL-operator/XSS payloads) rejected/encoded (`api-security`, `web-security`);35 - **abuse**: limits trip, CAPTCHA required on the right flows (`abuse-prevention`);36 - **auth**: tampered/expired/reused tokens rejected, enumeration resisted (`authentication-security`).37- **Enforce in CI**: these tests run on every change (`../../devops/ci-cd`) — a security test that isn't run guards nothing.38- Keep tests **behavioral** so they survive refactors and still catch reintroduction.39- Feed **incident postmortems** back into tests (`../../devops/incident-readiness`) — every security incident leaves a regression test.4041## Required Workflow42431. For each finding/mitigation, define the failing-first test + its level.442. Confirm each fails on vulnerable code, passes after fix.453. Add the standing negative-test suites (authz/injection/abuse/auth).464. Wire all into the CI-gated suite.475. Feed incident learnings back as new tests.4849## Decision Rules5051- A security fix without a test invites its return — the test is part of the fix.52- Failing-first: a security regression test that passed before the fix proves nothing.53- Lowest capturing level (unit/integration/API) for speed and stability.54- Behavioral assertions over brittle snapshots, so refactors don't erase the guard.5556## Rules5758- Every security fix lands with a failing-first regression test.59- Negative security tests run in CI, not on demand.60- Postmortem findings become tests.6162## Anti-Patterns6364- Fixing a vulnerability with no test locking it closed.65- Security tests that never failed (prove nothing).66- Authorization "covered" by happy-path tests with no denial cases.67- A security suite that exists but isn't in CI.68- Incidents resolved with no regression test, inviting recurrence.6970## Validation Checklist7172- [ ] A failing-first test per fixed vulnerability, at the right level.73- [ ] Standing negatives: authz, injection, abuse, auth.74- [ ] Behavioral assertions (refactor-durable).75- [ ] All wired into CI-gated suites.76- [ ] Postmortem findings encoded as tests.7778## Definition of Done7980Every fixed vulnerability and key threat guarded by a failing-first, behavioral security test — authorization, injection, abuse, and auth negatives included — running in CI so security regressions cannot silently return, with incidents feeding new tests.8182## Related Skills8384`../../testing/regression-testing`, `authorization-security`, `authentication-security`, `api-security`, `web-security`, `mobile-security`, `abuse-prevention`, `threat-modeling`, `../../testing/api-integration-testing`, `../../testing/test-data-management`, `../../devops/ci-cd`, `../../devops/incident-readiness`, `../../security-review`.8586## Related Knowledge8788`../../../knowledge/` (past vulnerabilities, threat mitigations).8990## Related References9192`../../../references/security/` (security test patterns, when populated).9394## Context Loading Guidance9596- **Requires:** the findings/mitigations to encode, test infra + personas.97- **Does not require:** re-running the reviews, unrelated app code.98- **May load:** `../../testing/api-integration-testing`, `authorization-security`.99- **Stop when:** failing-first tests + standing negatives are CI-gated.100101## Token Efficiency Guidance102103The finding/threat → test table (level, failing-first, CI) is the artifact; one test per finding at the right level.