Why the Master Matters
The Salt master can run commands as root on every minion. If an attacker controls the master, they control the fleet. Salt has had serious security fixes in the past, including remote code execution problems. So you treat the master like a domain controller: small, patched, restricted and watched.
Step 1: Limit the Network
| Port | Use | Who should reach it |
|---|---|---|
| 4505/tcp | Publish (master sends commands) | Only minion networks |
| 4506/tcp | Request/return (minions send results, request files and pillar) | Only minion networks |
| 8000/tcp (or your choice) | salt-api | Only admin tools and CI systems, behind TLS or a proxy |
| 22/tcp | SSH to the master | Only admin or bastion networks |
Step 2: Control Key Acceptance
- Keep
auto_accept: False(the default). Never set it toTrueon a master that can be reached from untrusted networks - Check the fingerprint of the minion key before you accept it
- Use
salt-key -aonly for known ids. Usesalt-key -Loften to look for unexpected pending keys - Consider pre-seeded keys or a controlled reactor with extra checks for cloud servers
- Reject or delete keys for retired servers
Step 3: Run the Master With Least Privilege
salt user. Read the install guide for your version and test after any change. The minion normally runs as root, because it manages the system.
| Item | Setting |
|---|---|
| Private keys | /etc/salt/pki/master/master.pem must be mode 400 or 600 and owned by the master user |
| Pillar files | Readable only by the master user. Pillar can hold secrets |
| Logs | Do not log secrets. Avoid -l debug in production for long periods |
| Config | Not world-writable. Keep in Git, deployed by a trusted process |
Step 4: Give People Limited Access (eauth and ACLs)
By default only root on the master can run salt. To let other users run some commands on some targets, use external authentication (eauth) with external_auth for the salt command and salt-api, or the simpler publisher_acl for local users.
state.apply app.deploy on web* cannot do much damage if its password leaks.
Step 5: Secure salt-api
salt-api offers a REST interface to Salt, usually through the rest_cherrypy module. It is powerful, so protect it.
- Always use TLS. Never send passwords over plain HTTP
- Limit access by IP in the firewall or the reverse proxy
- Use short token lifetimes (
token_expire) and a dedicated bot user for each system - Log API access. Rate limit at the proxy
- Do not expose
salt-apito the internet
Step 6: Watch and Record
- Keep the master log and job cache (
keep_jobs_seconds) long enough to investigate. Send job returns to a central place with a returner or an event forwarder - Review
salt/authandsalt/keyevents for unexpected keys - Use
salt-run jobs.list_jobsto see who ran what (theUserfield) - Use operating system
auditdrules on/etc/saltand/srv - Alert when
salt-key -Lshows unknown pending keys
Step 7: Protect Secrets
- Use encrypted pillar, Vault or an SDB backend (see the secrets lesson). Do not commit secrets to plain Git
- Keep pillar targeting strict: a minion should only get the pillar it needs
- Give gitfs deploy keys read-only access
- Restrict who can edit states: a state is code that runs as root on minions
Security Checklist
| Check | Done? |
|---|---|
| Salt master and minions are on a supported, patched version | |
| Ports 4505, 4506 limited to minion networks | |
auto_accept is off. Fingerprints are verified | |
| Master runs as a non-root user with correct file modes | |
Users and bots use publisher_acl or external_auth with minimal rights | |
salt-api uses TLS, is firewalled, and uses short tokens | |
| Secrets are encrypted or in Vault, not in plain pillar in Git | |
| Changes to states go through code review | |
| Events and jobs are logged and monitored | |
| Backups of the master key and config exist and are protected |
Practice Tasks
- Write firewall rules that allow only a minion network to ports 4505 and 4506
- Give a
deployuser permission to run onlystate.applyonweb*and test it - Compare
publisher_aclandexternal_auth - Set up
salt-apiwith TLS and calltest.pingwith a token - List five signs of a compromised master that you would monitor
Conclusion
Treat the master like your most sensitive server. Limit the network, never auto-accept keys, run with least privilege, give users narrow ACLs, secure salt-api with TLS, protect secrets, log everything and patch quickly.

