PharData always creates new files with mode 0666
| Sec Bug #77022 | PharData always creates new files with mode 0666 | ||||
|---|---|---|---|---|---|
| Submitted: | 2018-10-16 09:23 UTC | Modified: | 2020-01-08 17:49 UTC | ||
| From: | prose at zedcore dot com | Assigned: | stas (profile) | ||
| Status: | Closed | Package: | PHAR related | ||
| PHP Version: | 7.1.23 | OS: | |||
| Private report: | No | CVE-ID: | None | ||
[2018-10-16 09:23 UTC] prose at zedcore dot com
Description: ------------ When using PharData to create a Tar archive and then extracting it, the umask is not respected and/or the permissions of the original file are not either. If the tar utility is used to either create or extract the file, then the permissions are preserved. As the composer library uses this to create archives of dependencies that it then installs, it opens up the chance for someone to edit Test script: --------------- // Also available at 3v4l - https://3v4l.org/PO3hN var_dump(decoct(umask())); $sFile = tempnam('/tmp', 'test'); var_dump(decoct(stat($sFile)['mode'])); $phar = new \PharData('/tmp/test.tar', null, null, \Phar::TAR); $phar->addFile($sFile, 'test-file-phar'); $phar->extractTo('/tmp/'); var_dump(decoct(stat('/tmp/test-file-phar')['mode'])); Expected result: ---------------- The last two var_dumps should give the same file permissions Actual result: -------------- The second var_dump gives 100666 instead of 100600
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2018-11-26 11:17 UTC] prose at zedcore dot com
[2018-12-02 03:47 UTC] stas@php.net
[2018-12-02 05:02 UTC] stas@php.net
-Summary: PharData ignores umask +Summary: PharData always creates new files with mode 0666
[2018-12-02 05:20 UTC] stas@php.net
-Assigned To: +Assigned To: stas
[2018-12-02 05:50 UTC] stas@php.net
-Status: Assigned +Status: Closed
[2018-12-03 11:25 UTC] prose at zedcore dot com
-Summary: PharData always creates new files with mode 0666 +Summary: prose@zedcore.com
[2018-12-03 11:25 UTC] prose at zedcore dot com
[2018-12-03 14:04 UTC] cmb@php.net
[2018-12-03 14:17 UTC] prose at zedcore dot com
[2020-01-08 17:49 UTC] cmb@php.net
-Summary: prose@zedcore.com +Summary: PharData always creates new files with mode 0666