Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for CVE-2014-5284 which allows for root escalation via temp files #291

Merged
merged 1 commit into from
Sep 9, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions active-response/host-deny.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,18 @@ if [ "x${ACTION}" = "xadd" ]; then
# Deleting from hosts.deny
elif [ "x${ACTION}" = "xdelete" ]; then
lock;
TMP_FILE = `mktemp /var/ossec/ossec-hosts.XXXXXXXXXX`
if [ "X${TMP_FILE}" = "X" ]; then
# Cheap fake tmpfile, but should be harder then no random data
TMP_FILE = "/var/ossec/ossec-hosts.`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -1 `"
fi
if [ "X$UNAME" = "XFreeBSD" ]; then
cat /etc/hosts.allow | grep -v "ALL : ${IP} : deny$"> /tmp/hosts.deny.$$
mv /tmp/hosts.deny.$$ /etc/hosts.allow
cat /etc/hosts.allow | grep -v "ALL : ${IP} : deny$"> ${TMP_FILE}
mv ${TMP_FILE} /etc/hosts.allow
else
cat /etc/hosts.deny | grep -v "ALL:${IP}$"> /tmp/hosts.deny.$$
cat /tmp/hosts.deny.$$ > /etc/hosts.deny
rm /tmp/hosts.deny.$$
cat /etc/hosts.deny | grep -v "ALL:${IP}$"> ${TMP_FILE}
cat ${TMP_FILE} > /etc/hosts.deny
rm ${TMP_FILE}
fi
unlock;
exit 0;
Expand Down