My securiy filter doesn't let special characters through. HELP PLEASE

Discussion in 'PHP' started by x0x, Dec 25, 2008.

  1. #1
    My site has some injection filters that don't let through characters like: öäõü@£$€{[]

    The filters are supposed to keep users from SQL injection. Script has register_globals ON.

    My users can't post messages properly. How can this be fixed?

    if(str_replace("/", "", $_SERVER['PHP_SELF']) != 'adminpostfile.php'){
    
    // ant injection filters
    if (count($HTTP_GET_VARS) > 0) {foreach ($_GET as $name => $value) { if(is_array($value)){ ${$name} = $value; }else{ ${$name} = htmlentities($value,ENT_QUOTES,"UTF-8");} } }
    
    if (count($HTTP_POST_VARS) > 0) {foreach ($_POST as $name => $value) { if(is_array($value)){ ${$name} = $value; }else{ ${$name} = htmlentities($value,ENT_QUOTES,"UTF-8");} } }
    
    if (count($HTTP_COOKIE_VARS) > 0) {foreach ($_COOKIE as $name => $value) { if(is_array($value)){ ${$name} = $value; }else{ ${$name} = htmlentities($value,ENT_QUOTES,"UTF-8");} } }
    //ant injection filters
    
    }
    PHP:
    The weird thing is that it let's me post special characters on my offline windows server... The production server is running a linux system.
     
    x0x, Dec 25, 2008 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    I can't swear but it's something with the charset "utf-8"
     
    crivion, Dec 25, 2008 IP
  3. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    What can I do?
     
    x0x, Dec 25, 2008 IP
  4. ignas2526

    ignas2526 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello,
    Try ISO-8859-15
     
    ignas2526, Dec 25, 2008 IP
  5. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #5
    That worked, thanks.

    Will that open any security holes or what so ever?


    Also I've always had a weird issue. When I type anything behind the url like ' SELECT * FROM blabla, it will give me 10s of sql errors. Is there a way to make it not do that? On my local windows server it doesn't do that... Weird.
     
    x0x, Dec 25, 2008 IP
  6. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #6
    Maybe say what the errors are?
     
    Danltn, Dec 26, 2008 IP
  7. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #7
    One of the many:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'_xsap WHERE id=''' at line 1Duplicate entry '' for key 1



    That appeared when I typed ' behind the url.
     
    x0x, Dec 26, 2008 IP
  8. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #8
    You don't need the apostrophe...
    [b]\'[/b]_xsap WHERE id=''
    Code (markup):
     
    Danltn, Dec 26, 2008 IP
  9. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #9
    What do you mean? I just demonstrated how I brought up the errors... Does this mean the site can be injected?
     
    x0x, Dec 26, 2008 IP
  10. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #10
    Do us all a favour and post the code in question. :)
     
    Danltn, Dec 26, 2008 IP
  11. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #11
    How would that work? I can't post the whole script. It has 100s of pages.
     
    x0x, Dec 26, 2008 IP
  12. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #12
    Oh sorry, I'll just debug it without having a clue how it works...

    Seriously though, post any pages which send SQL queries, including any SQL handling classes.
     
    Danltn, Dec 26, 2008 IP