-
-
Notifications
You must be signed in to change notification settings - Fork 27
fix: set IPC socket permissions to 0600 for security #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,20 @@ impl IpcServer { | |
| let opts = ListenerOptions::new().name(fs_name("main")?); | ||
| debug!("Listening on {}", env::IPC_SOCK_MAIN.display()); | ||
| let (tx, rx) = tokio::sync::mpsc::channel(1); | ||
|
|
||
| // Set restrictive umask before creating socket to avoid TOCTOU race condition. | ||
| // This ensures the socket is created with 0600 permissions from the start. | ||
| #[cfg(unix)] | ||
| let old_umask = unsafe { libc::umask(0o077) }; | ||
|
|
||
| let listener = opts.create_tokio().into_diagnostic()?; | ||
|
|
||
| // Restore original umask | ||
| #[cfg(unix)] | ||
| unsafe { | ||
| libc::umask(old_umask); | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Process-wide umask affects concurrent file operationsMedium Severity The |
||
|
|
||
| tokio::spawn(async move { | ||
| loop { | ||
| if let Err(err) = Self::listen(&listener, tx.clone()).await { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.