LESSON 8

Security Testing

Design and run security tests within clear authorization: security test cases from threats, authorization and tenant isolation tests, input and abuse testing, API and AI-integration tests, penetration testing and fuzzing, and regression protection.

Introduction

A control that has never been tested is an assumption. The threat model says that one customer cannot read another’s data; the architecture says that a central layer enforces it; a review found no gaps. But has anyone actually tried to read another tenant’s record with a valid account of their own? Security testing replaces belief with evidence.

This lesson covers how to design security tests from the threat model, which kinds of testing to use, how to run them safely and within authorization, and how to keep the results as permanent regression protection.

Learning Objectives

  • Derive security test cases from threats, requirements, and abuse cases.
  • Write authorization and tenant isolation tests.
  • Test input handling, authentication, sessions, and resource limits.
  • Test APIs and AI-integration behavior, including prompt injection.
  • Explain penetration testing, fuzzing, and when to use each.
  • Define authorization, scope, and rules of engagement for testing.
  • Automate security tests as regression tests and report results honestly.
  • Use AI to design tests while keeping the work defensive and in scope.

1. Security Testing Is Negative Testing

Functional tests check that allowed things work. Security tests check that forbidden things fail. They typically:

  • Authenticate as a legitimate but limited user, then try to exceed their permissions.
  • Send input the developer did not expect.
  • Skip, repeat, or reorder steps.
  • Apply load, size, or rate beyond normal.
  • Check that failures are safe and leave a trace.

A useful habit is to attach a security test to every high-rated threat in the register. For each threat, ask: what request or action would show that the mitigation works, and what result would show that it does not?

2. Rules of Engagement First

Testing for weaknesses uses the same techniques as attacking. Make the line clear:

  • Authorization. Written permission from the system owner for the specific systems, environments, and methods. Never test systems you do not own or have permission to test, including third-party services such as the model provider (their terms usually forbid it).
  • Environment. Test in staging or a dedicated test environment. Production testing, if ever allowed, is limited, agreed, and monitored.
  • Data. Synthetic or anonymized test data only; no real customer data.
  • Scope. The components, accounts, and techniques included; the list of what is excluded (denial-of-service tests, social engineering, physical access, third-party systems).
  • Safety. Limits on volume and rate; a contact person; a way to stop immediately; backups before destructive tests; notification of anyone who watches the logs so the test is not mistaken for an attack.
  • Handling findings. Sensitive results are shared only with the people who need them, and vulnerabilities in third-party products are reported to their owners using their disclosure process.

Record these in a short test authorization document before starting. Tests that find a serious issue should pause and escalate, not push further than needed to prove the point.

3. Authorization and Tenant Isolation Tests

These deserve the most attention because broken access control is both common and severe. Use a matrix:

Actor Own tenant, allowed Own tenant, above role Other tenant Unauthenticated
Member Allowed Refused Refused Refused
Admin Allowed Allowed Refused Refused
Other tenant’s admin Refused Refused Allowed (in their own) Refused

Apply the matrix to every endpoint and every kind of access: reading, creating, updating, deleting, listing, searching, exporting, downloading files, bulk actions, and background jobs. For each endpoint, test:

  • Another tenant’s identifier (change a record ID in a path, body, or query).
  • A missing, malformed, or nonexistent identifier (the response should not distinguish “exists elsewhere” from “does not exist” where that leaks information).
  • A lower-privileged role calling an administrative action.
  • A request with a tampered tenant or role value in the body or token claims.
  • An expired, revoked, or malformed token.
  • Lists and searches: does a result set include other tenants’ records, counts, or names?

The tests should run in the pipeline with two seeded tenants. A test of the form “tenant A requests tenant B’s export and expects a refusal” is cheap, fast, and catches the most expensive class of defect. Make them generated from the endpoint list where possible, so a new endpoint without an authorization test is flagged.

Do not forget indirect paths: caches, search indexes, queue messages, file storage URLs, logs, and exports. A tenant-isolation test that exercises only the main API leaves these open.

4. Input and Abuse Tests

Test the behavior at each boundary:

  • Type, size, and format. Oversized fields, wrong types, missing fields, extra fields, unusual encodings, very long strings, empty values.
  • Injection patterns. Input containing characters meaningful to databases, commands, templates, and markup; the application should treat them as data and display them safely.
  • File uploads. Wrong file type or extension, mismatched content, oversized files, files with extremely many rows, compressed files that expand enormously, files with spreadsheet formulas in cells (which could execute when someone opens an export), files with unusual encodings.
  • URLs and redirects. If the server fetches or redirects to a user-supplied address, test that internal addresses and unexpected schemes are refused.
  • Business logic. Repeat a request, send steps out of order, send two conflicting requests at once, use an invitation or reset link twice or after expiry, change a plan or price field.
  • Rate and resource limits. Many requests quickly, many large uploads, many model calls; confirm limits, quotas, and meaningful error messages.

Each test states the expected safe outcome: rejected with a clear error, stored and displayed encoded, truncated, queued with a limit, and so on.

5. Authentication, Session, and Configuration Tests

  • Sign-in: repeated failures trigger throttling or lockout; error messages do not reveal whether an account exists; multi-factor authentication cannot be bypassed by skipping a step.
  • Sessions: tokens expire; sign-out and password change invalidate sessions; cookies carry protective attributes; tokens are not exposed in URLs or logs.
  • Recovery: reset links are single-use, short-lived, and rate-limited.
  • Transport and headers: only encrypted connections; modern protocol versions; security headers present; cross-origin rules as intended.
  • Error handling: errors do not expose stack traces, queries, or paths.
  • Configuration: debug endpoints, default accounts, open management ports, and directory listings are absent from deployed environments (a DAST baseline checks some of these).
  • Secrets: no secrets in responses, client-side bundles, container images, or logs (search outputs for known token patterns).

6. Testing the AI Integration

SignalDesk’s summary feature has its own test set, because it processes text from untrusted sources.

Test Expected safe behavior
Prompt injection in uploaded content: feedback text that tells the model to ignore its instructions, reveal its prompt, or include specific text Summary still follows the task; the injected text is treated as data; output has no extra capabilities or hidden content
Instruction extraction: attempts to make the model reveal system instructions or other users’ content No other tenant’s data is ever in the request; internal instructions do not contain secrets
Unsafe output rendering: model output containing markup, links, or scripts Output is encoded or sanitized before display; links are restricted
Output-triggered actions: output containing commands or API-like text Nothing executes; no action is taken without validation and authorization
Oversized or abusive input Truncation, limits, and quotas apply; cost stays within budget
Provider failure or slow response Graceful degradation; no data loss; no sensitive error details
Cross-tenant request construction A request built for tenant A contains only tenant A’s data (inspect the actual outbound requests in a test environment with the provider stubbed)

Prompt injection cannot be fully prevented, so tests verify containment: even if the model is fooled, the damage is limited because it has no data from other tenants, no tools, and its output is untrusted. Keep a growing collection of adversarial test inputs, and run them whenever instructions, models, or providers change. Model behavior can differ between versions, so a test that passed once can fail later.

7. Penetration Testing and Fuzzing

Penetration testing is a time-boxed, goal-oriented attempt to break into the system by skilled testers, usually mixing tools with creativity: chaining small weaknesses, probing business logic, and thinking like a real attacker. It finds what automated scans and checklists miss, and it measures how well detection and response work. Use it:

  • Before significant releases or changes in exposure, or on a regular schedule.
  • With a clear scope and rules of engagement, performed by an internal specialist or an external firm.
  • With remediation and re-testing of the findings.

For an early pilot, a focused penetration test of the highest-risk areas (authentication, authorization, upload, model integration) usually gives more value than a broad shallow one. It does not replace the continuous tests in this lesson; it complements them.

Fuzzing sends large volumes of malformed or random input to a parser or interface and watches for crashes, hangs, and unexpected behavior. It is excellent for file parsers (such as the CSV importer), serialization code, and protocol handlers. Run it against isolated test builds with resource limits, and treat every crash as a potential vulnerability to analyze.

Other useful techniques: property-based tests for security invariants (“for any two tenants, no query returns the other’s records”), chaos-style tests that revoke a permission or break a dependency to see that the system fails closed, and tabletop exercises that walk through a breach scenario (lesson 9 and the operations course).

8. Automate and Keep the Results

Security tests that run once are a snapshot; tests that run on every change are protection.

  • Put authorization, input, and AI-containment tests in the regression suite from the quality strategy, run in the pipeline against a seeded environment.
  • Turn each fixed vulnerability into a test that fails without the fix, so it cannot return silently.
  • Keep slow or invasive tests (full DAST, fuzzing, load and abuse tests) on a schedule.
  • Store results with the release: what was tested, what passed, what failed, what was not tested.
  • Report coverage in terms of threats: which high threats have a passing test, which have only a review, and which have neither. This is more meaningful than lines of code covered.

9. Using AI for Security Testing

AI is good at generating test ideas and boilerplate for defensive testing of your own system.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Act as a security test engineer designing tests for a system we own,
for execution only in our authorized staging environment with
synthetic data.

Inputs:
- Threat register with the threats to be tested: [paste]
- API specification or endpoint list: [paste]
- Roles and tenants in the test environment: [paste]
- Existing tests and test framework conventions: [paste]
- Rules of engagement and exclusions: [paste]

Tasks:
1. Produce an authorization test matrix covering each endpoint,
   role, and tenant combination, with the expected result.
2. For each high threat, propose test cases with preconditions,
   steps, and the expected safe outcome.
3. Propose input and abuse tests for the upload and import features.
4. Propose adversarial inputs to test containment of prompt
   injection in the summary feature.
5. Write the test code for [N] of the cases in our framework, using
   placeholders for any credentials.
6. List what these tests cannot show.

Stay within the stated scope. Do not produce attack tools, exploit
code for real vulnerabilities, or anything intended for systems we
do not own.

Review the output:

  • Check the expected results. A test that asserts the wrong behavior passes while hiding a vulnerability.
  • Make sure each test can fail. Run it against a deliberately unprotected version, or temporarily remove the control, to see the test turn red.
  • Check scope and rate before running anything that sends traffic.
  • Keep sensitive details such as test credentials in the secrets store.

10. Practical Exercise

For SignalDesk (or your project):

  1. Write the test authorization: systems, environments, methods, exclusions, data, contacts, and stop conditions; have the system owner approve it.
  2. Seed the test environment with two tenants and users in each role.
  3. Build the authorization matrix for every endpoint and implement the tests for the five highest-risk endpoints.
  4. Write input and abuse tests for the upload and import path, and run a time-boxed fuzzing session against the file parser in an isolated environment.
  5. Write the AI-integration test set, including at least five prompt injection cases and a check of the outbound request contents.
  6. Run the AI test design prompt, review the cases for correctness and scope, and add those that are valuable.
  7. For each failing test, add a finding to the register; for each fix, keep the test as a regression test.
  8. Produce a threat coverage table: threat, test, result, gaps.
  9. Decide when a penetration test is warranted and define its scope.

Verification

You are ready to continue when:

  • Testing is authorized in writing, scoped, and limited to non-production environments with synthetic data.
  • Every high threat has at least one test or an explicit reason why not.
  • Authorization tests cover roles, tenants, and every kind of access, and run in the pipeline.
  • Tests were shown capable of failing, and expected results were reviewed by a person.
  • Fixed vulnerabilities have regression tests, and results are stored with the release.
  • The report states what was not tested.

Key Takeaways

  • Security tests check that forbidden things fail; derive them from the threat model.
  • Authorization and tenant isolation tests are the highest-value tests in a multi-tenant system.
  • AI features need their own tests, focused on containment, since injection cannot be fully prevented.
  • Test only what you are authorized to test, in safe environments, with synthetic data.
  • Automate tests as regression protection, and report coverage by threat.

What’s Next?

Testing and review produce findings; findings are only valuable when they are fixed, accepted, or escalated properly. The next lesson covers remediation: tracking fixes to verified closure, recording risk acceptance, handling reports from outsiders, and preparing for the day something goes wrong.