Skip to content

fix: mediapool: block dangerous extensions in any filename segment#6538

Merged
gharlan merged 2 commits into
5.xfrom
fix/mediapool-multi-extension-bypass
Jun 1, 2026
Merged

fix: mediapool: block dangerous extensions in any filename segment#6538
gharlan merged 2 commits into
5.xfrom
fix/mediapool-multi-extension-bypass

Conversation

@gharlan
Copy link
Copy Markdown
Member

@gharlan gharlan commented Jun 1, 2026

isAllowedExtension only rejected a blocked extension when it was the terminal extension or the segment directly before it (*.php.). Filenames with a blocked extension as a non-terminal segment in a chain of three or more, e.g. shell.php.any.jpg, slipped through and could be executed as PHP on web servers that map handlers via a multi-extension match (mod_mime AddHandler / non-anchored FilesMatch).

Check each dot-separated segment against the blocked list instead. This matches whole segments, so it still allows foo.json and js_datei.txt (no false positive), while also fixing a case-sensitivity gap in the previous str_ends_with check (it ran against the raw filename).

Regression introduced in 9d00869 (#6213).

isAllowedExtension only rejected a blocked extension when it was the
terminal extension or the segment directly before it (*.php.<ext>).
Filenames with a blocked extension as a non-terminal segment in a chain
of three or more, e.g. shell.php.any.jpg, slipped through and could be
executed as PHP on web servers that map handlers via a multi-extension
match (mod_mime AddHandler / non-anchored FilesMatch).

Check each dot-separated segment against the blocked list instead. This
matches whole segments, so it still allows foo.json and js_datei.txt
(no false positive), while also fixing a case-sensitivity gap in the
previous str_ends_with check (it ran against the raw filename).

Regression introduced in 9d00869 (#6213).
@rex-bot rex-bot added the bug label Jun 1, 2026
@gharlan gharlan added this to the REDAXO 5.21.1 milestone Jun 1, 2026
@gharlan gharlan merged commit 462e368 into 5.x Jun 1, 2026
18 checks passed
@gharlan gharlan deleted the fix/mediapool-multi-extension-bypass branch June 1, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants