GHSA-qc2h-74x3-4v3w MaterialX Lack of MTLX Import Depth Limit Leads to DoS (Denial-Of-Service) Via Stack Exhaustion
SummaryNested 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.DetailsThe MaterialX [specification](https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/documents/Specification/MaterialX.Specification.md#mtlx-file-format-definition) 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.PoCThis 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:Compile or download the MaterialXView application in a Windows machineIn a separate Linux machine in the same local network, install the `impacket` package (the documentation of the package suggests using `pipx`, as in `python3 -m pipx install impacket
`).In the Linux machine, create a file named `template.mtlx` with the following content:In the same directory, create a file named `script.py` with the following content:Run the python script with the following command line, replacing the `$IP` placeholder with the IP address of your interface (the command will take some time to execute): `python3 script.py --iterations 1048576 template.mtlx chain $IP chain`This will print, in the console, a line documenting the UNC path of the first file of the chain. Copy that path in the clipboard.Spawn the SMB server by executing the following command line: `pipx run --spec impacket smbserver.py -smb2support chain chain/`In the Windows machine, create a MaterialX file with the following content, replacing the `$UNCPATH` placeholder with the content of the path printed at step 5:Load the MaterialX file in MaterialXViewNotice that the viewer doesn't respond anymore. After some minutes, notice that the viewer crashes, demonstrating the Stack ExhaustionNote: by consulting the Windows `Event Viewer`, it is possible to examine the application crash, verifying that it is indeed crashing with a `STATUS_STACK_OVERFLOW (0xc00000fd)`.ImpactAn attacker exploiting this vulnerability would be able to intentionally stall and crash an application reading MaterialX files controlled by them.In Windows, the attack complexity is lower, since the malicious MaterialX file can reference remote paths via the UNC notation. However, the attack would work in other systems as well, provided that the attacker can write an arbitrary amount of MaterialX files (implementing the chain) in the local file system.
CVSS v4.0 score: 5.5