Nested imports of MaterialX files can lead to a crash via stack memory exhaustion, due to the lack of a limit on the "import chain" depth.
The MaterialX specification supports importing other files by using XInclude tags.
When parsing file imports, recursion is used to process nested files in the form of a tree with the root node being the first MaterialX files parsed.
However, there is no limit imposed to the depth of files that can be parsed by the library, therefore, by building a sufficiently deep chain of MaterialX files one referencing the next, it is possible to crash the process using the MaterialX library via stack exhaustion.
This test is going to employ Windows UNC paths, in order to make the Proof Of Concept more realistic. In fact, by using windows network shares, an attacker would be able to exploit the vulnerability (in Windows) if they could control the content of a single .mtlx file being parsed.
Note that for the sake of simplicity the PoC will use the MaterialXView application to easily reproduce the vulnerability, however it does not affect MaterialXView directly.
In order to reproduce this test, please follow the steps below:
impacket package (the documentation of the package suggests using pipx, as in python3 -m pipx install impacket ).template.mtlx with the following content:<?xml version="1.0"?>
<materialx version="1.39" colorspace="lin_rec709">
<xi:include href="\\\\{ip}\\{name}.mtlx"/>
<surfacematerial name="Aluminum_Brushed" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="open_pbr_surface_surfaceshader" />...
1.39.21.39.3Exploitability
AV:NAC:LAT:NPR:NUI:NVulnerable System
VC:NVI:NVA:LSubsequent System
SC:NSI:NSA:N5.5/CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:P