Ajax Security Question: JQuery ajax() + PHP scandir() = Security Issue? -


I'm starting with PHP security issues Someone reported a security problem with my code but never got the details Given

Below is a short version of code.

Do you see any security issues

HTML document

/ P>

  Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ AJAX ({type: "post", url: "example.php", cache: incorrect, data: {foo: "picture", bar: "something else"}, success: function (html) {warning (html); }}); & Lt; / Script & gt;  

PHP document

  & lt; Php $ foo = filter_var ($ _ POST ["foo"], FILTER_SANITIZE_STRING); $ Bar = filter_var ($ _ POST ["bar"], FILTER_SANITIZE_STRING); $ Foo = Scanderer ($ foo); $ Bar = (Explosion (",", $ bar)); Foreign currency ($ fu $$) {echo "img src = '$ foo / $ a' & gt;"; }? & Gt;  

Yes, I can tell every file on my machine. And potentially other machines that may be accessed through your server

FILTER_SANITIZE_STRING is designed to protect HTML, not for file path references, so it does not really help you here This information can help to run other unsafe software or identify sensitive files. . You should use only for that generated HTML as an output filter and not using the backend function.

You want to restrict the use of dangerous path tokens such as:, @, .., \ and / but preserve it by placing characters or values ​​as Tomahigh's example code in the whitelist.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -