💾 Archived View for complete.org › how-gapped-is-your-air captured on 2024-08-18 at 17:43:40. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
Sometimes we want better-than-firewall security for things. For instance:
1. An industrial control system for a municipal water-treatment plant should never have data come in or out
2. Or, a variant of the industrial control system: it should only permit telemetry and monitoring data out, and nothing else in or out
3. A system dedicated to keeping your GPG private keys secure should only have material to sign (or decrypt) come in, and signatures (or decrypted data) go out
4. A system keeping your tax records should normally only have new records go in, but may on occasion have data go out (eg, to print a copy of an old record)
In this article, I'll talk about the "high side" (the high-security or high-sensitivity systems) and the "low side" (the lower-sensitivity or general-purpose systems). For the sake of simplicity, I'll assume the high side is a single machine, but it could as well be a whole network.
Let's focus on examples 3 and 4 to make things simpler. Let's consider the primary concern to be data exfiltration (someone stealing your data), with a secondary concern of data integrity (somebody modifying or destroying your data).
You might think the safest possible approach is Airgapped[1] -- that is, there is literal no physical network connection to the machine at all. This help! But then, the problem becomes: how do we deal with the inevitable need to legitimately get things on or off of the system? As I wrote in Dead USB Drives Are Fine: Building a Reliable Sneakernet[2], by using tools such as NNCP[3], you can certainly create a "sneakernet": using USB drives as transport.
2: /dead-usb-drives-are-fine-building-a-reliable-sneakernet/
While this is a very secure setup, as with most things in security, it's less than perfect. The Wikipedia airgap article[4] discusses some ways airgapped machines can still be exploited. It mentions that security holes relating to removable media have been exploited in the past. There are also other ways to get data out; for instance, Debian ships with gensio[5] and minimodem, both of which can transfer data acoustically.
4: https://en.wikipedia.org/wiki/Air_gap_(networking)
But let's back up and think about why we think of airgapped machines as so much more secure, and what the failure modes of other approaches might be.
You could very easily set up high-side machine that is on a network, but is restricted to only one outbound TCP port. There could be a local firewall, and perhaps also a special port on an external firewall that implements the same restrictions. A variant on this approach would be two computers connected directly by a crossover cable, though this doesn't necessarily imply being more secure.
Of course, the concern about a local firewall is that it could potentially be compromised. An external firewall might too; for instance, if your credentials to it were on a machine that got compromised. This kind of dual compromise may be unlikely, but it is possible.
We can also think about the complexity in a network stack and firewall configuration, and think that there may be various opportunities to have things misconfigured or buggy in a system of that complexity. Another consideration is that data could be sent at any time, potentially making it harder to detect. On the other hand, network monitoring tools are commonplace.
On the other hand, it is convenient and cheap.
I use a system along those lines to do my backups. Data is sent, gpg-encrypted and then encrypted again at the NNCP layer, to the backup server. The NNCP process on the backup server runs as an untrusted user, and dumps the gpg-encrypted files to a secure location that is then processed by a cron job using Filespooler[6]. The backup server is on a dedicated firewall port, with a dedicated subnet. The only ports allowed out are for NNCP and NTP, and offsite backups. There is no default gateway. Not even DNS is permitted out (the firewall does the appropriate redirection). There is one pinhole allowed out, where a subset of the backup data is sent offsite.
I initially used USB drives as transport, and it had no network connection at all. But there were disadvantages to doing this for backups - particularly that I'd have no backups for as long as I'd forget to move the drives. The backup system also would have clock drift, and the offsite backup picture was more challenging. (The clock drift was a problem because I use 2FA on the system; a password, plus a TOTP generated by a Yubikey)
This is "pretty good" security, I'd think.
What are the weak spots? Well, if there were somehow a bug in the NNCP client, and the remote NNCP were compromised, that could lead to a compromise of the NNCP account. But this itself would accomplish little; some other vulnerability would have to be exploited on the backup server, because the NNCP account can't see plaintext data at all. I use borgbackup[7] to send a subset of backup data offsite over ssh. borgbackup has to run as root to be able to access all the files, but the ssh it calls runs as a separate user. A ssh vulnerability is therefore unlikely to cause much damage. If, somehow, the remote offsite system were compromised and it was able to exploit a security issue in the local borgbackup, that would be a problem. But that sounds like a remote possibility.
7: https://www.borgbackup.org/
borgbackup itself can't even be used over a sneakernet since it is not asynchronous[8]. A more secure solution would probably be using something like dar[9] over NNCP. This would eliminate the ssh installation entirely, and allow a complete isolation between the data-access and the communication stacks, and notably not require bidirectional communication. *Logic separation matters too.* My Roundup of Data Backup and Archiving Tools[10] may be helpful here.
8: /asynchronous-communication/
10: /roundup-of-data-backup-and-archiving-tools/
Other attack vectors could be a vulnerability in the kernel's networking stack, local root exploits that could be combined with exploiting NNCP or borgbackup to gain root, or local misconfiguration that makes the sandboxes around NNCP and borgbackup less secure.
Because this system is in my basement in a utility closet with no chairs and no good place for a console, I normally manage it via a serial console. While it's a dedicated line between the system and another machine, if the other machine is compromised or an adversary gets access to the physical line, credentials (and perhaps even data) could leak, albeit slowly.
But we can do much better with serial lines. Let's take a look.
Some of us remember RS-232 serial lines and their once-ubiquitous DB-9 connectors. Traditionally, their speed maxxed out at 115.2Kbps.
Serial lines have the benefit that they can be a direct application-to-application link. In my backup example above, a serial line could directly link the NNCP daemon on one system with the NNCP caller on another, with no firewall or anything else necessary. It is simply up to those programs to open the serial device appropriately.
This isn't perfect, however. Unlike TCP over Ethernet, a serial line has no inherent error checking. Modern programs such as NNCP and ssh assume that a lower layer is making the link completely clean and error-free for them, and will interpret any corruption as an attempt to tamper and sever the connection. However, there is a solution to that: gensio. In my page Using gensio and ser2net[11], I discuss how to run NNCP and ssh over gensio. gensio is a generic framework that can add framing, error checking, and retransmit to an unreliable link such as a serial port. It can also add encryption and authentication using TLS, which could be particularly useful for applications that aren't already doing that themselves.
11: /using-gensio-and-ser2net/
More traditional solutions for serial communications have their own built-in error correction. For instance, UUCP[12] and Kermit[13] both were designed in an era of noisy serial lines and might be an excellent fit for some use cases. The ZModem protocol also might be, though it offers somewhat less flexibility and automation than Kermit.
I have found that certain USB-to-serial adapters by Gearmo[14] will actually run at up to 2Mbps on a serial line! Look for the ones on their spec pages with a FTDI chipset rated at 920Kbps. It turns out they can successfully be driven faster, especially if gensio's relpkt is used. I've personally verified 2Mbps operation (Linux port speed 2000000) on Gearmo's USA-FTDI2X[15] and the USA-FTDI4X[16]. (I haven't seen any single-port options from Gearmo with the 920Kbps chipset, but they may exist).
15: https://www.gearmo.com/shop/usb-2-0-to-serial-professional-2port-converter/
16: https://www.gearmo.com/shop/professional-4-port-rs232-usb-to-serial-adapter-gm-ftdi4x/
Still, even at 2Mbps, speed may well be a limiting factor with some applications. If what you need is a console and some textual or batch data, it's probably fine. If you are sending 500GB backup files, you might look for something else. In theory, this USB to RS-422 adapter[17] should work at 10Mbps, but I haven't tried it.
17: https://us.connectiveperipherals.com/products/high-speed-usb-to-rs422-1
But if the speed works, running a dedicated application over a serial link could be a nice and fairly secure option.
One of the benefits of the airgapped approach is that data never leaves unless you are physically aware of transporting a USB stick. Of course, you may not be physically aware of what is ON that stick in the event of a compromise. This could easily be solved with a serial approach by, say, only plugging in the cable when you have data to transfer.
A traditional diode[18] lets electrical current flow in only one direction. A data diode[19] is the same concept, but for data: a hardware device that allows data to flow in only one direction.
18: https://en.wikipedia.org/wiki/Diode
19: https://en.wikipedia.org/wiki/Unidirectional_network
This could be useful, for instance, in the tax records system that should only receive data, or the industrial system that should only send it.
Wikipedia claims that the simplest kind of data diode is a fiber link with transceivers connected in only one direction. I think you could go one simpler: a serial cable with only ground and TX connected at one end, wired to ground and RX at the other. (I haven't tried this.)
This approach does have some challenges:
Many existing protocols assume a bidirectional link and won't be usable
There is a challenge of confirming data was successfully received. For a situation like telemetry, maybe it doesn't matter; another observation will come along in a minute. But for sending important documents, one wants to make sure they were properly received.
In some cases, the solution might be simple. For instance, with telemetry, just writing out data down the serial port in a simple format may be enough. For sending files, various mitigations, such as sending them multiple times, etc., might help. You might also look into FEC-supporting infrastructure such as blkar[20] and flute[21], but these don't provide an absolute guarantee. There is no perfect solution to knowing when a file has been successfully received if the data communication is entirely one-way.
20: https://crates.io/crates/blkar
21: https://crates.io/crates/flute
I hinted above that minimodem[22] and gensio[23] both are software audio modems. That is, you could literally use speakers and microphones, or alternatively audio cables, as a means of getting data into or out of these systems. This is pretty limited; it is 1200bps, and often half-duplex, and could literally be disrupted by barking dogs in some setups. But hey, it's an option.
22: http://www.whence.com/minimodem
23: /using-gensio-and-ser2net/
This is the scenario I began with, and named some of the possible pitfalls above as well. In addition to those, note also that USB drives aren't necessarily known for their error-free longevity. Be prepared for failure.
I wanted to lay out a few things in this post. First, that simply being airgapped is generally a step forward in security, but is not perfect. Secondly, that both physical and logical separation matter. And finally, that while tools like NNCP can make airgapped-with-USB-drive-transport a doable reality, there are also alternatives worth considering -- especially serial ports, firewalled hard-wired Ethernet, data diodes, and so forth. I think serial links, in particular, have been largely forgotten these days.
--------------------------------------------------------------------------------
"Airgap" refers to a computer (or network) that is physically disconnected from a larger network and the Internet.
Here are some (potentially) interesting topics you can find here:
(c) 2022-2024 John Goerzen