Skip to content

fix(proxy): keep the fallback session header out of function and site requests - #14925

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/fallback-cookies-runtime-strip
Oct 24, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/fallback-cookies-runtime-strip

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

#14874 stopped forwarding Appwrite session cookies to function and site runtimes. But clients that can't use cookies send the same session in x-fallback-cookies, and that header still reached user code.

  $requestHeaders = \array_map(..., $request->getHeadersWithoutCookies($strippedCookies));
+ // Clients without cookie support send their session in this header instead.
+ unset($requestHeaders['x-fallback-cookies']);

Test

SitesCustomServerTest::testPreviewCookies now also sends x-fallback-cookies, and asserts the site never sees it. The astro fixture's /cookie-header echoes that header back.

Found while backporting #14874 to 1.9.x, where #14911 ships the same fix.

@luxor-code-review

luxor-code-review Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This change prevents session-bearing fallback-cookie headers from being forwarded to proxied backends, closing a session-credential leak path, and covers it with an end-to-end test backed by a new Astro fixture page that echoes received cookie headers.

Files Change
app/controllers/general.php Adds header sanitization so X-Fallback-Cookies is removed before proxying requests for site previews and function executions.
tests/e2e/Services/Sites/SitesCustomServerTest.php Adds an e2e test asserting the fallback-cookie header is absent when a custom server receives a proxied request.
tests/resources/sites/astro/src/pages/cookie-header.js New Astro fixture endpoint that echoes the cookie headers it receives, letting the e2e test observe what actually reaches the custom server.

Reviewed commit: dcdcf54

@ghost

ghost commented Oct 24, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The filtering runs on the normalized header map used by both function and site proxy requests, and the E2E test covers the site behavior.

The function/site proxy now removes x-fallback-cookies from headers forwarded to runtimes. The Astro fixture and site E2E test verify the fallback session header is absent from runtime requests while ordinary cookies continue to be forwarded.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
app/controllers/general.php Removes the fallback session header from the proxy request headers before forwarding.
tests/e2e/Services/Sites/SitesCustomServerTest.php Sends a fallback session header and asserts the SSR site response does not expose it.
tests/resources/sites/astro/src/pages/cookie-header.js Echoes the fallback-cookie header to support the regression assertion.

Reviewed dcdcf54 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 24, 2026

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/fallback-cookies-runtime-strip (after).

Metric Before After Change
🚀 Requests/sec 204.93 208.28 ⚪ +1.6%
⏱️ Latency P50 83.5 ms 83.45 ms ⚪ -0.1%
⏱️ Latency P95 196.9 ms 193.39 ms ⚪ -1.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 83.45 193.39 12,939 208.28 -3.52
Account 150.31 287.15 681 11.3 +5.97
TablesDB 79.43 141.72 7,037 115.74 -3.12
Storage 80.23 187.29 3,405 57.94 -7.68
Functions 117.96 223.34 1,816 31.53 -10.12

Top API waits (after)

API request Max wait (ms)
storage.buckets.create 395.93
functions.create 375.11
account.name.update 374.21
functions.variables.update 355.15
functions.variables.create 348.03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant