fix: path traversal in web_ui
This commit is contained in:
@@ -37,8 +37,8 @@ async def index_html(rest_of_path: str):
|
|||||||
"""
|
"""
|
||||||
if rest_of_path.startswith("api") or rest_of_path.startswith("."):
|
if rest_of_path.startswith("api") or rest_of_path.startswith("."):
|
||||||
raise HTTPException(status_code=404, detail="Not Found")
|
raise HTTPException(status_code=404, detail="Not Found")
|
||||||
uibase = Path(__file__).parent / "ui/installed/"
|
uibase = (Path(__file__).parent / "ui/installed/").resolve()
|
||||||
filename = uibase / rest_of_path
|
filename = (uibase / rest_of_path).resolve()
|
||||||
# It's security relevant to check "relative_to".
|
# It's security relevant to check "relative_to".
|
||||||
# Without this, Directory-traversal is possible.
|
# Without this, Directory-traversal is possible.
|
||||||
media_type: str | None = None
|
media_type: str | None = None
|
||||||
|
|||||||
Reference in New Issue
Block a user