Skip to content

[BUG] Meta and output files written inside box directory are readable by sandboxed code #9

Description

@ombagal777

Description

The engine currently writes stdout/stderr and related metadata files into paths under the sandbox box directory (e.g., box/compile_stdout.txt, box/run_stdout.txt). Because these files live inside the isolate box filesystem, untrusted user code running in the sandbox can read them.

This is “not harmful but sloppy” for stdout/stderr, it is still a privilege‑leak pattern and could interact badly with future meta fields or sensitive headers.

Impact

  • Sandbox code can read its own compile_stdout.txt and run_stdout.txt.
  • If future changes store more sensitive information in these files (e.g., internal debug output, error traces with environment details), that information becomes visible to untrusted code.
  • Breaks the principle of least privilege between engine internals and sandbox processes.

Expected Behavior

  • Engine‑internal meta and output files are stored outside the box directory and are not directly readable by sandboxed processes.
  • Only the engine process should have access to those files; user code should see them only via the API response.

Actual Behavior

  • Stdout/stderr files are written inside the box (e.g., box/compile_stdout.txt).
  • Sandbox code can open and read them.

Possible Solution

  • Write stdout/stderr and meta files to a directory outside the box (e.g., /tmp/chadbox/<boxId>/...) and pass absolute paths to isolate using --stdout, --stderr, and meta flags.
  • Ensure that only the engine process has filesystem permissions to read these paths.
  • Keep the box directory limited to user‑controlled code and data only.

Activity

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions