fix(editor): texture exporter rejects path-traversal in source M2/WMO texture paths

Texture paths come from M2/WMO files which a malicious zone author
could craft to include '..' or absolute paths. Without this check,
exporting such a zone would write PNGs outside outputDir/textures/
and clobber sibling export files.
This commit is contained in:
Kelsi 2026-05-06 06:12:11 -07:00
parent b5a9ce7816
commit bbfc364119

View file

@ -117,6 +117,14 @@ int TextureExporter::exportTexturesAsPng(pipeline::AssetManager* am,
if (dotPos != std::string::npos)
outPath = outPath.substr(0, dotPos) + ".png";
// Reject path-traversal attempts in the source path. Texture paths
// come from M2/WMO files which a malicious zone could craft.
if (outPath.find("..") != std::string::npos ||
(!outPath.empty() && (outPath[0] == '/' || outPath[0] == '\\'))) {
LOG_WARNING("Texture path rejected (traversal attempt): ", texPath);
continue;
}
std::string fullPath = outputDir + "/" + outPath;
fs::create_directories(fs::path(fullPath).parent_path());