[ZBXNEXT-195] Proposal: Privilege separation for ZABBIX agent Created: 2010 Jan 06 Updated: 2018 Jan 31 |
|
Status: | Open |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | Agent (G) |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Change Request | Priority: | Major |
Reporter: | J. Fischer | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 7 |
Labels: | logmonitoring, patch, privilege, security | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
UNIX-like operating systems |
Attachments: |
![]() ![]() |
||||||||||||
Issue Links: |
|
Description |
The following is open for discussion. I would be glad to implement this and send patches 1. Purpose ZABBIX agent usually runs as an unprivileged user, which is a good thing to do. Alas, Privilege separation for ZABBIX agent aims to provide a simple, effective and proven 2. How it works Before ZABBIX agent drops it privileges to "zabbix" user, a special process will be This process will not communicate with the network or other processes than the ZABBIX Basically, the privileged process works in the following way:
It is then the responsibility of the unprivileged ZABBIX agent to work with and close this The code running as UID 0 is kept as minimal as possible and consists only of a very few 3. The interface The communication between the unprivileged Agent and the privileged process will be The ZABBIX agent can use new API functions for file operations, e.g.: int zbx_priv_open(int priv_fd, const char *path, int mode) The new functions try to mimic the behaviour of the original functions, returning error The changes in existing agent code will be as unintrusive as possible. 4. Whitelist For security purposes, there should be a new configuration parameter which defines the This pattern could be defined, for example, with: LogfileWhitelist = /var/log/* The privileged process will then match the filename given with each request against this Maybe a blacklist (LogfileBlacklist) configuration option would be a complimentary option, We could:
This would be the most simplistic approach, maybe not as good as a check with realpath(). 5. Extendibility The privsep protocol can easily be extended to provide more privileged functions to the For example, it could be used for data collection that requires root privileges (e.g. some 6. Compatibility The code has been tested on Linux and BSD (Open-, Net- and FreeBSD). It will not work on Alas, I have no access to "big-iron" UNIX-derivates such as HP-UX, AIX or Solaris that 7. Making it optional 7.1 At compile-time A new option to configure should be introduced, namely --enable-privsep. When not specified, 7.2 At run-time Similar to OpenSSH's sshd, a new configuration item "UsePrivilegeSeperation" should be 8. Open issues 8.1 logrt[] items It will not be possible to use this with items of type logrt[] due to the use of opendir(3). 8.2 Testing As written above, I only have limited access to more "exotic" platforms (from the OSS point Looking forward to any input and constructive criticism. |
Comments |
Comment by J. Fischer [ 2010 Jan 21 ] |
I have worked out a prototype for the implementation of privilege separation in ZABBIX agent. The patch for it is attached. To try it out:
The patch introduces three new options for zabbix_agentd.conf: PrivEnable=(0|1) - Runtime configuration of privilege separation functionality (Default: 1) PrivEnforce=(0|1) - Whether to enforce that any call to zbx_priv_open() will be performed via the privileged process. If set to 0, the agent will check whether the user "zabbix" has read permissions to a given file, and if it has, use default zbx_open() on that file. If set to 1, any call to zbx_priv_open() will be send through the privileged process and all whitelist constrainsts (see below) will apply. The default is 0. PrivWhitelist=<list of patterns> - Patterns to paths that the privileged process is allowed to open. Multiple patterns can be given and are separated using comma. Pattern matching will NOT be performed recursively. That is, a pattern "/var/log/*" would allow access for "/var/log/messages" but not "/var/log/audit/audit.log". This is to prevent path escape through using "/var/log/../../etc/shadow" or similar. The default is no pattern, which disallows access to any file. Open issues:
Things to note:
|
Comment by J. Fischer [ 2010 Apr 29 ] |
Attached is an updated patch which will apply cleanly to 1.8.2 version of ZABBIX agent. Also, support for HP-UX has been added. Might also compile on other commercial and/or older UNIX systems now. |
Comment by richlv [ 2010 May 26 ] |
as noted in http://www.zabbix.com/forum/showthread.php?p=63528#post63528, supporting command execution with privsep would also be beneficial |
Comment by richlv [ 2014 Dec 12 ] |
ZBXNEXT-2638 is similar |
Comment by Oleksii Zagorskyi [ 2015 Mar 07 ] |
Something related (but to server) mentioned in ZBXNEXT-2735 |
Comment by Glebs Ivanovskis (Inactive) [ 2018 Jan 31 ] |
Just wondering, what is the difference between this proposal (or similar ZBXNEXT-2638) and running two or more agents with different access privileges, firewall rules, etc. and with different configurations (e.g. user parameters, remote commands enabled/disabled, etc.)? P.S. Speaking of
You can't imagine how little code is enough to do terrible security bugs. |
Comment by Marc [ 2018 Jan 31 ] |
glebs.ivanovskis, using multiple agents is actually no option due to |