2

This page on server hardening has a large section on adding a SWAP partition.

Why is adding a SWAP partition good for server hardening?

Randomblue
  • 1,685
  • 3
  • 15
  • 17

2 Answers2

1

It improves the availability of the system, which is also an important part of information security.

E.g. if there's a DoS attack on a memory intensive service, the box is less likely/takes longer to crash.

billc.cn
  • 3,852
  • 1
  • 16
  • 24
  • 2
    FTR: This is increasing Availability at the potential risk of Confidentiality. e.g.: If the system shuts down before the swap partition gets wiped, there could be remnants of data in that partition that were never meant to be stored in the clear on a long-term storage device. – Iszi Feb 18 '16 at 19:40
  • @Iszi Some OSes ([OpenBSD](https://bsd.slashdot.org/story/00/01/16/1943235/openbsd-can-encrypt-swapspace)) encrypt swap by default, or [can be configured to](https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryption). – Matt Nordhoff Apr 19 '16 at 00:32
1

I agree with billc that the intention is to improve availability, however when most systems start swapping, performance drops so dramatically that you are facilitating a DOS for your users.

It is a good idea to be able to hibernate a system for fast recovery after a power outage (if you don't have enough UPS) which does require swap.

I'm struggling to imagine how the confidentiality issue described by Iszi would come about in practice.

symcbean
  • 18,278
  • 39
  • 73
  • Couldn't swap actually be used to leak sensitive memory as it's persisted to disk while RAM doesn't persist? – Ztyx Apr 19 '16 at 06:28
  • How does someone get access to the data in swap without access to the rest of the storage? – symcbean Apr 19 '16 at 06:55
  • They don't. But sensitive information might be leaked more easily on intrusion. – Ztyx Apr 19 '16 at 07:01
  • @symcbean Having swap does not necessarily lead to losing performance due to disk access. The OS will most likely swap other less used pages to disk leaving more memory for the application under attack. – billc.cn Apr 19 '16 at 08:55
  • @billc: in theory yes, in practice no. Multi-tenancy systems with large idle applications are *very* rare beasts these days. – symcbean Apr 19 '16 at 09:06