Skip to content

Instantly share code, notes, and snippets.

@felds
Created September 25, 2014 22:18
Show Gist options
  • Select an option

  • Save felds/36e8e74de7889ea760ec to your computer and use it in GitHub Desktop.

Select an option

Save felds/36e8e74de7889ea760ec to your computer and use it in GitHub Desktop.
How to protect yourself against Shellshock bug with PHP
<?php
// unsecure execution
$bug = '"() { :;} ; echo vulnerable" bash -c "echo "';
passthru("env X=$bug"); // outputs: "vulnerable"
// secure execution using escapeshellarg
$bug = escapeshellarg('"() { :;} ; echo vulnerable" bash -c "echo "');
passthru("env X=$bug"); // what it should (the dump of env)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment