Skip to content

security: prevent path traversal in ezcCacheStorageFile::generateIdentifier()#4

Open
se7enxweb wants to merge 1 commit intozetacomponents:masterfrom
se7enxweb:security/fix-path-traversal
Open

security: prevent path traversal in ezcCacheStorageFile::generateIdentifier()#4
se7enxweb wants to merge 1 commit intozetacomponents:masterfrom
se7enxweb:security/fix-path-traversal

Conversation

@se7enxweb
Copy link
Copy Markdown

Reported-by: CJW Network security audit 2026-03-01

Problem

generateIdentifier() replaces / with DIRECTORY_SEPARATOR but never canonicalises the resulting path. An ID containing .. sequences can escape the configured cache $location directory, causing cache reads/writes/deletes outside the intended directory.

Changes

src/storage/file.php

After building the identifier string, resolve the target directory with realpath() and verify it starts with the cache base directory. Throw ezcBaseValueException if the resolved path escapes the base.

Security fixes

  • Path traversal (CWE-22)

…tifier()

The method replaced '/' with DIRECTORY_SEPARATOR but never canonicalized
the resulting path, so IDs containing '..' sequences could escape the
configured cache location directory.

Fix: after building the identifier string, resolve the target directory
with realpath() and verify it starts with the cache base directory.
ezcBaseValueException is thrown if the resolved path escapes the base.

Reported-by: CJW Network security audit 2026-03-01
Security-fixes: path-traversal (CWE-22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant