Skip to content

fix(webhooks): make authPassword write-only - #14016

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/webhook-auth-password-write-only
Sep 30, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/webhook-auth-password-write-only

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Makes the webhook authPassword write-only.

A key scoped only to webhooks.read could read the stored HTTP Basic-auth password for a webhook's external endpoint from GET /v1/webhooks/:id and GET /v1/webhooks, while the signing key on the same routes was already withheld. The password is only ever needed by the webhooks worker, which reads it from the database directly.

  • Response\Model\Webhook::filter() now always returns authPassword as an empty string, so get, list, create and update responses no longer carry it.
  • PUT /v1/webhooks/:id now takes authPassword as optional and nullable: omitting it keeps the stored password, and sending '' clears it. The retained password is dropped when the update changes the URL or turns TLS verification off, so a webhooks.write key cannot redirect a credential it cannot read to an endpoint it controls. Without this, the Console (which currently echoes $webhook.authPassword back on every edit) would silently wipe the password when a user renames a webhook or changes its URL or events.

Out of scope: the V26 legacy response filter still serialises httpPass and signatureKey into project.webhooks[] for old response formats on project reads. That path needs project-level read access rather than webhooks.read, and can follow separately.

Behaviour change: Appwrite-to-Appwrite migrations can no longer copy a webhook's Basic-auth password, because the source API no longer returns it (the same caveat that already applies to secret). The migration test now asserts that.

Test Plan

  • testWebhookAuthPasswordNotExposedInResponses: create, get, list and update all return authPassword === '' and no httpPass.
  • testReadOnlyKeyCannotRecoverAuthPassword (custom server): a key with only webhooks.read gets an empty authPassword and secret from get and list.
  • testUpdateWebhookKeepsAuthPasswordWhenOmitted: updating a webhook without authPassword, then triggering an event, delivers Authorization: Basic base64(user:password) to the request catcher, so the stored credential survived the update.
  • testUpdateWebhookClearsAuthPasswordWhenUrlChanges: moving the URL without authPassword delivers no Authorization header.
  • Updated existing assertions (including the 1.9.0 legacy-format httpPass tests) that expected the password to be echoed back.
  • pint --test and phpstan pass on the changed files. E2E runs in CI.

Related PRs and Issues

A key scoped to webhooks.read could read back the Basic-auth credential for
the external endpoint, while the signing key on the same routes was already
withheld. The response model now always returns authPassword empty, and
updates that omit it keep the stored password so clients that can no longer
read it back do not wipe it on unrelated edits.
@ghost

ghost commented Sep 30, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new test exercises the previously uncovered TLS-downgrade guard, and no additional problems were found in the incremental changes.

Makes webhook Basic-auth passwords write-only in API responses. Updates preserve an omitted password unless the endpoint changes or TLS verification is downgraded. E2E coverage checks response redaction, read-only access, credential retention, and clearing on URL changes and TLS downgrades.

Latest changes: Adds a delivery-based regression test that disables TLS verification without changing the URL or supplying a password, then verifies that no Authorization header is sent.

Verdict New comments Fixed Still open
✅ Approved 0 1 0
📂 Walkthrough · 6
File Change
src/Appwrite/Platform/Modules/Webhooks/Http/Webhooks/Update.php Accepts nullable passwords and preserves stored credentials only when the endpoint remains safe.
src/Appwrite/Utopia/Response/Model/Webhook.php Redacts authPassword and documents its write-only behavior.
tests/e2e/Services/Migrations/MigrationsBase.php Updates migration expectations for passwords no longer returned by the source API.
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php Expects an empty password in webhook responses.
tests/e2e/Services/Webhooks/WebhooksBase.php Tests response redaction, credential retention, and clearing on URL changes and TLS downgrades; updates legacy-format expectations.
tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php Checks that a webhooks.read-only key cannot retrieve webhook credentials.
✅ Fixed since the last review · 1
  • Cover password clearing on TLS-verification downgrade · src/Appwrite/Platform/Modules/Webhooks/Http/Webhooks/Update.php:114

Reviewed the commits since e1d0aaa · 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 B · 1 blocking finding to address. Summary

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical risk] Webhook authentication password handling and exposure control.

The PR appears safe to merge; no outstanding finding or new actionable issue remains.

Summary

The PR makes webhook Basic-auth passwords write-only, retains them on eligible updates, and clears them when an update changes the URL or disables TLS verification. It also updates response, delivery, and migration tests.

Reviews (2) · Last reviewed commit: "test(webhooks): cover password clearing ..."

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/webhook-auth-password-write-only (after).

Metric Before After Change
🚀 Requests/sec 180.26 205.25 🟢 +13.9%
⏱️ Latency P50 95.2 ms 84.93 ms 🟢 -10.8%
⏱️ Latency P95 231.47 ms 194.31 ms 🟢 -16.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.93 194.31 12,711 205.25 -37.17
Account 154.1 294.23 669 11.16 -49.71
TablesDB 81.37 153.4 6,913 113.36 -41.63
Storage 80.27 180.24 3,345 57.14 -9.55
Functions 116.75 226.43 1,784 31.22 -31.88

Top API waits (after)

API request Max wait (ms)
account.name.update 440.44
functions.variables.update 427.45
account.prefs.update 381.66
storage.buckets.create 372.36
storage.files.create 364.86

Keeping the stored password on an update that moves the URL or disables TLS
verification let a webhooks.write key redirect the credential to an endpoint
it can read. Also align the legacy-format tests with the masked response and
pick deliveries by webhook ID so the project's catch-all webhook cannot
answer the probe.
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@greptile review

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

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

@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 A · Looks good to merge. Summary

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@greptile 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

@ChiragAgg5k
ChiragAgg5k merged commit 32340c2 into main Sep 30, 2026
51 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/webhook-auth-password-write-only branch September 30, 2026 12:04
abnegate added a commit that referenced this pull request Sep 30, 2026
Brings in main's OAuth2 state and nonce validation (#14012), which cloud
needs, along with the realtime origin alignment (#14020), subscriber
target ownership (#14019), GitLab primary email (#14010), impersonation
MFA (#14017), write-only webhook passwords (#14016), chunked-upload
resume ownership (#14014), preview authorize validation (#14013),
nightly forcing (#14015) and scheduled-function enqueue checks (#14011).

The merge had no textual conflicts, and main left composer.json and
composer.lock unchanged. So the lock keeps the branch's database and
async pins.

Main's assertResumeAllowed() in Storage Buckets/Files/Create checks
Input(Database::PERMISSION_UPDATE, ...). utopia-php/database 8 has no
PERMISSION_* constants, so every chunked resume would fail with an
undefined-constant error. It now passes PermissionType::Update, as the
rest of that action already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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