I have a bash script that I run through procmail. Procmail passes into the subject field and from the email as arguments to the bash script. Since these values ββare not processed in any way, I am trying to find out if there are any vulnerabilities in the area of ββinjections in bash that someone could use, and if so, what can I do to protect them. Here is a sample code illustrating what happens:
This bash script will be called by procmail with a .procmailrc script as follows:
:0 * ^From:\s*\/.* { FROM = "$MATCH" } :0 * ^Subject:\s*\/.* { SUBJECT = "$MATCH" } :0 c: * ^To:.*@example.com | /home/john_doe/examplescript.bash "$FROM" "$SUBJECT"
Two areas that I'm interested in regarding injection vulnerabilities are in creating a script:
/home/john_doe/examplescript.bash "$FROM" "$SUBJECT"
and using variables in the script.
/usr/sbin/sendmail -t <<EOF From: "myhost Administrator" < admin@myhost.example.com > To: john_doe@gmail.com Subject: An email subject You've received a new email. It has a subject of "$2" It was sent from "$1". EOF
If your curious, here is the actual use case that raised this question in my opinion
source share