CVE-2026-62992
JSON

6.9medium

Smarty: Symlink path traversal out of trusted directories

Severity
6.9medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.36% (higher than 32% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-f6wf-28g6-769x

Description

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to 5.8.2 (and 4.5.7 on the 4.x line), Security::_checkDir() does not fully resolve symbolic links before validating that a requested path lies within a configured secure directory. An attacker able to place or reference a symlink within a directory Smarty treats as trusted (e.g., a template or config directory) could use it to point outside the intended secure directory, bypassing the containment check and reading arbitrary files accessible to the PHP process. This issue is fixed in versions 5.8.2 and 4.5.7.

Affected

Product or packageVersionsReported by
smarty-php smarty>= 5.0.0, < 5.8.2, < 4.5.7CVE List
smarty/smarty (Packagist)from 5.0.0 before 5.8.2, before 4.5.7GitHub Advisory Database

All scores

GitHub_M6.9medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N

Classification

CWE-22CWE-61

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to 5.8.2 (and 4.5.7 on the 4.x line), Security::_checkDir() does not fully resolve symbolic links before validating that a requested path lies within a configured secure directory. An attacker able to place or reference a symlink within a directory Smarty treats as trusted (e.g., a template or config directory) could use it to point outside the intended secure directory, bypassing the containment check and reading arbitrary files accessible to the PHP process. This issue is fixed in versions 5.8.2 and 4.5.7.

GitHub Advisory Database

When Smarty's Security policy is enabled, secure_dir (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 file_get_contents() 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 secure_dir 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 secure_dir/the trusted template directories; restrict write access to those directories to trusted processes only.

References

  • Fix commit: 99c048c
  • CWE-22
NVD (es)

Smarty es un motor de plantillas para PHP, que facilita la separación de la presentación (HTML/CSS) de la lógica de la aplicación. Antes de la versión 5.8.2 (y 4.5.7 en la línea 4.x), Security::_checkDir() no resuelve completamente los enlaces simbólicos antes de validar que una ruta solicitada se encuentra dentro de un directorio seguro configurado. Un atacante capaz de colocar o referenciar un enlace simbólico dentro de un directorio que Smarty considera de confianza (por ejemplo, un directorio de plantillas o de configuración) podría usarlo para apuntar fuera del directorio seguro previsto, eludiendo la comprobación de contención y leyendo archivos arbitrarios accesibles al proceso PHP. Este problema está solucionado en las versiones 5.8.2 y 4.5.7.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-62992 changed 2026-08-07CVE Terms of Use
GitHub Advisory DatabaseGHSA-f6wf-28g6-769x changed 2026-08-07CC-BY-4.0
NVDCVE-2026-62992 changed 2026-10-24Public domain