Repository navigation
fix(templates): store password-typed template variables as secrets (appwrite:appwrite:alert#4728) - #15477
Conversation
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
This PR marks password-typed variables in the server-side template catalogs as
All cross-file contracts checked out: the Reviewed commit: 0998fd9 |
New ConsoleProject ID: Tip JWT tokens let functions act on behalf of users while preserving their permissions |
🟢 Tier S · Ready to mergeThe template catalogs now mark password-typed function and site variables as secret, and both setup wizards classify those variables as secret even when older servers omit the flag. The wizards use the resulting secret state for input masking and when creating variables. Added unit tests cover catalog markings and password-versus-text classification.
📂 Walkthrough · 7
Reviewed |
commit: |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
The function and site template catalogs described credential inputs with `type => 'password'` alone and never set `secret`, so the template response model filled it with `false`. Both setup wizards seeded each variable with that flag and passed it to `createVariable`, overriding the route's `secret` default of `true` — Redis and database passwords, API tokens and Stripe secret keys entered during setup were stored readable and handed back in clear text to anything holding `functions.read` or `sites.read`. Mark every password-typed catalog entry secret, and derive secrecy in the wizards from the type so a server that omits the flag still classifies the value. The input masking and the Secret badge now follow the same computed flag instead of the raw catalog one. appwrite:appwrite:alert#4728 Co-Authored-By: Claude Opus 5 <[email protected]>
0998fd9 to
c92a69c
Compare
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
fix(templates): store password-typed template variables as secrets (appwrite:appwrite:alert#4728) (cherry picked from commit 09db206)

What
Code-scanning alert #4728: credentials typed into the function/site template setup wizards were stored as non-secret variables, so
GET /v1/functions/:functionId/variables(scopefunctions.read) and the sites equivalent returned them in clear text.Three gaps composed:
app/config/templates/function.php/site.phpdescribe credential inputs only with'type' => 'password'and never setsecret, soTemplates/Get.php→TemplateVariablefilled it with itsfalsedefault.secret: v.secret || false— alwaysfalse.falsetocreateVariable, so the route's secure default (->param('secret', true, ...)) never applied.Variable::filter()blanksvalueonly whensecret === true, so any read-only API key, console member with read scope, or function runtime key with those scopes could read Redis/database passwords, third-party tokens and Stripe secret keys. The wizards also masked the input off the same never-true flag, so password fields were rendered as visible text during entry.Fix
type === 'password'is now authoritative for secrecy end to end:'secret' => trueon all 56 password-typed entries in the function catalog and all 3 in the site catalog, so new servers are explicit.isTemplateVariableSecret()(apps/console/src/lib/template-variables.ts) treats a password input as secret, so a server that omits the flag still classifies correctly. Both wizards seed variables through it.type='password'masking now follow the seeded flag instead of the raw catalog one, so password fields are masked during entry.Non-credential template variables keep their explicit
secret: false— their values stay readable in the console, as before.Tests
Both tests fail on
mainand pass here.tests/unit/General/TemplatesTest.php— every password-typed variable in both catalogs must be marked secret (59 entries today). Failed before the catalog change (query-upstash-vector: UPSTASH_TOKEN,: STRIPE_SECRET_KEY).apps/console/tests/unit/template-variable-secret.test.ts— a password-typed variable is classified secret whether the server sendssecret: falseor omits it; text inputs stay readable.Verified: full
--testsuite unit(2592 tests, no failures; only the known environmentalKeyTest/ListCacheTesterrors), Pint, PHPStan and Rector on the changed PHP,bun test tests/unitandtsc --noEmitfor the console.Follow-up (not in this PR)
Variables already created through the template wizards remain non-secret. They should be audited and the stored credentials rotated — the fix only protects values entered from here on.
🤖 Generated with Claude Code