Skip to content

Audit Fixes - #150

Merged
iMattPro merged 7 commits into
phpbb-extensions:mainfrom
iMattPro:fixes
Nov 13, 2026
Merged

iMattPro merged 7 commits into
phpbb-extensions:mainfrom
iMattPro:fixes

Conversation

@iMattPro

Copy link
Copy Markdown
Contributor

No description provided.

@codecov-commenter

codecov-commenter commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.32%. Comparing base (5dabeb3) to head (cf8c257).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #150      +/-   ##
============================================
+ Coverage     98.23%   98.32%   +0.09%     
- Complexity      276      289      +13     
============================================
  Files            11       11              
  Lines           794      838      +44     
============================================
+ Hits            780      824      +44     
  Misses           14       14              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI 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.

🟡 Changes recommended

VAPID validation can accept invalid or mismatched keys that break push authentication, while subscription recovery and legacy notification links also have unresolved regressions.

3 open issues
What changed in this PR

This PR addresses audit findings in the phpBB Browser Push Notifications extension, strengthening validation and adjusting subscription recovery and notification handling.

Changes:

  • Adds endpoint and VAPID key validation, with delivery error handling.
  • Updates browser subscription ownership checks, notification text decoding, and click URL resolution.
  • Adds regression tests and English/Russian validation and moderation-log messages.
File Description
ucp/​controller/​webpush.php Uses shared endpoint validation and updates notification rendering.
tests/​system/​simple_test.php Tests moderation-log translations.
tests/​subscription/​validator_test.php Adds VAPID key and endpoint validation cases.
tests/​notification/​webpush_branches_test.php Tests handling of invalid VAPID configuration.
tests/​notification/​notification_method_webpush_test.php Tests delivery isolation for malformed endpoints.
tests/​javascript/​webpush_test.php Runs browser subscription checks through Node.js.
tests/​javascript/​webpush_test.js Tests subscription ownership and refresh behavior.
tests/​javascript/​push_worker_test.php Runs worker URL checks through Node.js.
tests/​javascript/​push_worker_test.js Tests notification-click URL resolution and filtering.
tests/​controller/​controller_webpush_test.php Updates endpoint, worker, and notification-text tests.
tests/​controller/​controller_acp_test.php Tests VAPID validation when saving settings.
subscription/​validator.php Adds VAPID and endpoint URL validation helpers.
styles/​all/​template/​webpush.js Prevents automatic refresh of unrecognized subscriptions.
styles/​all/​template/​push_worker.js.twig Resolves notification links relative to the worker URL.
notification/​method/​webpush.php Validates stored endpoints and handles initialization failures.
language/​ru/​webpushnotifications_module_acp.php Adds Russian VAPID validation text.
language/​ru/​info_mcp_webpushnotifications.php Adds Russian subscription-removal log text.
language/​en/​webpushnotifications_module_acp.php Adds English VAPID validation text.
language/​en/​info_mcp_webpushnotifications.php Adds English subscription-removal log text.
controller/​acp_controller.php Validates VAPID credentials before saving enabled settings.

Review effort: Balanced

Comment thread subscription/validator.php Resolved
Comment thread styles/all/template/push_worker.js.twig Resolved
Comment thread styles/all/template/webpush.js Resolved
@iMattPro
iMattPro requested a balanced review from Copilot November 13, 2026 21:50

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI 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.

🟡 Changes recommended

Approval is blocked by two active issues: relative notification URLs can resolve to the wrong board path, and account switching leaves a foreign push subscription active.

3 open issues
1 resolved since last review

Review effort: Lite

Comment thread styles/all/template/webpush.js Resolved
@iMattPro

Copy link
Copy Markdown
Contributor Author

🟡 Changes recommended

Approval is blocked by two active issues: relative notification URLs can resolve to the wrong board path, and account switching leaves a foreign push subscription active.

3 open issues

1 resolved since last review
Review effort: Lite

Checking current files and commit/index state. Copilot may be reviewing stale base, staged-only diff, or missing that fixes landed in separate commits.

All three Copilot findings are stale/incorrect against current origin/fixes (322719f).

  1. Ownership after VAPID rotation: resolved

401/403 no longer delete subscription rows. Cleanup now calls should_remove_subscription(), which removes only library-expired 404/410 subscriptions or .invalid endpoints:

Thus ownership row survives rotation, and JavaScript guard permits automatic stale-key refresh. Tests explicitly verify 401/403 retention.

  1. Legacy notification URLs: resolved

Legacy payload branch now converts relative URLs to board-absolute URLs before returning JSON:

Current payload URLs remain unchanged and resolve against worker location. Tests cover ./viewtopic.php, subfolder board path, absolute links, and unsafe schemes.

  1. VAPID validity and pair matching: resolved

Copilot stops reading at VAPID::validate(). Code immediately afterward:

  • Calls existing is_valid() for strict Base64URL, P-256 point, and curve validation.
  • Builds ES256 JWK.
  • Signs validation input with private key.
  • Verifies signature with public key.

See pair validation. Mismatched valid keys have dedicated regression test.

No further code changes needed. Copilot review should be rerun against current commit; these comments can be refuted with references above.

Copilot AI 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.

🟡 Changes recommended

The change leaves current relative notification URLs resolving against the worker path, producing incorrect board URLs in push notifications.

1 open issue
3 resolved since last review

Review effort: Lite


try {
const url = new URL(event.notification.data.url, '{{ U_BOARD_URL|e("js") }}/');
const url = new URL(event.notification.data.url, self.location.href);
@iMattPro
iMattPro merged commit 7edb777 into phpbb-extensions:main Nov 13, 2026
33 checks passed
@iMattPro
iMattPro deleted the fixes branch November 13, 2026 22:25
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.

3 participants