Skip to content

Commit

Permalink
Disabled unix sockets being wrongfully sent to the agent when socket …
Browse files Browse the repository at this point in the history
…isn't connected
  • Loading branch information
aviramha committed Feb 5, 2024
1 parent 514f084 commit deab1c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/+unix-socket-falsely-sent.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled unix sockets being wrongfully sent to the agent when socket isn't connected
16 changes: 15 additions & 1 deletion mirrord/layer/src/socket/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
};

use errno::set_errno;
use libc::{c_int, c_void, hostent, sockaddr, socklen_t};
use libc::{c_int, c_void, hostent, sockaddr, socklen_t, AF_UNIX};
use mirrord_config::feature::network::incoming::IncomingMode;
use mirrord_intproxy_protocol::{
ConnMetadataRequest, ConnMetadataResponse, NetProtocol, OutgoingConnectRequest,
Expand Down Expand Up @@ -1135,6 +1135,13 @@ pub(super) fn send_to(
.remove(&sockfd)
.ok_or(Bypass::LocalFdNotFound(sockfd))?;

// we don't support unix sockets which don't use `connect`
if (destination.is_unix() || user_socket_info.domain == AF_UNIX)
&& user_socket_info.user_socket_info.state != SocketState::Connected

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_aarch64-unknown-linux-gnu

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_x86_64-unknown-linux-gnu

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_macos

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1140 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`
{
return Bypass::UnixSocket(destination);

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_aarch64-unknown-linux-gnu

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_aarch64-unknown-linux-gnu

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_x86_64-unknown-linux-gnu

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_x86_64-unknown-linux-gnu

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_macos

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_macos

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types

Check failure on line 1142 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types
}

// Currently this flow only handles DNS resolution.
// So here we have to check for 2 things:
//
Expand Down Expand Up @@ -1214,6 +1221,13 @@ pub(super) fn sendmsg(
.remove(&sockfd)
.ok_or(Bypass::LocalFdNotFound(sockfd))?;

// we don't support unix sockets which don't use `connect`
if (destination.is_unix() || user_socket_info.domain == AF_UNIX)
&& user_socket_info.user_socket_info.state != SocketState::Connected

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_aarch64-unknown-linux-gnu

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_x86_64-unknown-linux-gnu

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_macos

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`

Check failure on line 1226 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

no field `user_socket_info` on type `std::sync::Arc<socket::UserSocket>`
{
return Bypass::UnixSocket(destination);

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / check-rust-docs

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / lint

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / integration_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_aarch64-unknown-linux-gnu

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_aarch64-unknown-linux-gnu

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / macos_tests

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_x86_64-unknown-linux-gnu

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_x86_64-unknown-linux-gnu

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_macos

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / build_binaries_macos

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (docker)

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types

Check failure on line 1228 in mirrord/layer/src/socket/ops.rs

View workflow job for this annotation

GitHub Actions / e2e (containerd)

mismatched types
}

// Currently this flow only handles DNS resolution.
// So here we have to check for 2 things:
//
Expand Down

0 comments on commit deab1c1

Please sign in to comment.