Skip to content

fix(jobs): reject empty and default _APP_JOBS_SECRET - #14116

Merged
abnegate merged 11 commits into
mainfrom
cursor/jobs-secret-default-03b4
Oct 22, 2026
Merged

abnegate merged 11 commits into
mainfrom
cursor/jobs-secret-default-03b4

Conversation

@abnegate

@abnegate abnegate commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

JobsSecret treats missing, empty, and your-secret-key as unconfigured and does not verify an HMAC against them. /v1/jobs/event uses that check, so a placeholder-keyed signature is rejected the same way as an invalid one.

  • The installer now generates a unique _APP_JOBS_SECRET (filter: token) instead of writing the placeholder
  • The repo .env uses a unique local/CI secret so function and site deployment callbacks still verify (the public placeholder is no longer the committed default)
  • appwrite doctor flags a default jobs secret the same way it flags the encryption key

A non-placeholder value still verifies normally.

Test Plan

  • Unit: tests/unit/Auth/JobsSecretTest.php
    • Rejects null, empty, and your-secret-key even when the HMAC digest matches that value
    • Accepts a non-default secret with a matching digest
    • Rejects a non-default secret with a mismatched digest
  • Ran the suite with PHPUnit 12 (9 tests, 9 assertions)
  • Pint --test on the touched PHP files
  • First CI run: Functions/Sites/GraphQL/Realtime and other deployment-wait suites timed out or failed because .env still used the rejected placeholder. Follow-up commit points .env at a unique secret.

Related PRs and Issues

  • N/A

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web Open in Cursor 

Treat _APP_JOBS_SECRET as unconfigured when it is missing, empty, or the
public your-secret-key placeholder so /v1/jobs/event cannot be forged with
the known default. New installs generate a unique token instead.

Co-authored-by: Jake Barnby <[email protected]>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/jobs-secret-default-03b4 (after).

Metric Before After Change
🚀 Requests/sec 187.51 187.32 ⚪ -0.1%
⏱️ Latency P50 90.22 ms 91.77 ms ⚪ +1.7%
⏱️ Latency P95 221.06 ms 218.04 ms ⚪ -1.4%
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 91.77 218.04 11,628 187.32 -3.02
Account 180.31 330.27 612 10.17 +14.65
TablesDB 89.11 163.66 6,324 103.66 -1.15
Storage 84.17 203.15 3,060 52.33 -8.03
Functions 128.52 250.45 1,632 28.66 -19.06

Top API waits (after)

API request Max wait (ms)
account.name.update 470.73
functions.create 467.59
storage.buckets.create 450.87
account.prefs.update 424.81
tablesdb.rows.create 398.67

cursoragent and others added 2 commits October 5, 2026 08:13
The fail-closed /v1/jobs/event check rejects the public your-secret-key
placeholder, which hung CI function and site deployment waits. Point the
dev/CI env at a unique secret so jobs callbacks still verify.

Co-authored-by: Jake Barnby <[email protected]>
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • 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.

abnegate and others added 3 commits October 15, 2026 19:17
adhocore/jwt registers keys with array_merge, which renumbers integer-like
string keys. A token signed under a kid such as "1234567890123456" resolved
through the JWKS, then failed in the JWT layer with "Unknown key ID".

The mock provider derives its kid from the first 16 hex chars of a SHA-1, so
roughly one CI run in two thousand drew an all-digit kid and every ID token
session test in that job failed with a 401. Real providers with numeric kids
were rejected the same way.

Register keys with an array union so key IDs keep their exact value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cursor cursor Bot changed the title fix(jobs): reject empty and shipped-default _APP_JOBS_SECRET fix(jobs): reject empty and default _APP_JOBS_SECRET Oct 22, 2026
Co-authored-by: Jake Barnby <[email protected]>
@abnegate
abnegate marked this pull request as ready for review October 22, 2026 05:23
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟠 1 high

💬 Inline comments (1)

  • 🟠 Real _APP_JOBS_SECRET committed in .env — .env:147

This PR introduces a dedicated JobsSecret verifier for the Functions jobs event webhook, refines OIDC ID-token/JWT verification key handling, and wires the new _APP_JOBS_SECRET variable through .env, app/config/variables.php, and a Doctor diagnostic, with unit tests for both new auth libraries.

Files Change
src/Appwrite/Auth/JobsSecret.php New secret verifier with placeholder/insecure detection and fail-closed verify()
src/Appwrite/Auth/OIDC/JWT.php, src/Appwrite/Auth/OIDC/IdTokenVerifier.php JWKS key-ID handling and ID-token verification updates
src/Appwrite/Platform/Modules/Functions/Http/Jobs/Event/Create.php Switches the jobs event endpoint to JobsSecret signature verification
.env, app/config/variables.php, src/Appwrite/Platform/Tasks/Doctor.php New _APP_JOBS_SECRET variable wiring, default, and a Doctor health check
tests/unit/Auth/* Unit coverage for JobsSecret and the OIDC verifier
.env Commit of a concrete 64-hex value for _APP_JOBS_SECRET (see finding)

The committed secret lets stock clones sign valid job callbacks, so it should be reverted to the empty default before merge.

Reviewed commit: e2ff41d

@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

I found no additional actionable defects in the reviewed changes.

This change rejects empty and placeholder jobs callback secrets, generates unique values in installer and Compose setup, and adds a doctor check. It also adds regression coverage and fixes OIDC verification for integer-like key IDs.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 11
File Change
.env Sets the development jobs callback secret.
app/config/variables.php Makes the jobs secret default empty and generates it with the token filter.
apps/console/src/lib/docs/compose-generator/generate.ts Generates a random jobs secret in downloaded Compose environment files.
src/Appwrite/Auth/JobsSecret.php Adds insecure-secret detection, secret resolution, and HMAC verification.
src/Appwrite/Auth/OIDC/IdTokenVerifier.php Uses the local JWT wrapper for token verification.
src/Appwrite/Auth/OIDC/JWT.php Preserves integer-like key IDs when registering JWT signing keys.
src/Appwrite/Platform/Modules/Functions/Http/Jobs/Event/Create.php Uses JobsSecret to authenticate incoming job events.
src/Appwrite/Platform/Tasks/Doctor.php Reports whether the jobs callback secret is configured securely.
src/Appwrite/Platform/Tasks/Install.php Generates a jobs secret during environment preparation.
tests/unit/Auth/JobsSecretTest.php Covers insecure secret rejection, generation, and valid and invalid HMACs.
tests/unit/Auth/OIDC/IdTokenVerifierTest.php Covers verification with an integer-like key ID.

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

ghost
ghost previously requested changes Oct 22, 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 B · 2 blocking findings to address. Summary

Comment thread .env Resolved
Comment thread src/Appwrite/Auth/JobsSecret.php Resolved

@luxor-code-review luxor-code-review Bot 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.

Adds JobsSecret HMAC verification for the /v1/jobs/event endpoint plus OIDC/JWT verification hardening, new env wiring, Doctor checks, and unit tests - but commits a real signing secret in .env.

Key findings

  • 🟠 Real _APP_JOBS_SECRET committed in .env — .env:147

Comment thread .env Resolved

@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 B · See the inline comments. Summary

Comment thread tests/unit/Auth/JobsSecretTest.php Resolved
@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@ghost
ghost dismissed their stale review October 22, 2026 05:29

The findings that requested changes are resolved. See the summary comment for what is still open.

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@14116

commit: a6a9694

ghost
ghost previously requested changes Oct 22, 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 B · 1 blocking finding to address. Summary

Comment thread src/Appwrite/Auth/JobsSecret.php Resolved
@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@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

@ghost
ghost dismissed their stale review October 22, 2026 05:35

The findings that requested changes are resolved. See the summary comment for what is still open.

@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

Co-authored-by: Jake Barnby <[email protected]>
@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@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

Co-authored-by: Jake Barnby <[email protected]>
@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@hansi-codes review

@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

@abnegate
abnegate merged commit 7479c43 into main Oct 22, 2026
75 checks passed
@abnegate
abnegate deleted the cursor/jobs-secret-default-03b4 branch October 22, 2026 06:53
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…fault-03b4

fix(jobs): reject empty and default `_APP_JOBS_SECRET`

(cherry picked from commit 7479c43)
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.

2 participants