Skip to content

fix: mitigate unauthenticated path traversal in genmedia SPA routing#2214

Open
AK47Kavan wants to merge 1 commit into
google:mainfrom
AK47Kavan:fix/genmedia-path-traversal
Open

fix: mitigate unauthenticated path traversal in genmedia SPA routing#2214
AK47Kavan wants to merge 1 commit into
google:mainfrom
AK47Kavan:fix/genmedia-path-traversal

Conversation

@AK47Kavan

Copy link
Copy Markdown

Fixes #2201

Description

This PR resolves the unauthenticated path traversal vulnerability reported in issue #2201 within the genmedia-for-commerce application routing.

Changes

  • Replaced direct unsafe path concatenation with absolute path resolution via pathlib.Path.resolve().
  • Implemented a strict safe_path.is_relative_to(resolved_frontend_dir) check to ensure that the resolved asset path cannot traverse outside the boundary of the designated frontend assets directory.
  • Preserved the original SPA behavior and fallback rules while explicitly returning a 403 Forbidden JSON response if a path traversal attempt is detected.

Verification

  • Confirmed that directory climbing patterns (e.g., ../../) are safely caught and rejected by the validation step.
  • Ensured local formatting remains compliant with the repository's rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unauthenticated Path Traversal in genmedia-for-commerce FastAPI SPA route (Arbitrary File Read)

1 participant