#17943: fix: use 0o644 for inbound media files to allow sandbox read access
size: XS
experienced-contributor
Cluster:
Browser Security Enhancements
## Summary
Fixes #17941
Inbound media files were saved with `0o600` permissions (`-rw-------`), making them unreadable from Docker sandbox containers running as different users.
## Changes
- Change file mode from `0o600` to `0o644` in `saveMediaSource()` and `saveMediaBuffer()`
## Why 0o644?
- Owner can read/write
- Group and others can read (required for sandbox access)
- The containing directory already uses `0o700`, so only users with directory access can see filenames
- Media files are not sensitive credentials — they're user-uploaded attachments
---
🤖 Generated with Claude Code
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR changes media file permissions from `0o600` to `0o644` in `saveMediaSource()` (local file path) and `saveMediaBuffer()` to allow Docker sandbox containers running as different users to read inbound media files. The rationale is sound — media files are user-uploaded attachments (not credentials), and the parent directory already uses `0o700` to restrict directory-level access.
However, the fix is **incomplete for URL-sourced media**:
- The `downloadToFile` helper at line 152 still uses `createWriteStream(dest, { mode: 0o600 })`. When `saveMediaSource` processes a URL, it calls `downloadToFile` to write a `.tmp` file, then renames it. Since `fs.rename` preserves permissions, the final file retains `0o600` — leaving URL-downloaded media unreadable from the sandbox.
<h3>Confidence Score: 2/5</h3>
- This PR partially fixes the sandbox read-access issue but misses the URL download path, leaving the bug unfixed for a significant code path.
- The two changed lines are correct on their own, but the `downloadToFile` function (line 152) was not updated, which means URL-sourced media still gets `0o600` permissions. This is a functional gap that undermines the stated goal of the PR.
- `src/media/store.ts` — the `downloadToFile` function at line 152 still uses `0o600` and needs to be updated to `0o644`.
<sub>Last reviewed commit: 7c006bb</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17944: fix(security): fail-closed for local media paths without sandboxRoot
by Operative-001 · 2026-02-16
79.0%
#19344: fix(sandbox): allow writes when workspaceAccess is 'none'
by mingming099 · 2026-02-17
76.6%
#4226: Fix/sandbox containerworkdir rw access
by ozgur-polat · 2026-01-29
75.8%
#16922: fix: remove incorrect sandbox file tool guidance
by carrotRakko · 2026-02-15
75.7%
#20991: fix(sandbox): fall back to gateway UID:GID when no user is configur...
by cluster2600 · 2026-02-19
75.0%
#16509: Fix sandbox path validation rejecting Docker bind mount paths
by Clawborn · 2026-02-14
74.8%
#9817: fix(media): resolve relative paths before reading local files (#8759)
by lailoo · 2026-02-05
74.4%
#18811: fix(media): require file extension for ambiguous MEDIA: path detection
by aldoeliacim · 2026-02-17
73.6%
#17402: fix:sandbox path issue
by luckylhb90 · 2026-02-15
73.5%
#11820: fix(sandbox): remap container paths in sandboxed file tools
by steflsd · 2026-02-08
73.4%