Het is mogelijk om controles aan de kant van de agent te beperken door een lijst met items te maken die zijn toegestaan (whitelist), een lijst met items die zijn verboden (blacklist), of een combinatie van een whitelist en een blacklist.
Gebruik hiervoor een combinatie van twee agent configuratie parameters:
AllowKey=<patroon> - geeft aan welke controles zijn toegestaan; <patroon> wordt opgegeven met een wildcard (*) expressieDenyKey=<patroon> - geeft aan welke controles zijn verboden; <patroon> wordt opgegeven met een wildcard (*) expressieHoud er rekening mee dat:
Daarom moet u om externe commando's toe te staan AllowKey=system.run[<commando>,*] opgeven voor elk toegestaan commando, waarbij * staat voor de wacht- en nuwachtmodus. Het is ook mogelijk om de AllowKey=system.run[*] parameter op te geven om alle commando's met wacht- en nuwachtmodi toe te staan. Om specifieke externe commando's te verbieden, voegt u DenyKey parameters toe met system.run[] commando's voordat de AllowKey=system.run[*] parameter wordt opgegeven.
You can specify an unlimited number of AllowKey or DenyKey rules, though their order matters.
For example, when evaluating vfs.file.contents[/etc/passwd], the rules are processed as follows:
AllowKey=vfs.file.contents[/tmp/app.log] # Item key pattern does not match, agent proceeds to the next rule.
AllowKey=vfs.file.contents[/etc/passwd] # Item key pattern matches; agent allows the item check and stops rule evaluation.
DenyKey=vfs.file.*[*] # Agent ignores the rule, as the evaluation has stopped.The following rule order will deny the item check:
DenyKey=vfs.file.*[*] # Item key pattern matches; agent denies the item check and stops rule evaluation.
AllowKey=vfs.file.contents[/etc/passwd] # Agent ignores the rule, as the evaluation has stopped.
AllowKey=vfs.file.contents[/tmp/app.log] # Agent ignores the rule, as the evaluation has stopped.Allow only two vfs.file item checks and two system.run commands:
AllowKey=vfs.file.contents[/tmp/app.log]
AllowKey=vfs.file.size[/tmp/app.log]
AllowKey=system.run[/usr/bin/uptime]
AllowKey=system.run[/usr/bin/df -h /]
DenyKey=vfs.file.*[*]Setting DenyKey=system.run[*] is unnecessary, because all other system.run commands are denied by default.
Allow Zabbix agent to execute scripts on hosts via all available methods:
system.run[myscript.sh] key)system.run[myscript.sh,nowait] key)system.run Zabbix agent items with the script, for example:
system.run[myscript.sh]system.run[myscript.sh,wait]system.run[myscript.sh,nowait]To control the wait/nowait parameter, you must set a different rule. For example, you can allow only system.run[myscript.sh,wait] items, thus excluding other methods:
This example shows how to secure overly permissive AllowKey or DenyKey rules.
Consider the following rules:
AllowKey=system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat*"]
DenyKey=vfs.file.*
DenyKey=system.cpu.load[*]On Windows, you must escape spaces in the path using a caret (^).
These rules contain a wildcard (*), which can be misused:
test.bat script can be executed with any arguments, including unintended ones.vfs.file.* pattern matches only item keys without parameters; however, all vfs.file items require parameters.system.cpu.load[*] pattern matches only item keys with parameters; however system.cpu.load items do not require parameters.To secure these rules, explicitly allow executing test.bat only with specific arguments, and deny correct item key patterns; for example:
AllowKey=system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat status"]
AllowKey=system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat version"]
DenyKey=vfs.file.*[*]
DenyKey=system.cpu.load
DenyKey=system.cpu.load[*]You can test the rules by running the following commands, which will return ZBX_NOTSUPPORTED.
cd "C:\Program Files\Zabbix Agent 2"
zabbix_agent2.exe -t system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat debug"]
zabbix_agent2.exe -t vfs.file.size["C:\ProgramData\MyApp\config.ini"]
zabbix_agent2.exe -t vfs.file.contents["C:\Windows\System32\drivers\etc\hosts"]
zabbix_agent2.exe -t system.cpu.load
zabbix_agent2.exe -t system.cpu.load[all,avg1]| Patroon | Beschrijving | Overeenkomt | Geen overeenkomst |
|---|---|---|---|
| * | Overeenkomst met alle mogelijke sleutels met of zonder parameters. | Elk | Geen |
| vfs.file.contents | Komt overeen met vfs.file.contents zonder parameters. |
vfs.file.contents | vfs.file.contents[/etc/passwd] |
| vfs.file.contents[] | Komt overeen met vfs.file.contents met lege parameters. |
vfs.file.contents[] | vfs.file.contents |
| vfs.file.contents[*] | Komt overeen met vfs.file.contents met willekeurige parameters; komt niet overeen met vfs.file.contents zonder vierkante haken. |
vfs.file.contents[] vfs.file.contents[/pad/naar/bestand] |
vfs.file.contents |
| vfs.file.contents[/etc/passwd,*] | Komt overeen met vfs.file.contents met eerste parameters overeenkomend met /etc/passwd en alle andere parameters met een willekeurige waarde (ook leeg). |
vfs.file.contents[/etc/passwd,] vfs.file.contents[/etc/passwd,utf8] |
vfs.file.contents[/etc/passwd] vfs.file.contents[/var/log/zabbix_server.log] vfs.file.contents[] |
| vfs.file.contents[*passwd*] | Komt overeen met vfs.file.contents met eerste parameter overeenkomend met *passwd* en geen andere parameters. |
vfs.file.contents[/etc/passwd] | vfs.file.contents[/etc/passwd,] vfs.file.contents[/etc/passwd, utf8] |
| vfs.file.contents[*passwd*,*] | Komt overeen met vfs.file.contents met alleen de eerste parameter overeenkomend met *passwd* en alle volgende parameters met een willekeurige waarde (ook leeg). |
vfs.file.contents[/etc/passwd,] vfs.file.contents[/etc/passwd, utf8] |
vfs.file.contents[/etc/passwd] vfs.file.contents[/tmp/test] |
| vfs.file.contents[/var/log/zabbix_server.log,*,abc] | Komt overeen met vfs.file.contents met eerste parameter overeenkomend met /var/log/zabbix_server.log, derde parameter overeenkomend met 'abc' en een willekeurige (ook lege) tweede parameter. |
vfs.file.contents[/var/log/zabbix_server.log,,abc] vfs.file.contents[/var/log/zabbix_server.log,utf8,abc] |
vfs.file.contents[/var/log/zabbix_server.log,,abc,def] |
| vfs.file.contents[/etc/passwd,utf8] | Komt overeen met vfs.file.contents met eerste parameter overeenkomend met /etc/passwd, tweede parameter overeenkomend met 'utf8' en geen andere argumenten. |
vfs.file.contents[/etc/passwd,utf8] | vfs.file.contents[/etc/passwd,] vfs.file.contents[/etc/passwd,utf16] |
| vfs.file.* | Komt overeen met alle sleutels die beginnen met vfs.file. zonder enige parameters. |
vfs.file.contents vfs.file.size |
vfs.file.contents[] vfs.file.size[/var/log/zabbix_server.log] |
| vfs.file.*[*] | Komt overeen met alle sleutels die beginnen met vfs.file. met willekeurige parameters. |
vfs.file.size.bytes[] vfs.file.size[/var/log/zabbix_server.log, utf8] |
vfs.file.size.bytes |
| vfs.*.contents | Komt overeen met elke sleutel die begint met vfs. en eindigt met .contents zonder enige parameters. |
vfs.mount.point.file.contents vfs..contents |
vfs.contents |