User tests: Successful: Unsuccessful:
Add Path::check() validation to file operation methods in TemplateModel
that were missing it, consistent with getSource() which already uses it.
Affected methods: save(), deleteFile(), renameFile(), cropImage(), resizeImage()
all accepted a base64-encoded file parameter without validating the decoded
path stays within the template directory, allowing directory traversal via
sequences such as /../../../ to read, write, rename or delete files anywhere
under JPATH_ROOT.
Path::check() validation has been added to five file operation methods in
TemplateModel that were missing it. Path::clean() alone only normalises
path separators; it does not prevent ../ directory traversal. Path::check()
resolves the path and verifies it stays within JPATH_ROOT, throwing an
exception on traversal attempts.
Methods patched: save(), deleteFile(), renameFile(), cropImage(),
resizeImage(). The fix follows the pattern already used by getSource() in
the same class (line 945).
file parameter (base64-encoded).base64_encode("/../../../configuration.php").Before patch: the operation proceeds on configuration.php outside the
template directory.
After patch: Joomla displays an error message and refuses the operation.
File operations (save, deleteFile, renameFile, cropImage, resizeImage)
in the template editor accept a base64-encoded path parameter that is decoded
and used without traversal validation. A /../ sequence in the decoded value
allows the operation to target any file under JPATH_ROOT, including
configuration.php and files in libraries/, plugins/, etc.
All five file operation methods reject paths containing ../ sequences with an
error message, confining template file operations to the template directory.
Behaviour is now consistent with getSource(), which already applied
Path::check().
| Status | New | ⇒ | Pending |
| Category | ⇒ | Administration com_templates |
Thank you for your contribution, but please stop submitting AI PR proposals. See the AI policy you checked and hopefully read before. We're looking for thoughtful contributions. See this as a first warning.
In general it is not a bad idea to restrict the template manager to edit files only in its own directory.
If you have access to the template manager (restricted to super users) then you really can do anything you want