Unsafe path traversal in app.py image extraction #15

Open
opened 2026-03-19 17:31:11 +00:00 by llabeyrie · 0 comments
Owner

Description

In app.py lines 24-28, the _extract_image_from_stdout() function resolves paths from pipeline stdout without validating they stay within the project directory:

candidate = Path(text)
if not candidate.is_absolute():
    candidate = APP_DIR / candidate   # line 25

if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists():
    return candidate                  # returned without validation!

Problem

If the pipeline stdout contains a line like ../../etc/passwd.png, the path resolves outside APP_DIR. While exploitation requires control of stdout, the defense-in-depth principle applies — especially since stdout is a mix of debug prints and real output (issue #3).

Fix

candidate = (APP_DIR / candidate).resolve()
if not str(candidate).startswith(str(APP_DIR.resolve())):
    continue  # skip paths outside project directory
## Description In `app.py` lines 24-28, the `_extract_image_from_stdout()` function resolves paths from pipeline stdout without validating they stay within the project directory: ```python candidate = Path(text) if not candidate.is_absolute(): candidate = APP_DIR / candidate # line 25 if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists(): return candidate # returned without validation! ``` ### Problem If the pipeline stdout contains a line like `../../etc/passwd.png`, the path resolves outside `APP_DIR`. While exploitation requires control of stdout, the defense-in-depth principle applies — especially since stdout is a mix of debug prints and real output (issue #3). ### Fix ```python candidate = (APP_DIR / candidate).resolve() if not str(candidate).startswith(str(APP_DIR.resolve())): continue # skip paths outside project directory ```
llabeyrie added the bugpriority: low labels 2026-03-19 17:31:50 +00:00
Sign in to join this conversation.