Skip to content

Bun.cron(…) writes logs to the insecure globally shared temp dir on macOS #28298

Closed

Description

@lgarron

What version of Bun is running?

1.3.11

What platform is your computer?

macOS 26.3.1

What steps can reproduce the bug?

Register and run a job using Bun.cron(…)

What is the expected behavior?

Logs are not leaked to all other users on the system.

What do you see instead?

The daemon config at ~/Library/LaunchAgents/ use the following temp dirs:

    <key>StandardOutPath</key>
    <string>/tmp/bun.cron.(title).stdout.log</string>
    <key>StandardErrorPath</key>
    <string>/tmp/bun.cron.(title).stderr.log</string>

This is shared by all users. From Apple's docs: https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585-SW10

The temporary directories in macOS are shared among multiple users. This requires that they be writable by multiple users. Any time you work on files in a location to which others have read/write access, there’s the potential for the file to be compromised or corrupted.

The best way to handle this is to create a safe temporary directory that only you can access, then write the files into that directory.

To do this:

In a cocoa app, call NSTemporaryDirectory.
At the POSIX layer, call confstr and pass the constant _CS_DARWIN_USER_TEMP_DIR as the name parameter.

If the path needs to be deterministically derived for a given job, placing them under https://developer.apple.com/documentation/foundation/nstemporarydirectory() would be best.

(I'd personally also use this chance to group bun cron folders under a parent folder to avoid writing a whole bunch of files at the top level, but this is not so severe an issues since it's a temp dir.)

Additional information

No response

Activity

  1. changed the title [-]`Bun.cron(…)` writes logs to the insecure globally shared temp dir[/-] [+]`Bun.cron(…)` writes logs to the insecure globally shared temp dir on macOS[/+] on Mar 20, 2026
  2. added 8 commits that reference this issue on Mar 20, 2026
    d7e9942
    352cf4b
    132e09f
    27b832b
    e418842
    6f8953d
    7bbd93b
  3. added 4 commits that reference this issue on May 30, 2026
    504c4a8
    bb294ef
    f540bd3
    082412e
  4. added a commit that references this issue on Nov 19, 2026
    cdd3144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions