Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2004
    Posts
    126
    Plugin Contributions
    0

    Default [Done 1.3.7.1] Cross-Site Scripting in 1.3.7

    One of my clients has the latest zen but failed hackersafe's test regarding Cross-Site Scripting. On a few of her pages she has a text box for an attribute (customize your custom painted sign)
    and apparently that is failing. They say we have to filter out the usual suspects (<>) etc.

    Can anyone provide a easy way to do this for text attributes so she can get her official "please come and hack me, I dare you" symbol?

  2. #2
    Join Date
    Mar 2007
    Location
    Lakeland, FL, US
    Posts
    44
    Plugin Contributions
    2

    Idea or Suggestion Re: Cross-Site Scripting in 1.3.7

    One solution would be to pass every field's value through htmlentities on before handling the form data.

    This is an untested example. I just wrote if off the top of my head.

    PHP Code:
    foreach ($_POST as $key => $val) {
        if (
    is_array($val)) {
            foreach(
    $val as $sub_key => $sub_val) {
                
    $_POST[$key][$sub_key] = htmlentities($sub_valENT_QUOTES);
            }
        } else {
            
    $_POST[$key] = htmlentities($valENT_QUOTES);
        }


  3. #3
    Join Date
    Aug 2004
    Posts
    1,590
    Plugin Contributions
    1

    Default Re: Cross-Site Scripting in 1.3.7

    The example above is still a great one. However, to make sure you wish to remain between a-z and 0-9 characters, you could always replace the above with this one:

    PHP Code:
    foreach ($_POST as $key => $val) {
      if (
    preg_match("/[a-z0-9\-\_\s]/i"$val)) {
        if (
    is_array($val)) {
            foreach(
    $val as $sub_key => $sub_val) {
                
    $_POST[$key][$sub_key] = htmlentities($sub_valENT_QUOTES);
            }
        } else {
            
    $_POST[$key] = htmlentities($valENT_QUOTES);
        }
      } else {
      
    $messageStack->add('your_page_name_here'YOUR_TEXT_DEFINITION_NAME_HERE');
      } 

  4. #4
    Join Date
    Aug 2004
    Posts
    126
    Plugin Contributions
    0

    Default Re: Cross-Site Scripting in 1.3.7

    My programmer did the fix for me - added four lines to

    index.php (in the main directory)

    that seems to have done the trick:

    # HackerSafe hack - Removes "WebApp Cross Site Scripting - 2" vulnerability
    foreach($_POST as $var => $val) {
    $_POST[$var]=preg_replace("/</",".", $val);
    $_POST[$var]=preg_replace("/>/",".", $val);
    }

    hope that helps someone!

    A

  5. #5
    Join Date
    Aug 2004
    Posts
    1,590
    Plugin Contributions
    1

    Default Re: Cross-Site Scripting in 1.3.7

    This could be done with:

    PHP Code:
    $_POST[$var]=str_replace("<","."$val);
    $_POST[$var]=str_replace(">","."$val); 
    instead of preg_replace.

  6. #6
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Cross-Site Scripting in 1.3.7

    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Cross site scripting zj silver
    By linnx in forum Addon Templates
    Replies: 5
    Last Post: 20 Feb 2010, 10:21 PM
  2. Replies: 1
    Last Post: 29 Sep 2006, 07:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg