Skip to content

fix(webpush): recover gracefully from corrupted or mismatched VAPID keys#3031

Open
miaulalala wants to merge 1 commit into
masterfrom
fix/noid/webpushclient-recover-corrupted-vapid-keys
Open

fix(webpush): recover gracefully from corrupted or mismatched VAPID keys#3031
miaulalala wants to merge 1 commit into
masterfrom
fix/noid/webpushclient-recover-corrupted-vapid-keys

Conversation

@miaulalala
Copy link
Copy Markdown
Contributor

@miaulalala miaulalala commented May 26, 2026

Summary

Companion PR to nextcloud/server#60735

  • If VAPID keys stored in app_config were encrypted with a different instance secret (e.g. after a migration or secret rotation), getAppValueString() throws during decryption
  • This caused WebPushClient::__construct() to crash, which in turn crashed unrelated requests — e.g. joining a Talk room, which triggers notification processing as a side effect
  • Fix: catch any \Throwable from getAppValueString() in getVapid() and treat it the same as missing keys, regenerating a fresh VAPID key pair stored with the current secret

The immediate workaround for affected instances is:

occ config:app:delete notifications webpush_vapid_pubkey
occ config:app:delete notifications webpush_vapid_privkey

This fix makes the app self-heal that state transparently.

Test plan

  • NOCOVERAGE=1 ./autotest.sh sqlite apps-extra/notifications/tests/Unit/WebPushClientTest.php
  • New WebPushClientTest covers three cases: valid stored keys, missing keys, and keys that throw on decryption

🤖 Generated with Claude Code

@miaulalala miaulalala requested a review from nickvergessen as a code owner May 26, 2026 14:09
If the stored VAPID keys were encrypted with a different instance
secret (e.g. after a migration or secret rotation), decrypting them
throws an exception in WebPushClient::getVapid(). This caused the
entire request to fail, even for unrelated operations like joining a
Talk room (which triggers notification processing as a side effect).

Catch any Throwable from getAppValueString() and treat it the same as
missing keys: regenerate a fresh VAPID key pair and store it with the
current secret. This self-heals the broken state transparently.

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@miaulalala miaulalala force-pushed the fix/noid/webpushclient-recover-corrupted-vapid-keys branch from de2af5e to 80d4c71 Compare May 26, 2026 14:12
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