Skip to content

Commit d88d3d5

Browse files
committed
test(mxc): validate proxy identity using the live socket owner
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent b9d217e commit d88d3d5

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • crates/openshell-supervisor/src/backend_setup

‎crates/openshell-supervisor/src/backend_setup/tests.rs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,23 @@ fn mxc_setup_preserves_admitted_identity_and_constructs_only_mxc() {
698698
let proxy = built.proxy_listener.unwrap();
699699
assert_eq!(proxy.bind_addr, launch.proxy.bind_addr);
700700
assert_eq!(proxy.authorization.as_ref(), launch.proxy.authorization);
701+
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
702+
let client = std::net::TcpStream::connect(listener.local_addr().unwrap()).unwrap();
703+
let (server, peer) = listener.accept().unwrap();
704+
let socket_identity = (proxy.identity_resolver)(peer, server.local_addr().unwrap()).unwrap();
701705
assert_eq!(
702-
proxy.binary_identity.executable.path,
706+
std::fs::canonicalize(&socket_identity.executable.path).unwrap(),
707+
std::fs::canonicalize(std::env::current_exe().unwrap()).unwrap()
708+
);
709+
assert!(socket_identity.executable.digest.is_some());
710+
assert_ne!(
711+
socket_identity.executable.path,
703712
launch.proxy.workload_binary
704713
);
714+
// A missing connection must fail closed instead of using the launch binary.
715+
assert!((proxy.identity_resolver)(peer, "127.0.0.1:0".parse().unwrap()).is_err());
716+
drop(client);
717+
drop(server);
705718

706719
// Selecting a Windows implementation does not waive main's identity checks.
707720
let mut foreign_auth = setup.auth.clone();

0 commit comments

Comments
 (0)