GHSA-2pj4-v76f-wjvx: baserCMS: Path Traversal Bypass via realpath() in BcThemeFileService (CVE-2026-30940 Patch Bypass)
- Source:
- OSV.dev
- Published:
- Fetched:
- Updated:
- Affects:
- baserproject/baser-core
https://osv.dev/vulnerability/GHSA-2pj4-v76f-wjvx ↗
baserCMS: Path Traversal Bypass via realpath() in BcThemeFileService (CVE-2026-30940 Patch Bypass) ### Summary The security patch introduced in baserCMS 5.2.3 to address CVE-2026-30940 / [GHSA-c5c6-37vq-pjcq](https://github.com/baserproject/basercms/security/advisories/GHSA-c5c6-37vq-pjcq) is **incomplete**. The patch added a `realpath()`-based directory traversal check in `BcThemeFileService::getFullpath()`, but the check is **entirely skipped** when `realpath($baseDir)` returns `false` — which occurs whenever the target subdirectory does not physically exist on disk. An authenticated administrator can bypass the patch by supplying a `type` value (e.g., `js`) that maps to a non-existent directory in the theme. The absence of the directory causes `realpath()` to return `false`, the validation block is skipped, and the raw `path` parameter containing `../` sequences is returned unvalidated. This enables arbitrary file write and remote code execution (RCE) — the exact same impact as the original CVE. **This vulnerability was verified exploitable on baserCMS 5.2.3 (the "patched" version of CVE-2026-30940).** ### Details The vulnerability exists in `BcThemeFileService::getFullpath()` at [`plugins/bc-theme-file/src/Service/BcThemeFileService.php` lines 70–82](https://github.com/baserproject/basercms/blob/5.2.x/plugins/bc-theme-file/src/Service/BcThemeFileService.php#L70): ```php public function getFullpath(string $theme, string $plugin, string $type, string $path) { // ...build $baseDir and $fullPath from $theme, $type, $path... $baseDir = $viewPath . $type . DS; // e.g. .../BcThemeSample/webroot/js/ $fullPath = $baseDir . $path; // e.g. .../webroot/js/../../../../webroot/ $resolvedBase = realpath($baseDir); if ($resolvedBase !== false) { // ← BYPASS: entire block skipped when dir absent $resolvedBase = rtrim($resolvedBase, DS) . DS; $targetDir = realpath(dirname($fullPath)); if ($targetDir === false) { $targetDir = $this->normalizePath(dirname($fullPath)); } if (!str_starts_with(rtrim($targetDir, DS) . DS, $resolvedBase)) { throw new BcException(__d('baser_core', 'パスにテーマディレクトリ外への参照が含まれています。')); } } return $fullPath; // ← Returns unvalidated path when realpath returns false } ``` **Root cause — the bypass condition:** | `realpath($baseDir)` result | Behavior | |-----------------------------|----------| | Valid path string (dir **exists**) | Validation runs → `../` traversal **blocked** ✓ | | `false` (dir does **not** exist) | Validation **skipped entirely** → `../` traversal **allowed** ✗ | **Difference from CVE-2026-30940 (original bug):** | | CVE-2026-30940 (≤ 5.2.2) | This bypass (5.2.3) | |--|--|--| | Validation | None at all | `realpath()` check — but conditional | | `type` needed | Any valid type (`layout`, `cell`, …) | Must map to a **non-existent** subdirectory | | `path` blocked | Never | Only when target dir already exists | | Root cause | Missing validation | `if ($resolvedBase !== false)` skips fal Affected: Packagist:baserproject/baser-core Fixed in: 5.3.0 References: https://github.com/baserproject/basercms/security/advisories/GHSA-2pj4-v76f-wjvx https://nvd.nist.gov/vuln/detail/CVE-2026-62955 https://github.com/baserproject/basercms/commit/464227b8770704076ee6eddd4bd464c184786eca https://github.com/baserproject/basercms/commit/c650017acf5dfbfd15eb2f3eda07967bcb002be2 https://github.com/baserproject/bc-theme-file/commit/a8f90096f13eca576a87cb25aa02e8f54642af7e https://github.com/baserproject/basercms https://github.com/baserproject/basercms/releases/tag/5.3.0