Repository navigation
fix: keep write-only secrets on their endpoint and bind ephemeral keys to the project sequence - #14795
Conversation
…hanges SMTP passwords and OAuth2 client secrets are write-only, but a partial update kept the stored secret while pointing it at a new server. Changing the SMTP host, port or secure mode, or an OAuth2 provider's domain or endpoints, now requires the secret in the same request (400 otherwise), so a stored secret is only ever sent where it was configured.
Ephemeral keys only carried the public project ID, which can be reused by a new project after deletion. Issuers now sign the project's internal sequence too, and decoding refuses a key whose sequence differs. Keys issued before this carry no sequence and are still accepted until they expire.
|
Review complete. No issues found — approved ✅. This PR hardens credential handling in three ways: ephemeral API keys are bound to the issuing project's sequence so stolen keys die with project delete/recreate, OAuth2 provider updates now require re-supplying the write-only client secret when the stored endpoint changes, and SMTP updates require the password when host/port/secure change. Note: two sub-80-confidence candidate findings were not kept (a legacy plain-secret bypass in
Reviewed commit: 682822a |
🟢 Tier S · Ready to mergeThe pull request prevents partial updates from reusing stored SMTP or OAuth2 secrets with changed endpoints, and updates the Console guidance for SMTP password reuse. Newly issued project-bound ephemeral keys include the project sequence, which is checked during key decoding to prevent reuse after a public project ID is recycled; regression coverage was added for these behaviors. Latest changes: The latest commits make the SMTP stored-secret check treat the valid password "0" as present, add parameterized E2E coverage for that case, and update the SMTP password hint in Console and its Hebrew and Japanese dictionaries.
📂 Walkthrough · 6
Reviewed the commits since |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
… provider Each provider maps its params to different stored keys, so exercise GitLab, Authentik, FusionAuth, Keycloak (domain and realm) and Okta's authorization server too, and reset those providers between tests.
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
commit: |
The private-host test changes the host after an earlier test stored a password, so the write-only password rule (appwrite#14795) rejected it before the public-host check (appwrite#14811) ran.
…-and-key-binding fix: keep write-only secrets on their endpoint and bind ephemeral keys to the project sequence (cherry picked from commit 2fced02)
1.9.x now requires the password again whenever the SMTP host changes (backport of #14795), so the private-host regression test passes it.
…meral keys to the project (backport appwrite#14795) (cherry picked from commit 2fced02)
What was vulnerable
This PR addresses two separate credential-boundary issues.
1. Redirecting a write-only secret to a different server
SMTP passwords and OAuth2 client secrets are hidden from API responses. However, a caller authorized to update the corresponding project settings could change the server endpoint while omitting the secret. The partial update retained the stored secret and paired it with the caller's new endpoint.
That let the caller make Appwrite send a secret they could not read through the API to a server they controlled: during SMTP credential verification/authentication, or a subsequent OAuth authorization-code exchange.
The fix adds guards before the stored credentials are merged:
host,port, orsecurerequirespasswordin the same request when a password is stored.This requires settings write access; it is not an unauthenticated secret-read endpoint.
2. Replaying an ephemeral key after a public project ID is reused
Ephemeral keys previously signed only the public project ID. Deleting a project did not invalidate its outstanding JWTs. If a new project reused that public ID before a key expired, a holder of the old key could authenticate to the new project with the key's scopes.
All seven project-bound issuance paths now sign
projectSequence: project and organization ephemeral-key endpoints, synchronous and worker function executions, migration workers, deployment runtime keys, and function/site proxying.Key::decode()rejects a sequence mismatch. The existingprojectCheckDisabledbypass remains unchanged.Compatibility and rollout
projectSequenceremain accepted until expiry. The residual replay window can last up to 24 hours, including migration keys; the public ephemeral-key endpoints cap duration at one hour. Newly issued keys include the signed claim, which cannot be removed without invalidating the signature. All issuers must be updated before the legacy-key window can close."0"also requires re-supply when changing the server.Added coverage
projectCheckDisabledand legacy claimless-key behavior."0"; allow the same server, an explicit password, and changes with no stored password. Existing server-change tests now supply their password.Console Hebrew and Japanese translation audits passed, and the new hint is present in both merged dictionaries. Focused Pint and PHPStan checks passed for the SMTP action and E2E trait. The focused SMTP E2E run could not start because the local
appwriteDocker service is not running; runtime validation relies on the CI Project lanes.Related: appwrite-labs/cloud#6666