-5

in my application I have the following part of code and I would like to know if it is vulnerable. In case something can be done, I would like to know how the vulnerability could be valid.

$params = array("param1","param2","param3");

for ($i=0;$i<sizeof($params);$i++) {
    if (isset($HTTP_POST_VARS[$params[$i]])) {
        eval("\$$params[$i] = 
\"".trim($HTTP_POST_VARS[$params[$i]])."\";");
    } elseif (isset($HTTP_GET_VARS[$params[$i]])) {
        eval("\$$params[$i] = 
\"".trim($HTTP_GET_VARS[$params[$i]])."\";");
    } else {
        eval("\$$params[$i] = '';");
}

..

It's an old code, that's why HTTP_POST_VARS / HTTP_GET_VARS.

Thank you!

  • 2
    You are using eval on a user-provided string which did not undergo any kind of check or sanitization. This is most likely vulnerable. Apart from that: this is not a site where you just dump some undocumented code and ask for feedback. At least explain what the code is supposed to do, how it is used, how it tries to protect against vulnerabilities ... and then you can ask if this is sufficiently secure for the documented use case. Downvoted due to the lack of such self-effort. – Steffen Ullrich Jan 12 at 6:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.