GHSA-f6wf-28g6-769x: Path Traversal
When Smarty's Security policy is enabled, securedir (and the configured template/trusted directories) restrict which local files a template may read via {include} and {fetch}. The trust check in Security::checkDir() resolved the requested path with Smarty::realpath(), which normalizes the path as a string only and does not follow symbolic links. A symlink placed inside a trusted directory therefore passed the trust check, while the underlying filegetcontents() followed it to an arbitrary file outside the sandbox (e.g. /etc/passwd).
Impact An attacker able to (a) cause a symlink to exist inside a trusted directory (e.g. a user-upload area located within the template path) and (b) cause a template to reference that path can read arbitrary files readable by the PHP process, escaping the securedir boundary. Confidentiality impact only.
Patches Fixed in 5.8.2. Security::checkDir() now resolves the requested file with native realpath() and re-validates the canonical, symlink-free path against the trusted directories (which are canonicalized the same way, so legitimate symlinked deployment paths such as a Capistrano current symlink or macOS /var → /private/var keep working). It falls back to string normalization only when the file does not yet exist on disk.
Workarounds Ensure no untrusted symlinks can be created within any directory listed in securedir/the trusted template directories; restrict write access to those directories to trusted processes only.
References - Fix commit: 99c048c - CWE-22
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/smarty/smartyto a version that resolves this vulnerability.Fixed in 4.5.7 - Upgrade
Upgrade
composer/smarty/smartyto a version that resolves this vulnerability.Fixed in 5.8.2 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 5.8.2 - Configuration
Ensure no untrusted symlinks can be created within any directory listed in secure_dir / the trusted template directories; restrict write access to those directories to trusted processes only.
Smarty Security policy (secure_dir / trusted template directories) secure_dir / template trusted directories = Restrict write access so untrusted symlinks cannot be created within any directory listed in secure_dir and the trusted template directories - Compensating control
If applicable, rely on Smarty Security policy enforcement: when enabled, secure_dir (and configured template/trusted directories) restrict which local files a template may read via {include} and {fetch}.
Event History
Frequently Asked Questions
What is the severity of GHSA-f6wf-28g6-769x?
The severity of GHSA-f6wf-28g6-769x is rated at a risk level of 33.
How do I fix GHSA-f6wf-28g6-769x?
To fix GHSA-f6wf-28g6-769x, ensure that your Smarty installation is updated to the latest version that includes security patches.
What type of vulnerability is GHSA-f6wf-28g6-769x?
GHSA-f6wf-28g6-769x is a Path Traversal vulnerability affecting Smarty's Security policy.
Which software is affected by GHSA-f6wf-28g6-769x?
The GHSA-f6wf-28g6-769x vulnerability affects the composer/smarty/smarty software package.
What security feature does GHSA-f6wf-28g6-769x impact?
GHSA-f6wf-28g6-769x impacts the secure_dir setting in Smarty's Security policy, limiting file access through templates.