mod_rewrite exploit *patch your servers now*

Discussion in 'Apache' started by Shoemoney, Jul 28, 2006.

  1. #1
    http://www.apache.org/

    Description:
    According to a vendor announcement [0], a vulnerability exists in the
    mod_rewrite module of the Apache HTTP Server [1]. Depending on the
    manner in which the Apache HTTP Server was compiled, the software
    defect may result in a vulnerability which, in combination with
    certain types of "RewriteRule" directives in the server configuration
    files, could be triggered remotely. The nature of the vulnerability
    can be Denial of Service (DoS) or potentially allow arbitrary code
    execution. This issue only affects installations using a "RewriteRule"
    with the following characteristics: it allows the attacker to control
    the initial part of the rewritten URL (for example if the substitution
    URL starts with "$1") or the RewriteRule flags do NOT include any of
    the flags Forbidden (F), Gone (G), or NoEscape (NE).
     
    Shoemoney, Jul 28, 2006 IP
    nevetS likes this.
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    For those of you in Rio Linda,

    RewriteRule whatever/(.*)$ $1 [L]

    will expose it, and

    RewriteRule whatever/(.*)$ file.php?whatever=$1 [L]

    won't.

    http://www.kb.cert.org/vuls/id/395412
     
    Nintendo, Jul 28, 2006 IP
  3. Leo727

    Leo727 Active Member

    Messages:
    161
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Can someone please explain the full effect of this problem. The security notice says the vulnerability "could allow a remote attacker to execute arbitrary code on an affected web server." Does that mean *any* code? Is it possible that hackers can use it give them access to the server's files?

    It's relatively easy to patch our own servers (when the patch is available), I'm more worried about the servers that are out of our control yet affect us as users, eg. if you're ordering something online, and the server is not patched, could hackers use the vulnerability to gain access to our personal details...

    Now if we'd all listened to Microsoft, and used their excellent no-vulnerability Windows servers, we wouldn't be having this problem ;)
     
    Leo727, Jul 29, 2006 IP
  4. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #4
    a1 mainly everything looks vulnerable that uses the $1 pass off

    post your rules and me or nino can probably tell you if you should worry
     
    Shoemoney, Jul 29, 2006 IP
  5. Travis

    Travis Peon

    Messages:
    539
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey Shoemoney :)

    Can you tell me if you see a flaw in this rule?

    RewriteRule (.*)\.jpg$ /x/1/sig.php?user=$1

    Thanks
    (Really enjoy reading your blog, keep up the good work :))
     
    Travis, Jul 29, 2006 IP
  6. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #6
    from this exploit you should be ok with that... however you should add [L] at the end and also limit what charectors you take in..

    .* is a total wildcard
     
    Shoemoney, Jul 30, 2006 IP
  7. kouala

    kouala Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi, i'm this htaccess but it's not OK (sorry for my english:))

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule test/news-([a-z0-9\_]+)-([0-9]+)\.php$ test/news.php?id=$2 [L]

    Please help me !
     
    kouala, Dec 20, 2006 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Post an example of the original URL and how you want it.
     
    Nintendo, Dec 20, 2006 IP
  9. kouala

    kouala Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi,

    Transform this URL:
    http://www.test.com/test/news-zune_software_disponible_pour_windows_vista-7598.php

    To this:
    http://www.test.com/test/news.php?id=7598
     
    kouala, Dec 20, 2006 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #10
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^test/news\-([^.]+)\-([^.]+)\.html$ news.php?id=$2 [L]

    And you have to edit the script to link to the new URLs, and note the new URL ends in .html. That's much better than .php!!
     
    Nintendo, Dec 21, 2006 IP