|
1 | 1 | .\" |
2 | | -.\" SEC (Simple Event Correlator) 2.9.alpha2 - sec.man |
| 2 | +.\" SEC (Simple Event Correlator) 2.9.0 - sec.man |
3 | 3 | .\" Copyright (C) 2000-2021 Risto Vaarandi |
4 | 4 | .\" |
5 | 5 | .\" This program is free software; you can redistribute it and/or |
|
16 | 16 | .\" along with this program; if not, write to the Free Software |
17 | 17 | .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | 18 | .\" |
19 | | -.TH sec 1 "April 2021" "SEC 2.9.alpha2" |
| 19 | +.TH sec 1 "May 2021" "SEC 2.9.0" |
20 | 20 | .SH NAME |
21 | 21 | sec \- simple event correlator |
22 | 22 | .SH SYNOPSIS |
@@ -5870,6 +5870,52 @@ and |
5870 | 5870 | actions, the program command line is not parsed by shell, |
5871 | 5871 | even if shell metacharacters are present in the command line. |
5872 | 5872 | .PP |
| 5873 | +Disabling shell parsing for command lines can be useful for avoiding unwanted |
| 5874 | +side effects. For example, consider the following badly written rule for |
| 5875 | +sending an e-mail to a local user if 10 SSH login failures have been observed |
| 5876 | +for this user from the same IP address during 300 seconds: |
| 5877 | +.PP |
| 5878 | +type=SingleWithThreshold |
| 5879 | +.br |
| 5880 | +ptype=RegExp |
| 5881 | +.br |
| 5882 | +pattern=sshd\\[\\d+\\]: Failed .+ for (.+) from ([\\d.]+) port \\d+ ssh2 |
| 5883 | +.br |
| 5884 | +desc=Failed SSH logins for user $1 from $2 |
| 5885 | +.br |
| 5886 | +action=pipe 'Failed SSH logins from $2' /bin/mail -s alert $1 |
| 5887 | +.br |
| 5888 | +window=300 |
| 5889 | +.br |
| 5890 | +thresh=10 |
| 5891 | +.PP |
| 5892 | +Unfortunately, the above rule allows for the execution of arbitrary command |
| 5893 | +lines with the privileges of the SEC process. |
| 5894 | +For example, consider the following malicious command line for providing |
| 5895 | +fake input events for the rule: |
| 5896 | +.PP |
| 5897 | +logger -p authpriv.info -t sshd -i 'Failed password for `/usr/bin/touch /tmp/test` from 127.0.0.1 port 12345 ssh2' |
| 5898 | +.PP |
| 5899 | +When this command line is repeatedly executed, the attacker is able to trigger |
| 5900 | +the execution of the command line |
| 5901 | +.IR "/bin/mail -s alert `/usr/bin/touch /tmp/test`" . |
| 5902 | +However, this command line is parsed by shell that triggers the execution |
| 5903 | +of the command line specified by the attacker: |
| 5904 | +.IR "/usr/bin/touch /tmp/test" . |
| 5905 | +For fixing this issue, the |
| 5906 | +.I pipe |
| 5907 | +action can be replaced with |
| 5908 | +.I pipeexec |
| 5909 | +which will disable the shell parsing: |
| 5910 | +.PP |
| 5911 | +action=pipeexec 'Failed SSH logins from $2' /bin/mail -s alert $1 |
| 5912 | +.PP |
| 5913 | +As another workaround, the regular expression pattern of the rule can be |
| 5914 | +modified to match user names that do not contain shell metacharacters, |
| 5915 | +for example: |
| 5916 | +.PP |
| 5917 | +pattern=sshd\\[\\d+\\]: Failed .+ for ([\\w.-]+) from ([\\d.]+) port \\d+ ssh2 |
| 5918 | +.PP |
5873 | 5919 | SEC communicates with its child processes through pipes (created with the |
5874 | 5920 | .BR pipe (2) |
5875 | 5921 | system call). |
|
0 commit comments