Faille-htaccess-limit-get-post

De Aldeid.
Image:incomplete.png
Section incomplète ou article incomplet
Cette section ou cet article doit être complété(e) car il (elle) est en cours d'élaboration. Merci de votre compréhension.
Incomplete section or article
This section or this article must be completed, it is currently in progress. Thank you for your comprehension.

Sommaire

Faille du fichier .htaccess

Description

Mise en évidence de la faille

Tester si un site est vulnérable

Afin de mettre en évidence la faille deux types de requêtes sont testées :

  • Requête correctement formée (Méthode GET, version HTTP/1.1)
  • Requête mal formée (Méthode inexistante : OOPS, version HTTP/1.1)

sur deux serveurs :

  • L'un protégé contre la faille : google.fr
  • L'autre non protégé : apparaît sous forme d'astérisques dans l'exemple

Les résultats obtenus sont reportés dans le tableau suivant :

Requête Site protégé Site Non protégé
Requête standard
# nc google.fr 80
GET / HTTP/1.1
Host: 127.0.0.1

HTTP/1.1 200 OK
Date: Mon, 16 Nov 2009 06:56:06 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Server: gws
X-XSS-Protection: 0
Transfer-Encoding: chunked

fef
<!doctype html><html><head><meta http-equiv=
"content-type" content="text/html; charset=I
SO-8859-1"><title>Google</ title><script>win
dow.google={kEI:"hvcAS8bcCtSOjAf5o5WLCw",kEX
(...tronqué...)
# nc ********.com 80
GET / HTTP/1.1
Host: 127.0.0.1

HTTP/1.1 200 OK
Date: Mon, 16 Nov 2009 07:28:29 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11
OpenSSL/0.9.8k PHP/5.3.0
X-Powered-By: PHP/5.3.0
X-Pingback: http://**************.********.
com/xmlrpc.php
Cache-Control: max-age=60
Expires: Mon, 16 Nov 2009 07:29:29 GMT
MS-Author-Via: DAV
X-Frame-Options: SameOrigin
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

2016
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
 Transitional//EN" "http://www.w3.org/TR/xht
ml1/DTD/xhtml1-transitional.dtd">
(...tronqué...)
Requête mal formée
# nc google.fr 80
OOPS / HTTP/1.1
Host: 127.0.0.1

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=UTF-8
Content-Length: 1350
Date: Mon, 16 Nov 2009 07:36:45 GMT
Server: GFE/2.0
X-XSS-Protection: 0

<html><head>
<meta http-equiv="content-type" content="tex
t/html;charset=utf-8">
<title>400 Bad Request</title>
<style><!--
body {font-family: arial,sans-serif}
(...tronqué...)
# nc ********.com 80
GET / HTTP/1.1
Host: 127.0.0.1

HTTP/1.1 200 OK
Date: Mon, 16 Nov 2009 07:28:29 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11
OpenSSL/0.9.8k PHP/5.3.0
X-Powered-By: PHP/5.3.0
X-Pingback: http://**************.********.
com/xmlrpc.php
Cache-Control: max-age=60
Expires: Mon, 16 Nov 2009 07:29:29 GMT
MS-Author-Via: DAV
X-Frame-Options: SameOrigin
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

2016
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
 Transitional//EN" "http://www.w3.org/TR/xht
ml1/DTD/xhtml1-transitional.dtd">
(...tronqué...)

Comme nous pouvons le constater, le serveur protégé renvoie un code 400 (Bad request : La syntaxe de la requête est erronée) pour la requête mal formée alors que l'autre serveur renvoie un code 200 (OK : requête traitée avec succès) bien que la méthode employée soit inexistante (Méthode OOPS).

Application aux fichiers .htaccess

Il est possible de contourner une restriction d'accès (protection par fichier .htaccess) en exploitant les limitations apportées dans la section <LIMIT>.

Voici un exemple de fichier .htaccess :

Authname "Authentification"
AuthUserFile /usr/local/wwwpass/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
<LIMIT GET POST> 
require valid-user
</LIMIT>

Contre-mesure

Outils personnels