hardening.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .. _hardening-salt:
  2. ==============
  3. Hardening Salt
  4. ==============
  5. This topic contains tips you can use to secure and harden your Salt
  6. environment. How you best secure and harden your Salt environment depends
  7. heavily on how you use Salt, where you use Salt, how your team is structured,
  8. where you get data from, and what kinds of access (internal and external) you
  9. require.
  10. .. warning::
  11. For historical reasons, Salt requires PyCrypto as a "lowest common
  12. denominator". However, `PyCrypto is unmaintained`_ and best practice is to
  13. manually upgrade to use a more maintained library such as `PyCryptodome`_. See
  14. `Issue #52674`_ and `Issue #54115`_ for more info
  15. .. _PyCrypto is unmaintained: https://github.com/dlitz/pycrypto/issues/301#issue-551975699
  16. .. _PyCryptodome: https://pypi.org/project/pycryptodome/
  17. .. _Issue #52674: https://github.com/saltstack/salt/issues/52674
  18. .. _Issue #54115: https://github.com/saltstack/salt/issues/54115
  19. General hardening tips
  20. ======================
  21. - Restrict who can directly log into your Salt master system.
  22. - Use SSH keys secured with a passphrase to gain access to the Salt master system.
  23. - Track and secure SSH keys and any other login credentials you and your team
  24. need to gain access to the Salt master system.
  25. - Use a hardened bastion server or a VPN to restrict direct access to the Salt
  26. master from the internet.
  27. - Don't expose the Salt master any more than what is required.
  28. - Harden the system as you would with any high-priority target.
  29. - Keep the system patched and up-to-date.
  30. - Use tight firewall rules. Pay particular attention to TCP/4505 and TCP/4506
  31. on the salt master and avoid exposing these ports unnecessarily.
  32. Salt hardening tips
  33. ===================
  34. - Subscribe to `salt-users`_ or `salt-announce`_ so you know when new Salt
  35. releases are available. Keep your systems up-to-date with the latest patches.
  36. - Use Salt's Client :ref:`ACL system <acl>` to avoid having to give out root
  37. access in order to run Salt commands.
  38. - Use Salt's Client :ref:`ACL system <acl>` to restrict which users can run what commands.
  39. - Use :ref:`external Pillar <all-salt.pillars>` to pull data into Salt from
  40. external sources so that non-sysadmins (other teams, junior admins,
  41. developers, etc) can provide configuration data without needing access to the
  42. Salt master.
  43. - Make heavy use of SLS files that are version-controlled and go through
  44. a peer-review/code-review process before they're deployed and run in
  45. production. This is good advice even for "one-off" CLI commands because it
  46. helps mitigate typos and mistakes.
  47. - Use salt-api, SSL, and restrict authentication with the :ref:`external auth
  48. <acl-eauth>` system if you need to expose your Salt master to external
  49. services.
  50. - Make use of Salt's event system and :ref:`reactor <reactor>` to allow minions
  51. to signal the Salt master without requiring direct access.
  52. - Run the ``salt-master`` daemon as non-root.
  53. - Disable which modules are loaded onto minions with the
  54. :conf_minion:`disable_modules` setting. (for example, disable the ``cmd``
  55. module if it makes sense in your environment.)
  56. - Look through the fully-commented sample :ref:`master
  57. <configuration-examples-master>` and :ref:`minion
  58. <configuration-examples-minion>` config files. There are many options for
  59. securing an installation.
  60. - Run :ref:`masterless-mode <tutorial-standalone-minion>` minions on
  61. particularly sensitive minions. There is also :ref:`salt-ssh` or the
  62. :mod:`modules.sudo <salt.modules.sudo>` if you need to further restrict
  63. a minion.
  64. - Monitor specific security related log messages. Salt ``salt-master`` logs
  65. attempts to access methods which are not exposed to network clients. These log
  66. messages are logged at the ``error`` log level and start with ``Requested
  67. method not exposed``.
  68. .. _salt-users: https://groups.google.com/forum/#!forum/salt-users
  69. .. _salt-announce: https://groups.google.com/forum/#!forum/salt-announce