Skip to content

Refuse to open a pre-existing log file - #2068

Merged
cgutman merged 1 commit into
moonlight-stream:masterfrom
ccowan93:fix/log-file-symlink
Oct 24, 2026
Merged

cgutman merged 1 commit into
moonlight-stream:masterfrom
ccowan93:fix/log-file-symlink

Conversation

@ccowan93

Copy link
Copy Markdown
Contributor

On macOS, release builds log to /tmp/Moonlight-<epoch>.log. /tmp is shared between users and the name is predictable. Another local user can plant symlinks at upcoming log names, and Moonlight will then truncate and write through them into any file the victim can write. The log was also created world-readable.

This opens the log with QIODevice::NewOnly (O_CREAT|O_EXCL), so an existing file or symlink is never opened. On Qt 6.3+ the file is also created with owner-only permissions. If the open fails we keep logging to stderr, as before.

Tested (macOS, Qt 6.12, release build):

  • Symlinks were planted at the next 30 seconds of log names, pointing at a canary file. Before: the canary was overwritten with Moonlight's log. After: the canary is untouched and Moonlight logs to stderr.
  • Normal launch: the log file is created as -rw-------.

🤖 Generated with Claude Code

On macOS, release builds log to /tmp/Moonlight-<epoch>.log. /tmp is
shared by all users and the file name is predictable, so another local
user could plant symlinks at upcoming log names and have Moonlight
truncate and overwrite any file the victim can write to. The log was
also created world-readable.

Open the log with QIODevice::NewOnly (O_CREAT|O_EXCL) so an existing
file or symlink is never opened, and create it readable only by the
owner on Qt 6.3+. If the open fails we keep logging to stderr, as we
already did for any other open failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cgutman
cgutman merged commit 8f2e52e into moonlight-stream:master Oct 24, 2026
5 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.

2 participants