Commit Graph
21 Commits
Author SHA1 Message Date
Jash 31959be5ff fix: send correct content types and attachment disposition for exports refs #5708 2026-11-13 14:15:01 +05:30
Jash c4c5e2b15c fix: remove an export's working directory once its archive is built and the archive once it is downloaded fixes #5583 2026-11-12 03:36:15 +05:30
Isaac ConnorandClaude Opus 4.8 0fd646ef2e fix: reject path traversal in export download and archive views refs GHSA-fvx4-86xp-9v22
views/download.php and views/archive.php sanitized the user-controlled
`file` and `export_root` request parameters with str_replace('/', '')
only, which strips slashes but leaves `..` intact. export_root=.. made the
resolved path climb out of DIR_EXPORTS_DOWNLOAD into ZM_DIR_EXPORTS (and,
with file=.. as well, higher), and download.php then readfile()s it and,
from its shutdown handler, @unlink()s it. Any user with Events or Snapshots
view permission could read and delete files the web user can reach outside
the downloads directory.

Add safeExportComponent() and pathWithinExportDir() in
download_functions.php. The export file and directory names these views
handle are always single path components (zmExport_<connkey>.zip, a merged
'<Monitor> <start> to <end>.mp4'), so safeExportComponent() rejects any
value with a directory separator, a null byte, or a '.'/'..' traversal and
falls back to the generated default. pathWithinExportDir() resolves the
final path with realpath() and is checked in front of readfile() and
unlink(), so a path that still escapes the export directory - including
through a symlink - is refused.

Tests: tests/php/test_download_path_traversal.php

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-01 22:04:58 -05:00
Isaac Connor 8ddec91870 Allow snapshot downloading 2021-08-18 10:53:59 -04:00
Isaac Connor bed41ca44b Support specifying the export filename by passing the export_root 2021-08-05 13:30:52 -04:00
Isaac Connor 10c0a6617c Return Debug to a regular function to match other logging functions. Since we switched to using namespaces we no longer clash with cake_php. 2020-10-14 10:39:25 -04:00
Isaac Connor d99ec696b4 reorganize to reduce code depth 2020-04-10 12:21:53 -04:00
Isaac Connor 5d72e3b1b5 ensure no output buffering when downloading an archive. 2020-04-03 15:33:28 -04:00
Isaac Connor fd310c0f0a Merge branch 'master' into storageareas 2019-02-22 11:33:47 -05:00
Isaac Connor 5098329d94 remove ob_clean stuff which logs errors when output buffering is turned off (#2395)
* remove ob_clean stuff which logs errors when output buffering is turned off.

* Don't ob_clean because if buffering is off php will output an error
2019-02-22 09:58:16 -05:00
Isaac Connor 8dd8888975 Php namespace (#2537)
* experiment with namespaces on the Server class

* experiment with namespaces on the Server class

* Implement the ZM namespace on objects

* Implement the ZM namespace on objects

* Implement the ZM namespace on objects
2019-02-22 09:19:07 -05:00
Isaac Connor 9c437b0303 Merge branch 'add_export_to_filter' into storageareas 2018-09-25 14:35:19 -04:00
Isaac Connor 5dba17e1fc Merge branch 'master' into storageareas 2018-09-21 10:50:10 -04:00
Andrew Bauer 347c0d2ae4 fix whitespace 2018-09-20 13:41:13 -05:00
Andrew Bauer ac9129b632 fix corrupted export downloads 2018-09-20 13:36:52 -05:00
Isaac Connor 40292f3dad Add Compression flag 2018-09-07 09:08:33 -04:00
Isaac Connor 62946578c6 Use to determine export filename 2018-07-09 12:02:05 -04:00
Isaac 337db8bb18 Include Content-Length so we get a download progress 2018-05-18 15:52:30 +02:00
Isaac e364a541d4 Whitespace and use ZM_DIR_EXPORT instead of ZM_DIR_TMP 2018-01-24 22:21:43 +01:00
digital-gnome 4f5677eb3b Remove time limit from archive download for exceptionally large files 2017-12-03 14:42:08 -05:00
Andrew Bauer 200f92b1ad make zmexport not rely on symlinks in the webroot (#1888)
* make zmexport not rely on symlinks in the webroot

* add archive view
2017-05-17 11:30:39 -04:00