← Back to Baseline

MB-0003

Automated Webroot hygiene (no .git/.env/backups in pub/)

MB-C01 File & Folder Permissions High

Webroot hygiene (no .git/.env/backups in pub/); assess only the collected Magento deployment scope.

Overview

Webroot hygiene (no .git/.env/backups in pub/); assess only the collected Magento deployment scope.

Why it Matters

The Magento webroot (pub/) must stay clean and only contain files needed for the storefront. If old developer files, backups, or hidden files like .git or .env remain inside, attackers can easily download them and learn about your database, passwords, or source code.

Exposed artifacts give attackers an easy entry point without needing to exploit complex bugs. Keeping the webroot free of leftover files reduces information leaks and protects the store from quick, automated attacks that scan for these common mistakes.

Verification Steps

Manual Verification

  1. Review pub including hidden files and symlinks.
  2. Check the deployed server document root, then inspect any repository, environment or backup artifact without opening secrets in shared output.
  3. Confirm removals in the deployed release.

Command / Review Sample

find pub -maxdepth 3 -name .git -print
find pub -maxdepth 3 -name .env -print
find pub -maxdepth 3 -iname '*.bak' -print

Use the assessed Magento project and the appropriate application or read-only review account. Replace example hosts, paths and identifiers with the assessment scope; configuration and source fragments are illustrative.

Remediation / Fix Guidance

  1. Investigate and change: Move the reported Git metadata, environment files, database dumps or backups outside pub and any served alias. Add explicit edge/origin access denial for sensitive paths and invalidate any cached exposed artifacts.
  2. Validate the change: Request the previously exposed paths without credentials and confirm denial/absence; rotate credentials if secret contents were exposed.
  3. Recheck MB-0003: Verify access as the relevant runtime identity and retest the affected upload, cache or release feature after the scoped change. Rerun against the same deployment; avoid recursive permission changes unrelated to the reported paths.

Examples

Illustrative examples only. Interpret them within the current revision criterion above; missing collection evidence is unresolved, never PASS.

Fail Example

pub/.git or pub/database-backup.sql is deployed under the document root.

Pass Example

No sensitive deployment artifacts occur in the completely reviewed pub tree.

Scope and Evidence Limits

Rule revision: 3. Target modes: LOCAL.

Webroot hygiene (no .git/.env/backups in pub/); assess only the collected Magento deployment scope.

This check covers only the collected observation. Missing collection scope, external controls and runtime behavior require separate evidence.

Catalog coverage describes implementation capability, not a scan outcome. An incomplete manual review cannot establish that the criterion is satisfied.

References