1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
use super::{
Error, TestContext, helpers,
helpers::{connect_and_wait, send_guest_probes},
};
use mullvad_management_interface::MullvadProxyClient;
use std::net::SocketAddr;
use test_macro::test_function;
use test_rpc::ServiceClient;
/// Verify that traffic to private IPs is blocked when
/// "local network sharing" is disabled, but not blocked
/// when it is enabled.
/// It only checks whether outgoing UDP, TCP, and ICMP is
/// blocked for a single arbitrary private IP and port.
#[test_function]
pub async fn test_lan(
_: TestContext,
rpc: ServiceClient,
mut mullvad_client: MullvadProxyClient,
) -> Result<(), Error> {
// Take care not to use some bogus IP in the guest's subnet, lest we just send ARP requests
// These will fail if there's no actual host present
let lan_destination = "10.1.2.3:1234".parse().unwrap();
// Disable LAN sharing
//
log::info!("LAN sharing: disabled");
mullvad_client
.set_allow_lan(false)
.await
.expect("failed to disable LAN sharing");
// Connect
//
connect_and_wait(&mut mullvad_client).await?;
// Ensure LAN is not reachable
//
log::info!("Test whether outgoing LAN traffic is blocked");
let default_interface = rpc.get_default_interface().await?;
let detected_probes =
send_guest_probes(rpc.clone(), default_interface.clone(), lan_destination).await;
assert!(
detected_probes.none(),
"observed unexpected outgoing LAN packets: {detected_probes:?}"
);
// Enable LAN sharing
//
log::info!("LAN sharing: enabled");
mullvad_client
.set_allow_lan(true)
.await
.expect("failed to enable LAN sharing");
// Ensure LAN is reachable
//
log::info!("Test whether outgoing LAN traffic is blocked");
let detected_probes = send_guest_probes(rpc.clone(), default_interface, lan_destination).await;
assert!(
detected_probes.all(),
"did not observe all outgoing LAN packets: {detected_probes:?}"
);
Ok(())
}
/// Enable lockdown mode. This test succeeds if:
///
/// * Disconnected state: Outgoing traffic leaks (UDP/TCP/ICMP) cannot be produced.
/// * Disconnected state: Outgoing traffic to a single private IP can be produced, if and only if
/// LAN sharing is enabled.
/// * Connected state: Outgoing traffic leaks (UDP/TCP/ICMP) cannot be produced.
///
/// # Limitations
///
/// These tests are performed on one single public IP address
/// and one private IP address. They detect basic leaks but
/// do not guarantee close conformity with the security
/// document.
#[test_function]
pub async fn test_lockdown(
_: TestContext,
rpc: ServiceClient,
mut mullvad_client: MullvadProxyClient,
) -> Result<(), Error> {
// Take care not to use some bogus IP in the guest's subnet, lest we just send ARP requests
// These will fail if there's no actual host present
let lan_destination = "10.1.2.3:1234".parse().unwrap();
let inet_destination: SocketAddr = "1.1.1.1:1337".parse().unwrap();
// Disable LAN sharing
//
log::info!("LAN sharing: disabled");
mullvad_client
.set_allow_lan(false)
.await
.expect("failed to disable LAN sharing");
// Enable lockdown mode
//
mullvad_client
.set_lockdown_mode(true)
.await
.expect("failed to enable lockdown mode");
// Ensure all destinations are unreachable
//
let default_interface = rpc.get_default_interface().await?;
let detected_probes =
send_guest_probes(rpc.clone(), default_interface.clone(), lan_destination).await;
assert!(
detected_probes.none(),
"observed outgoing packets to LAN: {detected_probes:?}"
);
let detected_probes =
send_guest_probes(rpc.clone(), default_interface.clone(), inet_destination).await;
assert!(
detected_probes.none(),
"observed outgoing packets to internet: {detected_probes:?}"
);
// Enable LAN sharing
//
log::info!("LAN sharing: enabled");
mullvad_client
.set_allow_lan(true)
.await
.expect("failed to enable LAN sharing");
// Ensure private IPs are reachable, but not others
//
let detected_probes =
send_guest_probes(rpc.clone(), default_interface.clone(), lan_destination).await;
assert!(
detected_probes.all(),
"did not observe some outgoing packets: {detected_probes:?}"
);
let detected_probes =
send_guest_probes(rpc.clone(), default_interface.clone(), inet_destination).await;
assert!(
detected_probes.none(),
"observed outgoing packets to internet: {detected_probes:?}"
);
// Connect
//
connect_and_wait(&mut mullvad_client).await?;
// Leak test
//
assert!(
helpers::using_mullvad_exit(&rpc).await,
"expected Mullvad exit IP"
);
// Send traffic outside the tunnel to sanity check that the internet is *not* reachable via non-
// tunnel interfaces.
let detected_probes = send_guest_probes(rpc.clone(), default_interface, inet_destination).await;
assert!(
detected_probes.none(),
"observed outgoing packets to internet: {detected_probes:?}"
);
Ok(())
}
|