PHP object injection via Yaml::PARSE_OBJECT when parsing OpenAPI/JSON-Schema specs
Description
PHP object injection via Yaml::PARSE_OBJECT when parsing OpenAPI/JSON-Schema specs
Summary
SchemaParser::parseSchema() parses YAML specification files with Symfony's Yaml::PARSE_OBJECT flag enabled, which runs PHP's unserialize() on any !php/object tag in the document. A spec that Jane reads can therefore instantiate arbitrary PHP objects and fire their magic methods at generation time.
Affected
- Package:
jane-php/open-api-3(and the sharedjane-php/open-api-common) - Version tested: 8.1.2 (latest on Packagist)
- Dependency:
symfony/yaml8.1.11
Details
Jane\Component\OpenApiCommon\SchemaParser\SchemaParser::parseSchema() first tries to decode the spec as JSON. When that fails, which is the normal case for the YAML specs most people write, it falls through to the YAML branch:
// src/Component/OpenApiCommon/SchemaParser/SchemaParser.php:45
$content = Yaml::parse(
$openApiSpecContents,
Yaml::PARSE_OBJECT | Yaml::PARSE_DATETIME | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE
);PARSE_OBJECT is the Symfony flag that resolves the !php/object tag by calling unserialize() on the tag's payload. Symfony's own documentation flags it as unsafe for untrusted input. An OpenAPI document is pure data, so there's no reason it should ever be allowed to reconstruct live PHP objects.
The injection happens during the parse call, before denormalize() or any schema validation runs, so none of the downstream OpenAPI checks ever get a chance to reject it.
The same flag combination appears a second time in src/Component/JsonSchemaRuntime/Reference.php:163, applied to the content of a fetched $ref document. In 8.1.2 a remote $ref requires the non-default allow-external-refs: true, but a local YAML $ref confined to the spec directory (allowed by default) still reaches it. This sink sits inside the doResolve() method that CVE-2026-63415 hardened in 7.12.0; see "Relationship to existing advisories" below.
Proof of concept
Install the real package and parse a YAML spec carrying a canary object:
openapi: "3.0.0"
info: {title: x, version: "1"}
paths: {}
pwn: !php/object 'O:9:"PocCanary":1:{s:6:"marker";s:11:"/tmp/canary";}'$parser = new Jane\Component\OpenApi3\SchemaParser\SchemaParser(/* denormalizer */);
$parser->parseSchema('/path/to/evil.yaml'); // PocCanary::__wakeup() runs hereIn my test (PHP 8.5.4, jane-php/open-api-3 8.1.2, symfony/yaml 8.1.11) the canary's __wakeup() wrote its marker file every run. That confirms the bytes ran through unserialize() via Jane's public API, not a direct Symfony call I made myself.
Impact
This is a PHP object injection (CWE-502). On its own it gives an attacker arbitrary object instantiation and magic-method execution. Whether that reaches file write or RCE depends on the POP gadgets autoloaded in the consuming application. The usual Symfony/Guzzle/Monolog/Doctrine stacks have well-known chains (e.g. via phpggc). I did not weaponize a chain; the confirmed primitive is the object injection itself.
The realistic precondition: an attacker controls the OpenAPI/JSON-Schema document fed to Jane, or a local YAML $ref it pulls in. That's a real scenario wherever specs come from a third party: a vendor-published openapi.yaml, a spec contributed to a repo, or a CI job generating a client from an external API description. A developer generating a client from someone else's spec would not expect a YAML tag to run code.
Relationship to existing advisories
This is a distinct vulnerability from the four advisories published for jane-php in July 2026, and one of them is directly adjacent:
- CVE-2026-63415 (GHSA-c3cj-3p6p-j822: SSRF/LFI via
$refresolution inReference.php::doResolve, fixed in 7.12.0) patched where a$refmay point. 8.1.2 now enforces a scheme allowlist (Reference.php:234), confines local$reftargets to allowed directories (:280-288), and gates remote refs behind the non-defaultallow-external-refs(:323). That fix edited the exactdoResolve()method quoted above but left theYaml::PARSE_OBJECTflag on the fetched content (:163-164) in place. Restricting the target of a$refdoes not stop the fetched document from being deserialized, so the object-injection sink survived the fix. This is an incomplete-fix finding adjacent to CVE-2026-63415, not a re-report of it. - CVE-2026-63411 / 63412 / 63413 (PHPDoc
*/breakout to codegen RCE, fixed 7.12.0) are a different mechanism (comment-context escaping in generated code). They share only the threat model: an attacker-influenced OpenAPI document consumed at generation time, with a developer running the generator. That threat model, including the user-interaction precondition this report also carries, was accepted for all four CVEs.
The primary sink here (SchemaParser.php:45, the top-level spec parse) is independent of all four. It fires on any YAML spec with no $ref and no non-default option.
Suggested fix
Drop PARSE_OBJECT from both call sites. It isn't needed to read a spec:
src/Component/OpenApiCommon/SchemaParser/SchemaParser.php:47src/Component/JsonSchemaRuntime/Reference.php:164
Keep PARSE_DATETIME / PARSE_OBJECT_FOR_MAP as before; only the object-instantiation flag needs to go.
Severity
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H = 7.0 (High)
AV:L and UI:R because a local build-time process consumes the spec and a developer runs the generator. The high C/I/A reflect the ceiling once a gadget is present; the guaranteed, demonstrated impact is the injection primitive.
Disclosure
Reported under coordinated disclosure, 90-day timeline from acknowledgment. Happy to share the full PoC project and help verify the fix.