OwnPay icon indicating copy to clipboard operation
OwnPay copied to clipboard

[MEDIUM] [UPD-2] HealthChecker Storage-Write Check Passes When Directory Does Not Exist (False Positive)

Open fattain-naime opened this issue 3 months ago • 1 comments

Audit Finding: UPD-2

  • Severity: MEDIUM
  • Category: Update
  • File: /home/z/my-project/ownpay/src/Update/HealthChecker.php:146-157

Description

checkWritable() iterates over ['storage', 'storage/cache', 'storage/logs'] and for each: if (is_dir($path) && !is_writable($path)) returns an error. The logic is inverted — it only reports a problem when the directory EXISTS and is NOT writable. If the directory does NOT exist (e.g., the update package failed to create storage/cache/, or a cleanup script removed it), is_dir returns false, the condition is false, and the check passes with ok: true. The update is then marked healthy (line 370-372 of UpdateService) and maintenance mode is exited, but the application will crash on the first request that tries to write to the missing directory.

Impact

After an update that fails to create or populate storage/cache/ or storage/logs/, the health check reports healthy: true, maintenance mode is exited, and production traffic immediately fails with 500 errors (Twig cannot write compiled templates, Logger cannot write log files). The admin sees "Update completed successfully" followed by a broken site.

Reproduction

  rm -rf /var/www/ownpay/storage/cache
  php -r "require 'vendor/autoload.php'; print_r((new \OwnPay\Update\HealthChecker())->check());"
  # Output: [writable] => ['ok' => true, 'error' => null]  <-- false positive

Recommended Fix

Change the condition to require both existence and writability: if (!is_dir($path) || !is_writable($path)) { return ['ok' => false, 'error' => "Missing or not writable: {$dir}"]; }.



Discovered during comprehensive codebase audit. See /home/z/my-project/worklog.md for full audit context.

fattain-naime avatar Aug 12 '26 23:08 fattain-naime

Duplicate Issue — Closed

This issue is a duplicate of #379 (same audit finding UPD-2 — both issues share the same title, file path, and description).

The fix has been implemented and is ready for review in PR #523: https://github.com/own-pay/OwnPay/pull/523

Tracking will continue under the canonical issue #379, which is referenced by the PR's Closes #379 line and will be auto-closed when the PR merges.

Closing this duplicate as not_planned to keep the audit tracker clean.

fattain-naime avatar Aug 13 '26 15:08 fattain-naime