Repository navigation
Description
Affected versions: confirmed on commit 036dfcc2a86bed3767fde88ea0bdc243ff81b709 (current default branch, master).
Summary
Stride's custom YAML deserializer (Stride.Core.Yaml) resolves an unrecognized YAML tag directly to a .NET type via reflection against every loaded assembly, including the standard library, with no check on what the resolved type actually is. The resolved type is then instantiated via the object factory and has its properties populated directly from the YAML mapping. This is reached whenever any Stride asset YAML file (.sdscene, .sdprefab, etc) is parsed, which happens from the ordinary workflow of opening a project or package, not only from running your own compiled code.
Details
sources/core/Stride.Core.Yaml/Serialization/YamlAssemblyRegistry.cs, TypeFromTag() (around lines 185-234): when a YAML node's tag isn't already a known registered alias, it resolves the tag string via ResolveType().
ResolveSingleType() (around lines 293-328): does assembly.GetType(typeName) against every assembly in lookupAssemblies, which always includes mscorlib/CoreLib (typeof(int).Assembly) plus every assembly registered via AssetYamlSerializer/YamlSerializer.RegisterAssembly. No base-type/interface constraint and no allowlist or denylist is applied to the result.
sources/core/Stride.Core.Yaml/Serialization/Serializers/TagTypeSerializer.cs, ReadYaml(): sets the deserialization context's type descriptor to the resolved type, only checking that a type was resolved at all, not what it is.
sources/core/Stride.Core.Yaml/Serialization/Serializers/ObjectSerializer.cs, CreateOrTransformObject() (around line 133-139): unconditionally instantiates the resolved type via ObjectFactory.Create().
sources/core/Stride.Core.Yaml/Serialization/DefaultObjectFactory.cs: the only gate before Activator.CreateInstance(type) is that the type has a public parameterless constructor, a shape check rather than a security check.
Live validation confirmed this end to end with a harmless test type (a plain class with one settable string property, no [DataContract] attribute): feeding !ProbeType\nMessage: hello-from-yaml through the real, unmodified Stride.Core.Yaml deserializer (via the same SerializerSettings.RegisterAssembly API Stride's own code uses) produced an instance of that type with its property populated from the YAML mapping. No allowlist, denylist, or [DataContract] gate exists anywhere in this chain prior to the fix in the attached PR.
Steps To Reproduce
(available upon request)
Impact
Opening a Stride project, package, or any individual asset file from an untrusted source (cloning a shared repository, downloading a sample project or template, collaborating on a shared package) parses its .sdscene/.sdprefab/asset YAML files through this deserializer. A YAML tag in such a file can cause the deserializer to instantiate any public, parameterless-constructible type currently loaded in the process, not just types intended for asset serialization, and to populate its properties directly from attacker-controlled YAML content. This was confirmed to work end to end against a harmless demonstration type; whether a specific loaded type's property setters can be chained into a more severe outcome (code execution, file write, etc) was not investigated as part of this report, consistent with responsible-disclosure scope, but the underlying primitive (arbitrary type instantiation plus property injection driven by untrusted input) is itself the reportable issue, matching the well-documented risk class of unconstrained polymorphic deserialization (CWE-502).
CVSS 3.1: AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L (approximately 5.4, Medium)
CWE-502 (Deserialization of Untrusted Data)
A fix PR is attached: requires the resolved type (or a base type it inherits DataContractAttribute.Inherited from) to carry [DataContract] before TypeFromTag() returns it, mirroring the identical inheritance-walk already used elsewhere in the codebase (ObjectDescriptor's constructor) to resolve DefaultMemberMode from the same attribute. Verified in an isolated build: an unmarked type now fails resolution the same way an unknown tag already did, while a [DataContract]-marked type of the same shape still deserializes correctly.
Activity