Jump to content

PHP Security Issue!


IronicSoul

Recommended Posts

We have a website that allows our users to add html to their profile's and such until some person thought they were real funny and posting this:

 

<iframe src=http://lancxeon.com/jack****.html</iframe>

 

On their profile, in return this contained Javascript on that remote page that acted on our site and our users in a bad way.

 

The link above no longer contains the bad code and is resolved. We would really like to know how to sensor out words/html tags that can cause XSS that our system does not normally detect as bad. Here is a snip lit of our user_class file:

 

// DECODE TO MAKE HTML TAGS FOR PROFILE FIELDS VALID
              $field_value_profile = htmlspecialchars_decode($field_value_profile, ENT_QUOTES);

            // FORMAT VALUE FOR FORM
            } else {
              if($field_info[field_type] == 2) { $field_value = str_replace("<br>", "\r\n",  $field_value); }
            }
                break; 

 

I have read ALOT on the php page on usage of htmlspecialchars and str_replace, but nothing will truly get rid of the code from being used, or at least being html-safe.

 

Any help I would greatly appreciate it!

Link to comment
https://forums.phpfreaks.com/topic/110237-php-security-issue/
Share on other sites

You could just use a function to kill the script if it detects any bad entries.

 

$bad_codes = array("<iframe", "</script>");
foreach ($bad_codes as $bad_code) {
if (preg_match("/" . $bad_code . "/", $profile_data)) {
echo "Invalid Data";
exit();
}
}

Link to comment
https://forums.phpfreaks.com/topic/110237-php-security-issue/#findComment-565774
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.