fix(webpush): recover gracefully from corrupted or mismatched VAPID keys#3031
Open
miaulalala wants to merge 1 commit into
Open
fix(webpush): recover gracefully from corrupted or mismatched VAPID keys#3031miaulalala wants to merge 1 commit into
miaulalala wants to merge 1 commit into
Conversation
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>
de2af5e to
80d4c71
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Companion PR to nextcloud/server#60735
app_configwere encrypted with a different instance secret (e.g. after a migration or secret rotation),getAppValueString()throws during decryptionWebPushClient::__construct()to crash, which in turn crashed unrelated requests — e.g. joining a Talk room, which triggers notification processing as a side effect\ThrowablefromgetAppValueString()ingetVapid()and treat it the same as missing keys, regenerating a fresh VAPID key pair stored with the current secretThe immediate workaround for affected instances is:
This fix makes the app self-heal that state transparently.
Test plan
NOCOVERAGE=1 ./autotest.sh sqlite apps-extra/notifications/tests/Unit/WebPushClientTest.phpWebPushClientTestcovers three cases: valid stored keys, missing keys, and keys that throw on decryption🤖 Generated with Claude Code