PHP 8.2.30
Preview: TempFileHandling.md Size: 797 B
/opt/cpanel/ea-ruby27/src/passenger-release-6.1.2/doc/TempFileHandling.md

# Handling of temp files

Always use unpredictable filenames for temp files. Failing to do so makes us vulnerable to symlink attacks, TOCTOU race conditions, file squatting, or even information disclosure and privilege escalation.

Always use a tempfile creation strategy that atomically:
1. Finds a free filename, *and*,
2. Reserves that filename (failing if it already exists), *and*,
3. Restrict permissions to only the intended user (e.g. mode 0600),
Doing these non-atomically makes us vulnerable to TOCTU race conditions.

Implementation tips:
- Use getSystemTempDir()
- Use mkstemp() for single, regular files. Don't use it for non-regular files such as Unix sockets; use a temp dir instead.
- Use mkdtemp() for creating a temp dir or for storing temp non-regular files.
- mktemp() is bad.

Directory Contents

Dirs: 3 × Files: 8

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-13 08:03:52
Edit Download
images DIR
- drwxr-xr-x 2026-02-13 08:03:52
Edit Download
templates DIR
- drwxr-xr-x 2026-02-13 08:03:52
Edit Download
6.63 KB lrw-r--r-- 2026-01-27 23:50:52
Edit Download
2.93 KB lrw-r--r-- 2026-01-27 23:50:52
Edit Download
982 B lrw-r--r-- 2026-01-27 23:50:52
Edit Download
2.97 KB lrw-r--r-- 2026-01-27 23:50:52
Edit Download
4.95 KB lrw-r--r-- 2026-01-27 23:50:52
Edit Download
3.50 KB lrw-r--r-- 2026-01-27 23:50:52
Edit Download
12.53 KB lrw-r--r-- 2026-01-27 23:50:52
Edit Download
797 B lrw-r--r-- 2026-01-27 23:50:52
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).