Repository navigation
fix(functions): validate reserved x-appwrite execution headers case-insensitively - #14185
Conversation
…poofing Reserved function headers were only blocked when the caller used a lowercase x-appwrite- prefix, so mixed-case or uppercase names in the execution headers param reached the runtime alongside injected values. Co-authored-by: Jake Barnby <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
Co-authored-by: Jake Barnby <[email protected]>
|
Review complete. 🟠 1 high 💬 Inline comments (1)
Adds a shared
Reviewed commit: 84bf558 |
|
@hansi-codes review |
🟢 Tier S · Ready to merge
This change makes the reserved
📂 Walkthrough · 8
Reviewed |
There was a problem hiding this comment.
This PR rejects spoofed reserved x-appwrite-* headers on execution creation and silently strips them on the proxy route and worker paths via a new Headers::stripReserved validator.
Key findings
- 🟠 Worker strip drops
x-appwrite-client-ipand geo from async executions — Functions.php:570
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
…ders Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Async execution reads do not include a response body, so the finished run is loaded with the project key and the IP is taken from the function logs. Co-authored-by: Jake Barnby <[email protected]>
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Rector's PHPUnit quality set rewrites assertNotFalse(strpos()) to assertStringContainsString(). Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Send mixed-case reserved headers through the domain path and check the function receives Appwrite's values, not the caller-supplied ones. Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
…eader-spoof-4078 fix(functions): validate reserved x-appwrite execution headers case-insensitively (cherry picked from commit 003584a)
What does this PR do?
The function Headers validator now treats the reserved
x-appwrite-prefix as case-insensitive. Any caller header whose lowercased name starts withx-appwrite-is stripped before Appwrite injects its own values on every execution path that forwards caller-controlled headers:POST /v1/functions/:functionId/executions(sync, async, scheduled)The reserved names include
x-appwrite-user-id,x-appwrite-trigger,x-appwrite-event, andx-appwrite-key.The previous check used a case-sensitive
str_starts_with($key, 'x-appwrite-'). PHP array keys are case-sensitive, soX-Appwrite-User-Idpassed validation. The execution path then set Appwrite's values under lowercase keys, leaving both the caller's mixed-case key and the injected key in the map sent to the executor. Runtimes treat HTTP headers as case-insensitive and expose the caller's value.On current
main, a rejectedheadersparam already returns HTTP 400 (general_argument_invalid). That 400-class mapping is unchanged.Test Plan
tests/unit/Functions/Validator/HeadersTest.phpcover mixed case, ALL CAPS, andstripReserved(). These fail if the prefix check is case-sensitive again.FunctionsCustomClientTest: guestPOSTwith mixed-case and ALL CAPS reserved headers must return 400general_argument_invalid.FunctionsCustomServerTest::testCreateExecutionFAILURE block: same mixed-case / ALL CAPS reserved headers return 400.composer analyzewas not run here (no project vendor tree in this environment).vendor/bin/phpunit tests/unit/Functions/Validator/HeadersTest.phppassed (31 assertions).Related PRs and Issues
Checklist