[LOW] [CORE-3] EventManager::isOwnerActive Fail-Opens on Any Throwable — Disabled/Errored Plugin Still Runs Hooks
Audit Finding: CORE-3
- Severity:
LOW - Category: Core / Event
- File:
/home/z/my-project/ownpay/src/Event/EventManager.php:170-198
Description
isOwnerActive($owner) resolves whether a plugin's hook should fire for the current brand. The catch block on line 193-194 returns true for any \Throwable raised during the BrandContext::getActiveBrandId() or PluginRegistry::isPluginActive() lookups. The docblock on line 194 ("return true" on error) is fail-open: if the plugin registry throws (DB connection blip, misconfigured plugin manifest, deserialization error in op_plugins.manifest JSON, etc.), the hook is treated as active and runs anyway — even for a plugin that the merchant has explicitly deactivated.
Impact
A plugin that the merchant deactivated continues to receive db.query.before filters, payment.transaction.completed actions, etc. — for as long as the registry lookup keeps throwing. Combined with FINDING DB-1 (db.query.before can rewrite any SQL), this means a "deactivated but broken" plugin can silently continue intercepting queries. The merchant sees the plugin as "Inactive" in the admin UI but it is still executing PHP code on every request.
Reproduction
Install a plugin whose manifest JSON in op_plugins.manifest is corrupted (e.g., by a failed plugin update). Deactivate the plugin in the admin UI. The PluginRegistry::isPluginActive() lookup throws when decoding the manifest. isOwnerActive() catches the throwable and returns true. The plugin's db.query.before filter continues to fire on every query.
Recommended Fix
Fail closed for non-core owners: catch (\Throwable $e) { $this->logHookError('isOwnerActive', $owner, $e); return false; }. Log the error so the operator can see why the plugin was suspended. The current return true is a footgun that prioritizes availability over the merchant's explicit deactivation intent.
Discovered during comprehensive codebase audit. See /home/z/my-project/worklog.md for full audit context.
Duplicate Issue — Closed
This issue is a duplicate of #413 (same audit finding CORE-3 — both issues share the same title, file path, and description).
The fix has been implemented and is ready for review in PR #524: https://github.com/own-pay/OwnPay/pull/524
Tracking will continue under the canonical issue #413, which is referenced by the PR's Closes #413 line and will be auto-closed when the PR merges.
Closing this duplicate as not_planned to keep the audit tracker clean.