fix(security): restrict permissions on service tmp dir and log file#2502
fix(security): restrict permissions on service tmp dir and log file#2502ColinM-sys wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
/tmp/nemoclaw-services-{name}/ was created with the default 0o755 mode,
making cloudflared.log world-readable. The log contains the public
*.trycloudflare.com tunnel URL, which any local user on a multi-user
system could read and use to probe the dashboard.
Set the directory to 0o700 and the log file to 0o600 so only the
owning user can access them.
Signed-off-by: ColinM-sys <cmcdonough@50words.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThe PR updates Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/services.ts`:
- Line 126: The log file is opened with openSync(logFile, "w", 0o600) but that
mode only applies on create; if cloudflared.log already exists its permissions
can remain world-readable—after calling openSync and assigning to logFd add a
call to fchmodSync(logFd, 0o600) to force owner-only permissions; locate the
openSync usage that assigns to logFd in src/lib/services.ts and invoke
fchmodSync(logFd, 0o600) immediately after opening (keep the same logFile and
logFd symbols).
- Around line 63-65: The code only sets mode in mkdirSync which doesn’t change
permissions on existing pidDir or log files; update the pid directory and any
service log/pid file handling to explicitly call fs.chmodSync after
creation/existence check so permissions are enforced—e.g., after using mkdirSync
or when you compute pidDir (refer to the pidDir variable and the
mkdirSync/existsSync block), call chmodSync(pidDir, 0o700); likewise, after
creating/opening service files (where openSync is used) call
chmodSync(logPathOrPidFile, 0o600) to tighten permissions for existing objects.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c08043df-dfe3-43d8-8597-43fd2f5d28cf
📒 Files selected for processing (1)
src/lib/services.ts
…rs and logs The previous commit set the mode in mkdirSync and openSync, but those only apply at creation time. If the pid directory or log file already exists from a prior run the permissions were never updated. Add chmodSync(pidDir, 0o700) unconditionally after the existence check, and fchmodSync(logFd, 0o600) immediately after openSync so permissions are enforced regardless of whether the objects were just created. Signed-off-by: ColinM-sys <cmcdonough@50words.com>
|
✨ Thanks for submitting this pull request that proposes a way to fix a security bug by restricting permissions on the service tmp dir and log file, making the cloudflared.log file no longer world-readable. |
`/tmp/nemoclaw-services-{name}/` was created with the default 0o755
mode, making `cloudflared.log` world-readable. The log contains the
public `*.trycloudflare.com` tunnel URL — any local user on a
multi-user system could read it and use the URL to probe the dashboard
from anywhere on the internet.
Set the directory to 0o700 and the log file to 0o600 so only the
owning user can access them.
Signed-off-by: ColinM-sys cmcdonough@50words.com
Summary by CodeRabbit