Add anchor.
[tails/vicves.git] / wiki / src / blueprint / macchanger.mdwn
blob6f8a7b889ff4ad91d231e443944658641ad394ff
1 [[!toc levels=2]]
3 # Rationale
5 The uniqueness of [[!wikipedia MAC addresses]] introduce two types of
6 potential issues for Tails users, in particular if the MAC address can
7 be linked to the user's identity:
9 1. Geographical location tracking: A time-stamped log of a MAC address
10    ties a device to a certain location at a particular time. If the
11    device's owner is known, his or her movements are also known. In
12    case an unknown owner, the tracked movements leak information about
13    the owner, which eventually may lead to identification.
15 2. Identify Tails (or Tor) users: If the usage of Tails (or Tor) can
16    be fingerprinted on the network (despite other measures taken), and
17    the owner of a device is known, it can be determined that the owner
18    also is a Tails (or Tor) user.
20 Spoofing the MAC address is the natural solution. Unfortunately, in
21 some cases MAC spoofing may cause network connection issues or even
22 raise alarms; care should be taken to prevent MAC spoofing in such
23 situations.
25 # Threat model
27 ## Adversary capabilities
29 The adversary's capabilities are assumed to be:
31 1. Omniscient wireless snooping of when and where (via triangulation)
32    all MAC addresses are used. Also access to Time-stamped logs of the
33    presence of MAC addresses on all wired networks (think compromised
34    routers and/or ISP:s). [AdvCapSniff]
36 2. Has access, on specific request, to all user/customer records and
37    surveillance data of any public network. [AdvCapRecords]
39 3. Knows who owns which MAC address according to the last traceable
40    transaction (e.g. credit card trail). Cash purchase, trade, trash
41    salvaging or theft are ways to potentially avoid this but the
42    adversary can interrogate the previous owner to obtain that
43    information if remembered (or at all known). [AdvCapOwners]
45 ## Adversary goals
47 We assume an adversary whose goals are the following, which all
48 happens on a global, omniscient level thanks to AdvCapSniff:
50 1. Monitoring of when and where a particular MAC address with a known
51    owner is used. In other words, monitoring of an individual's
52    geographical movement while using a certain device (thanks to
53    AdvCapOwners).  [AdvGoalTracking]
55 2. Dragnet-style logging of when and where MAC addresses with unknown
56    owners are used for large-scale social graphing and profiling which
57    leaks information owners' identities. [AdvGoalProfiling]
59 3. Identify Tails (and Tor) users. If Tails (or Tor) usageAdv can be
60    fingerprinted, then that fact is documented about a particular
61    individual (thanks to AdvCapOwners). [AdvGoalIdTails]
63 4. Identify MAC spoofing individuals. We assume that our adversary has
64    bought into the "nothing to hide" argument, which makes such
65    suspicious behaviour valuable information. [AdvGoalIdMacSpoof]
67 Note that none of the goals deal with other types of unique
68 identifiers than MAC addresses. In particular, logging of IMEI:s [1],
69 used by mobile NIC:s, are omitted (mostly due to lack of proper
70 tools).
72 [1] http://en.wikipedia.org/wiki/IMEI
74 ## Tails user goals
76 1. Hide geographical movement, i.e. prevent AdvGoalTracking and
77    AdvGoalProfiling. [AvoidTracking]
79 2. No unspoofed usage of Tails (or Tor), i.e. prevent AdvGoalIdTails.
80    [AvoidIdTails]
82 3. Not raising alarms on the network, i.e. prevent AdvGoalIdMacSpoof,
83    but also avoid alarming the local administrators (imagine a
84    situation where security guards are sent to investigate an "alien
85    computer" at your workplace, or similar). [AvoidIdMacSpoof]
87 4. Avoid network connection problems due to MAC address white-listing,
88    fixed ARP tables, hardware or driver issues, or
89    similar. [AvoidConnectionProbs]
91 # Use case analysis
93 Below we analyse how MAC address spoofing relates to each user goal
94 for the given situation.
96 ## Using Tails at home
98 First, note that the user's relation (owner, family member's,
99 friend's, work's, borrowed, etc.) to the computer running Tails
100 doesn't matter; the location is already directly related to the user's
101 identity. Similarly, because of this, MAC spoofing is of very limited
102 value for both AvoidTracking and AvoidIdTails value.
104 MAC spoofing could hinder AvoidIdMacSpoof if detected by the ISP's
105 hardware (i.e. no trusted router in the way). Similarly, ISP-provided
106 hardware may employ some sort of MAC address white-listing (e.g. only
107 X unique ones are allowed) that can prevent AvoidConnectionProbs.
109 Summary: MAC spoofing should be avoided but isn't terribly dangerous
110 if enabled.
112 ## Using Tails at a friend's place
114 ### Using your computer
116 MAC spoofing should be enabled for both AvoidTracking and
117 AvoidIdTails. AvoidIdMacSpoof won't be your problem but your friend's
118 (which isn't a problem at all unless you're there spoofing all the
119 time). AvoidConnectionProbs can be problematic for the same reasons as
120 in "Using Tails at home".
122 Summary: Enable MAC spoofing!
124 ### Using any other computer
126 Since the computer you use isn't tied to you, AvoidTracking and
127 AvoidIdTails aren't relevant. AvoidIdMacSpoof won't be your problem but
128 your friend's. AvoidConnectionProbs can be problematic for the same
129 reasons as in "Using Tails at home".
131 Summary: MAC spoofing should be avoided but isn't terribly dangerous
132 if enabled.
134 ## Using Tails at a restricted public network
136 Access is restricted to registered users' identities only. We use
137 "registration" a bit loosely, but example of networks like these are:
139 * paid-for access when there's a money trail (e.g. credit cards).
140 * captive portals requiring logging in with an identity-tied account.
141 * locations requiring a identity-tied key card (e.g. university
142   computer labs and workplaces) to access.
144 This should probably also cover otherwise unrestricted networks that
145 snoops on users in other ways, e.g. a library with video camera
146 surveillance.
148 ### Using your computer
150 Since the user is registered for network access, both AvoidTracking
151 and AvoidIdTails are hard to get. However, AdvCapRecords requires
152 explicit targeting (more expensive), while AdvCapSniff isn't, and MAC
153 spoofing would defeat the latter, so it's not without merit.
155 AvoidIdMacSpoof could be problematic if your registered presence on the
156 network is correlated to constantly new MAC addresses. A quite likely
157 situation for this case is that you login via some captive portal, and
158 these often use your MAC address for access control purposes, so a log
159 of which you have used
161 AvoidConnectionProbs is a problem if your MAC address becomes part of
162 your registration, and is assumed to not change (maybe a place where
163 you have to pay for each device you connect with). This seems pretty
164 far-fetched, though.
166 Summary: There's no easy choice here but in most scenarios
167 AvoidTracking is probably more valuable than AvoidIdMacSpoof, so MAC
168 spoofing should be enabled.
170 ### Using a public computer
172 Since the computer isn't tied to you, MAC spoofing does nothing to
173 AvoidTracking and AvoidIdTails. It could cause problems to both
174 AvoidIdMacSpoof and AvoidConnectionProbs.
176 Summary: MAC spoofing should be avoided but isn't terribly dangerous
177 if enabled.
179 ## Using Tails at an open public network
181 Access is completely open, and no kind of registration is needed.
183 ### Using your computer
185 MAC spoofing should be enabled for both AvoidTracking and
186 AvoidIdTails. Such a network should expect to see many unique MAC
187 addresses daily, and be ready to deal with it, so AvoidIdMacSpoof and
188 AvoidConnectionProbs are of no consequence.
190 Summary: Enable MAC spoofing!
192 ### Using a public computer
194 Same as using a public computer at a restricted public network.
196 Summary: MAC spoofing should be avoided but isn't terribly dangerous
197 if enabled.
199 ## Conclusions
201 The strong requirement of enabling MAC spoofing in a few cases, and
202 the low risk of keeping it enabled even in the cases where it should
203 be avoided, warrants for making this feature enabled by default, with
204 the possibility to opt-out.
206 # Leak prevention
208 It is conceivable that NICs may send packets before the user has made
209 a decision about whether to use MAC spoofing or not. In fact, someone
210 on tails-dev@
211 [alluded](https://mailman.boum.org/pipermail/tails-dev/2013-January/002491.htm)
212 to this being possible for wireless NICs although without any
213 references (this may refer to so called "active probing"; see section
214 below). If this is the case it at the very least implies that we must
215 enforce the MAC spoofing setting as early as possible.
217 However, since we (obviously) cannot foresee the user's decision we get
218 a problematic time frame between when a network device is added during
219 early boot and when the user makes the decision later on. Enforcing a
220 default MAC spoofing setting immediately when a network device is
221 added, that then potentially is reversed when the user makes the
222 decision, leads to problems in some scenarios if we assume these early
223 leaks happen:
225 * If MAC spoofing is enabled before the user has made the decision, a
226   fake MAC address would leak before the user made the decision, and
227   the decision was to disable MAC spoofing. The sudden switch of MAC
228   address may result in a breach of AvoidIdMacSpoof.
230 * If MAC spoofing is disabled before the user has made the decision, the
231   real MAC address would leak even if the user wanted MAC spoofing
232   enabled, which leaks to breaches of AvoidTracking and AvoidIdTails.
233   The sudden switch of MAC address may result in a breach of
234   AvoidIdMacSpoof.
236 The first is clearly less bad than the second, but the ideal, which
237 avoids these problems altogether.
239 The real solution is therefore to eliminate the problematic this time
240 frame completely by preventing any network devices from being enabled
241 at all until the decision has been made, and have the MAC spoofing
242 setting applied immediately when the device is added.
244 # User interface design
246 This option, which is of the on/off variety, will be implemented as a
247 check box in Tails Greeter. The problem is to formulate a concise
248 description that's clear and informative enough to guide the user to
249 make an informed decision.
251 In our previous blueprint we state that we want a user interface that
252 presents the option using "simple words such as 'I am using a public
253 computer' instead of speaking geek-language about mac addresses or
254 whatever". However, in the use case analysis above it's obvious that
255 simply "public or not" isn't enough to differentiate between the
256 different use cases, and it seems unlikely to be the case for any
257 other easily understood concept.
259 Therefore it seems that the label of the option isn't what we should
260 focus on, so we might just as well call it "Spoof all MAC addresses",
261 which at least can help advanced users that know what they're
262 doing. Beyond a concise summary in Tails Greeter, it's also highly
263 important that we have clear and complete documentation about this,
264 and that we make this documentation easily available from inside
265 Tails Greeter.
267 <a id="active-probe-fingerprinting"></a>
269 # Active probe fingerprinting
271 **NO PREVENTION AGAINST THIS IS IMPLEMENTED YET**
273 There's an opportunity for an adversary to achieve AdvGoalTracking and
274 AdvGoalProfiling due to "active probing" performed by NetworkManager
275 for Wi-Fi connections. This puts AvoidTracking at risk.
277 Wi-Fi has both a passive and active scanning mode. Passive scanning,
278 as the name suggests, passively listens for broadcasted wireless
279 networks, which is entirely safe. Active scanning, however, actively
280 sends probes for any known networks. In our case these are the saved
281 connections in NetworkManager, so this turns especially problematic
282 when persistent NM-connections are used; the (potentially long) list of
283 networks actively probed for can be used as a fingerprint by an
284 adversary, breaching AvoidTracking.
286 While this has nothing to do with MAC spoofing, it does strongly
287 affect the (arguably) most important user goal of this feature, namely
288 AvoidTracking. Because of this, active scanning should be disabled in
289 NetworkManager when MAC spoofing is enabled.
291 # Implementation
293 The current implementation spoofs the non-vendors bits of any network
294 device's MAC address immediately after it is added by udev. Furthermore, to
295 deal with potential network leaks before the user has chosen whether
296 to enable MAC spoofing or not, the addition of network devices is delayed
297 until after Tails Greeter knows the user's final decision.
299 ## Network blocking
301 As suggested in the "Leak prevention" section, we block all network
302 devices' modules from being loaded until the user has made the decision about
303 whether to enable MAC spoofing or not. The way we do this is by
304 generating a list of all network device modules during build time, and
305 add these to a `modprobe.d`-type blacklist. In Tails Greeter's
306 post-login script (when we know the user's decision) we unblock the
307 network by simply removing that list, and then we have udev "re-probe"
308 for network devices and load their modules.
310 Scripts:
312 * [[!tails_gitweb config/chroot_local-hooks/80-block-network]] (runs at
313   build time)
315 * [[!tails_gitweb config/chroot_local-includes/usr/local/sbin/tails-unblock-network]]
316   (runs right after Tails Greeter logs in)
318 ## Trigger
320 We use udev as the trigger that hooks MAC address spoofing. Because of
321 that, it happens for every Ethernet device automatically, as early as
322 possible (i.e. immediately after it's added), so even if there's some
323 kind of weird leak before a device is up:ed the real MAC address
324 shouldn't leak.
326 Hook:
327 [[!tails_gitweb config/chroot_local-includes/etc/udev/rules.d/00-mac-spoof.rules]]
329 ### Discarded approaches
331 All other triggers that were considered do not deal with the "early"
332 leaks issue, in addition to other reasons for being discarded:
334 * ifupdown hook: A if-pre-up hook would probably work but since we use
335   NetworManager the exact behaviour is blurred and not particularly
336   well-documented. It doesn't feel robust for this reason.
338 * NetworkManager hook: NM doesn't trigger events equivalent to
339   if-pre-up, so this isn't possible. See the commented parts in:
340   /etc/NetworkManager/dispatcher.d/01ifupdown
342 * systemd integration: We don't use this yet.
344 * NetworkManager plugin: While this certainly would have a nice impact
345   outside of Tails, the added maintenance burden makes it less
346   attractive.
348 ## MAC changing tool
350 The tool used to change the MAC address is simply macchanger, mostly
351 because it's in Debian (where the known vulnerabilities are patched)
352 and macchiato isn't (and it's not as well tested, yet). macchanger is
353 used in a very straightforward way, so if we want to switch tool in
354 the future it's a simple task.
356 Helper scripts:
357 [[!tails_gitweb config/chroot_local-includes/usr/local/sbin/tails-spoof-mac]]
359 ## Connection failure detection
361 This section deals with AvoidConnectionProbs. The goal is to somehow
362 identify connection errors that are related to MAC spoofing, and
363 notify the user when this happens.
365 Due to lack of hooks into NetworkManager's connection error handling
366 we currently use a simple monitoring script that's started when MAC
367 spoofing is enabled. It scans syslog for the error message patterns
368 from NetworkManager and `wpa_supplicant` expected when the connection
369 fails due to MAC spoofing. When such a pattern is found, a
370 notification is shown to the user, stating that the connection problem
371 *may* be MAC spoofing related. Due to the uncertainty and lack of
372 information available for this approach, there certainly will be false
373 positives.
375 At the moment this script only deals with wireless connections. It
376 successfully distinguishes between MAC-spoof related errors and errors
377 when entering the wrong passphrase, so no false positives in that
378 (relatively common) case.
380 For details, see the script:
381 [[!tails_gitweb config/chroot_local-includes/usr/local/sbin/tails-blocked-network-detector]]
383 ## MAC spoofing and virtual machine networking issues
385 Some virtualization tools seem to behave poorly when spoofing virtual NIC
386 MAC addresses. For instance, VirtualBox's networking completely breaks
387 when using bridge- and NAT-based adapters in combination with
388 MAC-spoofing, and those two are probably the two most common scenarios
389 (NAT-based in particular). Therefore, if it is detected (using
390 `virt-what`) that Tails is running inside a virtual machine, then
391 MAC spoofing is disabled by default. If the user still enables the
392 option, a warning is immediately shown.
394 When running Tails inside a virtual machine, MAC spoofing is mostly
395 useless, at least when NAT-based (and similar) approaches to network
396 sharing are used, since only the host system will see the MAC address.
397 However, that's not the case with bridged connections, but on the other
398 hand only the virtual NICs MAC address is leaked, which usually is
399 randomised upon creation any way. Still, this could leak to breaking
400 AvoidTracking, since the MAC address usually is persistent. We may
401 want to document this, and advice users to preferably use NAT-based
402 virtual adapters (which usually is the default). Users that must use
403 bridged connection will have to manually randomise the MAC address
404 each boot.
406 # Future work
408 ## Using NetwokManager for AvoidConnectionProbs?
410 Instead of our current hack, we'd ideally want to hook into
411 NetworkManager's error handling, which certainly would be more robust,
412 and hopefully would provide more information about the error, but this
413 currently seems unsupported.
415 An experiment has showed that when connecting to a password-protected
416 (WPA-PSK) wireless network with MAC address white-listing, spoofed
417 (and hence blocked) MAC addresses resulted in an endless cycle of NM
418 asking for passphrase. When cancelled, NM displays a "Disconnected"
419 notification, and during this time no NM dispatcher events were
420 emitted.
422 Some bugs of interest that may bring some hope:
424 * <https://bugzilla.gnome.org/show_bug.cgi?id=387832>
425 * <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518368>
426 * <https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/336736>
428 ## Vendor bit randomisation with macchiato
430 These are the current relevant OUI counts from macchiato's git:
432 5       oui/bluetooth_laptop.sh
433 2       oui/bluetooth_misc.sh
434 12      oui/bluetooth_mobile.sh
435 1       oui/bluetooth_pmp.sh
436 2       oui/wired_console.sh
437 3       oui/wired_desktop_dedicated.sh
438 11      oui/wired_desktop_onboard.sh
439 8       oui/wired_infrastructure.sh
440 17      oui/wired_laptop.sh
441 6       oui/wired_misc.sh
442 4       oui/wired_printer.sh
443 2       oui/wireless_camera.sh
444 1       oui/wireless_console.sh
445 4       oui/wireless_desktop_dedicated.sh
446 2       oui/wireless_desktop_onboard.sh
447 4       oui/wireless_handheld.sh
448 6       oui/wireless_infrastructure.sh
449 1       oui/wireless_laptop_dedicated.sh
450 21      oui/wireless_laptop.sh
451 17      oui/wireless_mobile.sh
452 7       oui/wireless_pmp.sh
453 4       oui/wireless_printer.sh
454 8       oui/wireless_usb.sh
456 In particular there's ~20 each in wireless_laptop and wired_laptop,
457 which is what we should care about most (desktops rarely need MAC
458 spoofing). However, after investigating the sources for some OUI:s
459 (via git history), some OUI:s are (according to the submitter) only
460 common in certain geographical areas. This makes the lists too small
461 and unreliable at the moment.
463 # Questions, remaining issues, and other random stuff
465 ## MAC spoof failure warning and failsafe
467 If MAC spoofing fails for some interface we'd like to prevent it from
468 exposing the real MAC address, and warn the user about this via a
469 notification.
471 In the current implementation there's no failsafe that verifies that
472 the selected MAC spoofing setting has been enforced before
473 connecting. This would be easy if there was something like pre-up NM
474 dispatcher hooks but just like in the section about "Connection
475 failure detection", there's none yet.
477 An alternative would be to do this in
478 [[!tails_gitweb config/chroot_local-includes/usr/local/sbin/tails-spoof-mac]], which
479 is run by the udev hook. In the end of the script we could try to
480 verify that the spoofing indeed happened for the NIC in question, and
481 if it didn't we could go into full-out panic mode:
483 1. Down the interface
484 2. Try to unload the module used by the NIC. While one easily can find
485    the module used by a `$NIC` via `readlink
486    "/sys/class/net/${NIC}/device/driver/module"`, we'd also have to
487    resolve reverse dependencies. For instance, for current Intel
488    wireless chipsets, the `iwlwifi` module is loaded, but with current
489    Linux kernels another module called `iwldvm` is loaded, and it uses
490    `iwlwifi`, so a `morprobe -r iwlwifi` will fail. Sadly `modprobe`
491    doesn't have a `--recursive-remove` or `--show-reverse-depends` so
492    we'd have to e.g. parse "Used by" field of `lsmod` or similar, and
493    we'd have to do it recursively to be rigorous.
494 3. Perhaps prevent NetworkManager from starting if the previous step
495    failed?
496 4. Show a scary error message to the user
498 It would obviously require to drop `set -e`, because errors are indeed
499 what could cause this to happen.
501 ## Detecting MAC-spoof related connection errors for wired NICs
503 While Wi-Fi connection are covered, this gets trickier for wired
504 connections. The problem is that there's no strong concept of being
505 "associated" to a wired network (at least a "standard" one, perhaps
506 there is with 802.1x security...). It'll probably be hard to identify
507 blocking without confusing it with other types of wired connection
508 failures (i.e. false positives). How does wired MAC address blocking
509 usually work? On which level? DHCP? Lower layer?
511 # Old stuff from blueprint
513 ## Improving macchanger
515 Some of our goals would be easier to achieve by patching macchanger
516 itself. Since it's been unmaintained upstream for a while, we've been
517 discussing and working with someone who has taken its maintenance over
518 and has already started patching it to better suit our needs:
520 * [Redmine project](https://labs.riseup.net/code/projects/show/macchanger)
521 * Git repository: `git://labs.riseup.net/backupninja.git`
522 * Debian packages: the maintainer of the macchanger package in
523   Debian has already integrated some of these patches (uploaded to
524   sid: 1.5.0-8) and is likely to go on this way. Tails has been
525   using this improved version for a while.
527 ## Inspiration sources
529 ### Haven
531 Haven does not automatically start network-manager at boot time.
532 It provides shortcuts in the application menu to run macchanger-gtk
533 and start the network if desired.
535 ### Liberte Linux
537 Liberte Linux randomises wireless MAC addresses at boot time and
538 allows changing wired interfaces' MAC addresses after boot, see their
539 `src/usr/local/sbin/mac-randomize` that uses `ifconfig IFACE hw ether`
540 rather than macchanger.
542 ## Documentation
544 Investigate and possibly document the kind of information that could
545 still be seen on the LAN about the system. Such as the manufacturer (ex:
546 Sony), model number, BIOS and version, etc.?