fix: apply traversal-safe path normalization to direct-fetch asset fallback - #5
Open
Smeagol1907 wants to merge 1 commit into
Open
fix: apply traversal-safe path normalization to direct-fetch asset fallback#5Smeagol1907 wants to merge 1 commit into
Smeagol1907 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
loadMuJoCoAssets() extracts texture/mesh file paths from task XML via
/ attributes, then loads each asset
either from a zip index or by falling back to a direct fetch.
The zip-lookup path is traversal-safe: buildZipCandidates() calls
normalizeZipPath(), which strips ".." segments before using the path as a
map key. The direct-fetch fallback, however, used the raw assetPath
straight from the regex-extracted XML attribute with no normalization at
all, before concatenating it into
${apiBase}/${apiPath}and fetching it.I haven't been able to confirm end-to-end whether task XML is ever
attacker-influenced in the production task-authoring flow (the task
generation tooling in this org looks server-side/offline from what's
public), so I can't say for certain this is reachable by an external
attacker today. Still, it's an inconsistency worth closing: one code path
in the same function treats this exact string as untrusted and sanitizes
it, the other doesn't.
Fix: normalize assetPath through the same normalizeZipPath() function
before it's used for either the zip lookup or the direct-fetch fallback,
so both paths get identical treatment. Verified normal paths pass through
unchanged and "../" sequences get safely collapsed rather than escaping
the intended directory.