Skip to content

Prevent cross-user tampering of extracted PHAR resources - #145

Merged
pyrech merged 2 commits into
jolicode:mainfrom
thomas-chauchefoin-tob:security/private-phar-extraction-directory
Sep 29, 2026
Merged

pyrech merged 2 commits into
jolicode:mainfrom
thomas-chauchefoin-tob:security/private-phar-extraction-directory

Conversation

@thomas-chauchefoin-tob

@thomas-chauchefoin-tob thomas-chauchefoin-tob commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

PHAR resources are currently extracted to a predictable directory under sys_get_temp_dir()/jolinotif. On systems with a shared temporary directory, another local user could pre-create these paths and place a malicious FFI header, causing JoliNotif to load an attacker-controlled shared library.

This change moves extraction into a private cache, $HOME/.jolinotif on Linux and macOS and %LOCALAPPDATA%\JoliNotif on Windows. It also includes a SHA-256 digest of the PHAR in the cache name to prevent distinct versions from reusing/overwriting each other's resources, and it attempts to handle concurrent access.

@pyrech I'm just starting with a CI run on this one and will ping you later for a more thorough review; the tests likely need more work.

Comment thread src/Util/PharExtractor.php Resolved
Comment thread src/Util/PharExtractor.php Resolved
Comment thread src/Util/PharExtractor.php Resolved
Comment thread src/Util/PharExtractor.php Resolved
Comment thread src/Util/PharExtractor.php Resolved
Comment thread src/Util/PharExtractor.php Resolved
Comment thread tests/Util/PharExtractorTest.php Resolved
@pyrech
pyrech force-pushed the security/private-phar-extraction-directory branch from 3c8076a to 95dfee1 Compare September 29, 2026 12:06
@pyrech

pyrech commented Sep 29, 2026

Copy link
Copy Markdown
Member

Thanks a lot for your PR @thomas-chauchefoin-tob

I have just squashed your commits and applied review suggestions.

Comment thread src/Util/PharExtractor.php Resolved
Follow the XDG cache directory, fall back to the temporary directory when the home is not usable, prune stale directories and never let an extraction failure break the host application.
@pyrech
pyrech force-pushed the security/private-phar-extraction-directory branch from 95dfee1 to 8396d09 Compare September 29, 2026 12:21

@pyrech pyrech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@pyrech
pyrech merged commit 793872e into jolicode:main Sep 29, 2026
8 checks passed
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.

3 participants