Repository navigation
test: preventative security E2E suite over the live route table - #14245
Conversation
Enumerate /v1 routes from Http::getRoutes() and run pluggable attack classes (guest access, cross-tenant, IDOR, key scopes, console roles, header spoofing, SSRF URLs, sensitive fields). Known exceptions live in a checked-in baseline; CI fails on new findings without a reason. Co-authored-by: Jake Barnby <[email protected]>
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Self-hosted allows a single console organization, so World::boot was 403ing on the second POST /teams. Create the org once and attach both isolation projects to it. Also clear PHPStan and Rector nits that failed Checks. Co-authored-by: Jake Barnby <[email protected]>
A guest-callable route succeeding with a foreign key or a locale-only key is the public surface, not a bypass. Same for console-role probes on account/home/console scopes that any logged-in session already satisfies. Co-authored-by: Jake Barnby <[email protected]>
The live suite covered 705 /v1 routes. Presence upsert echoing a caller-chosen id is not an IDOR; passwordUpdate is a datetime; developers can read org projects. Record remaining allowlisted rows, including locale forwarded-IP reflection under default trusted proxies. Co-authored-by: Jake Barnby <[email protected]>
Shorten allowlist reasons and drop first-scan row notes from the suite README so the checked-in files stay unremarkable. Co-authored-by: Jake Barnby <[email protected]>
d5b45e7 to
1845b76
Compare
|
Review complete. 🟡 3 medium 💬 Inline comments (3)
🧹 Nitpicks (2) — 🟢 2 low
This PR introduces an automated attack-probe framework that enumerates the API catalog and runs SSRF, IDOR, guest-access, header-spoofing, scope, and sensitive-field probes against a live stack, recording accepted findings in a checked-in baseline. Supporting infrastructure covers route targeting, finding keys, and baseline persistence.
Risk is moderate: the suite itself is new test tooling, but baseline-update and param-substitution bugs could silently weaken or wipe the security allowlist. Reviewed commit: 1845b76 |
Co-authored-by: Jake Barnby <[email protected]>
🟢 Tier S · Ready to mergeAdds a route-table-driven security E2E suite that probes live Latest changes: The latest commits make a completed baseline update replace the findings list, preserving reasons only for findings still observed, and update the README and unit test to cover that behavior.
📂 Walkthrough · 9
Reviewed the commits since |
Co-authored-by: Jake Barnby <[email protected]>
There was a problem hiding this comment.
The PR adds a preventative security e2e probe suite (tests/e2e/Security/*) with a baseline allowlist, unit tests, and a dedicated e2e_security CI job.
Key findings
- 🟡 Baseline update mode can wipe the allowlist file — SecurityProbeTest.php:38
- 🟡 SSRF probe replaces dummy params, skipping multi-param routes — SsrfUrl.php:50
- 🟡 Baseline update writes inside the container, not the repo — Baseline.php:13
Co-authored-by: Jake Barnby <[email protected]>
Co-authored-by: Jake Barnby <[email protected]>
Co-authored-by: Jake Barnby <[email protected]>
Merge dummy required fields under URL overrides so multi-param routes reach the handler instead of a 400. Refuse a baseline rewrite unless the world booted and every attack class ran, keep rows the run did not emit, and copy the document to the cache volume when tests/ is not bind-mounted.
|
Addressed the open Hansi + Tenki findings in ef85a21:
@hansi-codes review |
|
Already reviewed ef85a21. No new commits since then, so I didn't post another review. |
Keeping omitted rows after a full Attacks::all() run would allowlist a later recurrence of a fixed probe. Partial runs still refuse to write; a completed update now replaces the findings list and only preserves reasons for keys that still fire.
|
Dropped stale baseline rows on a completed update in 919e8c7. Partial runs still refuse to write; a full run no longer keep-alives resolved findings. @hansi-codes review |
|
Already reviewed 919e8c7. No new commits since then, so I didn't post another review. |
What does this PR do?
Adds a preventative security E2E suite: every live
/v1route is taken from the process router (Http::getRoutes()after the same bootstrap the specs task uses) and offered to a set of pluggable attack classes. A newly added endpoint is probed automatically. This is the dynamic counterpart to the Semgrep baseline in #14062, not another list of hand-written cases for known reports (that is #14064).Coverage (routes × classes)
Source of truth:
Catalogloadsapp/controllers/general.php+ module HTTP init, thenHttp::getRoutes(). Aliases collapse to the primary path. GraphQL fan-out and mock-labeled routes are skipped; everything else under/v1is in.Green scan (
791d774a8c/ rewritten asdaaf6b324c, 705/v1routes, ~27s of probes):guest-accesscross-tenantidorscope-least-privilegeconsole-roleheader-spoofssrf-urlsensitive-fieldsAttack classes (
tests/e2e/Security/Attack/, auto-discovered):guest-accesscross-tenantidoruserId/emailscope-least-privilegelocale.readplus built-in key scopes, only on non-guest routesconsole-roleaccount/projects.read); plus owner-only membership mutationsheader-spoofx-appwrite-*identity headers (mixed case),X-Forwarded-Forssrf-urlsensitive-fieldssecret/password/ execution streams must be empty or absentAdding a class is one file in
Attack/.Baseline
tests/e2e/Security/baseline.jsonis the allowlist (same spirit as.semgrep/baseline.json):attack + method + path + probekey is not listed.reason.METHOD /v1/...ids). CI fails on a live catalog route that is not listed until the inventory is updated.The baseline lists a forwarded-IP WARNING: compose/CI sits on loopback or RFC1918, so default
_APP_TRUSTED_PROXIESreflectsX-Forwarded-For.False positives that were not allowlisted:
$idwhileuserIdstays the caller.passwordUpdate— ISO datetime of last password change, documented on the Account model.To accept a reviewed new endpoint (and refresh the route list):
Review the
baseline.jsondiff like code. How to add a route is documented intests/e2e/Security/README.md.CI
New job
Tests / E2E / Security— one stack (default PostgreSQL, dedicated tables), sequential PHPUnit, 20-minute test budget (~27s of probes after world boot). Shared fixture world (one console organization, two projects, two users, least-privilege key, console developer). ParaTest is not used: multiplying that world per process costs more than the request loop saves.Docs:
tests/e2e/Security/README.md.Unit tests for catalog filtering, baseline matching (including that a canary route is rejected once
routesis locked), probe path filling, and attack discovery run in the existing unit job.Test Plan
Tests / E2E / Securitygreen with reasoned baselinetests/unit/Securitypass (unit job)POST /v1/security-inventory-canaryisfreshmain(includes fix(users): align session route scopes with their admin/server auth types #13994) and dropped the resolved baseline row; remaining allowlist is the forwarded-IP warning only