Skip to content

fix(proxy): strip Appwrite session cookies from function and site requests - #14874

Merged
HarshMN2345 merged 2 commits into
mainfrom
fix-session-cookie-runtime-strip
Oct 23, 2026
Merged

HarshMN2345 merged 2 commits into
mainfrom
fix-session-cookie-runtime-strip

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

Requests routed to function and site runtimes now drop every a_session_* cookie (project, console and legacy variants) along with the preview cookie, instead of only the console session cookies. Other cookies are forwarded unchanged.

Details are tracked internally.

Tested: Pint on the touched files; extended the existing Sites cookie-header e2e assertion to include project session and legacy cookies (relying on CI for the run).

@luxor-code-review

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

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The proxy previously hardcoded only a_session_console and a_session_console_legacy for removal, so project-scoped session cookies could reach user-executed functions/sites. This PR builds the strip list dynamically from the request's actual cookie params via an a_session_ prefix match, alongside COOKIE_NAME_PREVIEW.

Files Change
app/controllers/general.php Replaces the hardcoded cookie strip list with a dynamic a_session_ prefix scan over getCookieParams() before getHeadersWithoutCookies() rebuilds the header map.
tests/e2e/Services/Sites/SitesCustomServerTest.php Adds project-scoped session and legacy session cookies to the preview-cookie test, asserting only non-session cookies survive forwarding.

No defects were found; the strip logic covers console, legacy, and per-project cookie variants and the e2e test verifies the contract end to end.

Reviewed commit: d2d79bb

@ghost

ghost commented Oct 23, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The proxy now removes every cookie whose name begins with a_session_, in addition to the preview cookie, before forwarding function and site requests. The Sites SSR cookie-header E2E assertion now covers project session cookies and their legacy variant while verifying unrelated cookies remain forwarded.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
app/controllers/general.php Builds a removal list from incoming session cookie names and uses it when constructing forwarded headers.
tests/e2e/Services/Sites/SitesCustomServerTest.php Extends the SSR cookie-header assertion with project session and legacy cookies.

Merged main (a9f8ae1); no changes to this PR's code since d2d79bb · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@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

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-session-cookie-runtime-strip (after).

Metric Before After Change
🚀 Requests/sec 202.71 204.63 ⚪ +0.9%
⏱️ Latency P50 83.87 ms 84.44 ms ⚪ +0.7%
⏱️ Latency P95 199.57 ms 199.7 ms ⚪ +0.1%
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 84.44 199.7 12,654 204.63 +0.13
Account 157.61 291.35 666 11.04 +5.91
TablesDB 80.16 146.35 6,882 112.93 -9.36
Storage 81.47 187.85 3,330 56.79 -0.09
Functions 119.21 238.91 1,776 31.02 +3.38

Top API waits (after)

API request Max wait (ms)
functions.variables.update 425.66
account.name.update 411.88
account.prefs.update 361.05
storage.buckets.create 358.63
storage.files.update 356.71

@HarshMN2345
HarshMN2345 merged commit a03bb89 into main Oct 23, 2026
20 checks passed
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…ntime-strip

fix(proxy): strip Appwrite session cookies from function and site requests

(cherry picked from commit a03bb89)
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