Code injection (RCE) via patternProperties regex key verbatim-emitted into generated normalizers (jane-php/json-schema)
Description
jane-php's generated JSON (de)normalizers emit the patternProperties regex key from an input JSON-Schema / OpenAPI document into generated PHP as a raw '/.../' string literal through a php-parser Name node (not a Scalar\String_ node). php-parser prints a Name node verbatim, so the quote auto-escaping that protects every other schema-text sink never runs. The only sanitization applied to the attacker-controlled key is str_replace('/', '\\/', $pattern), which escapes the regex delimiter and nothing else — single quotes pass through unescaped. A patternProperties key containing single quotes closes the '/.../' literal and injects arbitrary PHP into executable expression position inside the generated normalize() / denormalize() method bodies (CWE-94). When the generated SDK is loaded and a model is (de)serialized, the injected code executes.
This is the same vulnerability CLASS as CVE-2026-63411/63412/63413 (attacker-controlled schema text → generated PHP → RCE) but a distinct, unreported sink: a different package (jane-php/json-schema), different files (Normalizer generators / PatternMultipleType), a different breakout mechanism (single-quote string-literal breakout via a Name node, not a PHPDoc */ breakout), and a different entry field (schema patternProperties key, not an OpenAPI parameter name/description). The PHPDoc fix commit 0ea379dea does not touch any of these files.
Root Cause
At four sink sites the regex is built as a raw PHP string and wrapped in a Name node:
new Expr\ConstFetch(new Name("'/" . str_replace('/', '\\/', $pattern) . "/'"))Because php-parser pretty-prints a Name node literally (no escaping), and str_replace only touches /, a key such as '.phpinfo().' produces preg_match('/'.phpinfo().'/', (string) $key) — valid, executable PHP.
Sink sites (paths on v8.1.2):
src/Component/JsonSchema/Generator/Normalizer/DenormalizerGenerator.php:277(createPatternPropertiesDenormalizationStatements)src/Component/JsonSchema/Generator/Normalizer/NormalizerGenerator.php:276(createPatternPropertiesNormalizationStatements)src/Component/JsonSchema/Guesser/Guess/PatternMultipleType.php:74(createDenormalizationStatement)src/Component/JsonSchema/Guesser/Guess/PatternMultipleType.php:115(createNormalizationStatement)
Impact
Arbitrary PHP code execution. The injected expression runs inside the generated normalizer whenever the SDK is used (de)serialization of the corresponding model). In a typical workflow (a developer / CI runs jane against a shared, third-party, or URL-fetched OpenAPI/JSON-Schema document), this yields RCE on the build/runtime host. Same impact class the maintainer rated CRITICAL for the sibling PHPDoc sink.
Proof of Concept
Schema:
{"type":"object","patternProperties":{"'.phpinfo().'":{"type":"string"}}}Generating a normalizer for this schema emits (verbatim):
if (preg_match('/'.phpinfo().'/', (string) $key)) { ... }which is valid PHP and executes phpinfo() when the generated normalizer is loaded. A chr()-encoded file_put_contents(...) payload embedded in the key was generated via the exact sink, the output was required, and the marker file was written to disk — confirming arbitrary code execution (verified with php-parser v5.6.1 / v5.9.0, within jane's ^5.1).
Note: a single-quote-containing payload must avoid inner single quotes (they collide with the outer literal). Use a numeric index ('.system($_GET[0]).'), chr(), or base64_decode() instead of $_GET['c'].
Attack Chain
- Entry — Attacker supplies a schema with an object whose
patternPropertieshas a malicious KEY, e.g.{"type":"object","patternProperties":{"'.phpinfo().'":{"type":"string"}}}.
- Guard:
TypeArrayValidator(OpenApi3). Bypass proof: it is purely diagnostic — only flagstype:[...]arrays and treatspatternPropertieschildren as property names; no charset/format check on the key (TypeArrayValidator.phpPROPERTY_MAP_KEYSwhitelists traversal, validates nothing). Key accepted unchanged.
- Propagation — key flows guesser →
ClassGuess→Jane.phprekey → generator.
- Guard: none. Bypass proof: every hop uses
$patternas a verbatim array key (ObjectGuesser::resolveAdditionalPropertiesObjectGuesser.php:92-96;PatternPropertiesGuesser::addTypePatternPropertiesGuesser.php:45-46;Jane.php:85-89;ClassGuess::getExtensionsType()ClassGuess.php:111). NoNaming::cleaning()on extension keys.
- Sink emission — generator builds
new Expr\ConstFetch(new Name("'/" . str_replace('/', '\\/', $pattern) . "/'"))at the 4 sink sites above.
- Guard:
str_replace('/', '\\/', ...). Bypass proof: payload contains no/; it uses'(single quote), whichstr_replacedoes not touch.
- Pretty-print — php-parser prints the node.
- Guard: AST
Scalar\String_auto-escaping (the PHPDoc-sink primary defense). Bypass proof: sink uses aNamenode, notScalar\String_; ran php-parser — key'.phpinfo().'prints VERBATIM aspreg_match('/'.phpinfo().'/', (string) $key)and re-parses as valid PHP.
- Execution — generated normalizer is loaded and the model is (de)serialized → injected expression executes. Live PoC: chr()-encoded
file_put_contentsin the key → generated coderequired → marker file written. RCE confirmed.
Bypass Evidence
KEY: '.phpinfo().' → preg_match('/'.phpinfo().'/', (string) $key) → VALID PHP: YES
KEY: '.system($_GET[0]).'→ preg_match('/'.system($_GET[0]).'/', (string) $key) → VALID PHP: YES
KEY: '.print_r(1).' → preg_match('/'.print_r(1).'/', (string) $key) → VALID PHP: YES
LIVE: chr()-encoded file_put_contents payload in key → generated code require'd → marker file WRITTEN ⇒ RCE CONFIRMEDAffected Versions
<= 8.1.2 (all releases). Sink present since 7.0.0 (introduced in commit 806687e99); verified present on latest release tag v8.1.2; no fix on any released tag or on HEAD. Fix commit 0ea379dea (PHPDoc */ hardening) does not touch any of the 4 sink files. The vulnerable component is jane-php/json-schema; jane-php/open-api-common, jane-php/open-api-3, and jane-php/open-api-3-1 inherit the sink via class inheritance.
Suggested Fix
Emit the regex through an auto-escaped literal — new Scalar\String_('/' . str_replace('/', '\\/', $pattern) . '/') — or preg_quote($pattern, '/'), at all four sink sites.
--- Reported by zx (Jace) — GitHub: @manus-use