/lost+found
-
/home/recent
- Performing a `pg_basebackup` against the GitLab’s managed PostgreSQL database
- YubiKey Bio Series for fingerprint authentication
- Huge /var/log/lastlog file and BackupPC backup
- Quick benchmark of Gzip and Gnupg throughput
- « realm join » returns with error « Server not found in Kerberos database »
- Notes to self for future breakage involving `intel-microcode` updates
- Configuring Linux VM with french MacBook Pro keyboard and VMware Fusion
- Siara Systems leaking CPE’s MAC addresses?
- Building a Netgear DM111Pv2 firmware without scfgmgr
- Netgear DM111P backdoor?
/var/archives
- juin 2026
- février 2026
- octobre 2020
- juin 2020
- décembre 2016
- janvier 2014
- décembre 2013
- octobre 2013
- août 2013
- juillet 2013
- juin 2013
- mai 2013
- février 2013
- novembre 2012
- octobre 2012
- juillet 2012
- juin 2012
- mai 2012
- avril 2012
- mars 2012
- février 2012
- janvier 2012
- novembre 2011
- octobre 2011
- septembre 2011
- juillet 2011
- juin 2011
- mai 2011
- avril 2011
- mars 2011
- février 2011
- janvier 2011
- décembre 2010
- novembre 2010
- octobre 2010
- septembre 2010
- août 2010
- juillet 2010
- juin 2010
- mai 2010
- avril 2010
Re: Hackers bypass .htaccess security by using GETS rather than GET
http://cd34.com/blog/web-security/hackers-bypass-htaccess-security-by-using-gets-rather-than-get/
After reading this article I immediately checked my application and found that it was subject to this issue. I started worrying and testing out how to mitigate this issue and protect my application.
However, after calming down, I started looking for the cause of this issue, and finally I came to the conclusion that the problem is not from PHP, or Apache, but only in the content of the `.htaccess' file.
Here are my observation on this issue and the working of Apache with mod_php5.
- The problem is not only with Zend Server as I replicated the problem with a standard PHP 5.3 and the same `.htaccess'.
-
Why is Apache granting access to "GETS" requests without authentication ?
The .htaccess specify that the "require valid-user" only applies to "GET" and "POST" requests. So, a "GETS" request is not subject to the "require valid-user".
So the request is processed without asking for authentication.
-
Why Apache does not reject the invalid "GETS" request ?
Apache does not send a "invalid method" HTTP error message because the ressource pointed by the URL is handled by mod_php5 (AddHandler php5-script .php), so it assumes that mod_php5 will know what to do with a "GETS" requests.
So, it passes the request to mod_php5.
This is convenient for implementing new HTTP method like DAV methods in PHP without Apache knowing in advance the full set of method for this protocol.
-
Why is PHP treating the request as a "GET" request ?
From the source code of PHP 5.3 (main/SAPI.C:sapi_activate()) we see that PHP first check if the request is a "HEAD" (special treatment "only headers") or "POST" (special treatment for decoding the POST data), then anything else is handled to the script.
This is also convenient for handling new HTTP methods (e.g. DAV PROPFIND) from PHP scripts.
So, mod_php5 run the scripts and assumes that the script will know what to do with a "GETS" method.
The script does not check which method was used, so it print out his result on STDOUT and that gives a "HTTP 200 OK" response to the client.
Conclusion
After these observations, I come to the conclusion that this behaviour is normal, and that the real problem lies in the `.htaccess' which only protects "GET" and "POST" request, missing the fact that other methods can pass and be used to trigger the execution of the PHP script.
One solution is to deny acces to anything that is not "GET" or "POST" with a <LimitExcept />:
AuthUserFile .htpasswd AuthName "Protected Area" AuthType Basic <Limit GET POST> require valid-user </Limit> <LimitExcept GET POST> Order Allow,Deny Deny from all </LimitExcept>
Another one would be to check in the PHP scripts that the $PHP_AUTH_USER variable is set, which will indicate that the HTTP Basic auth as been successfully completed.
Or check $_SERVER["REQUEST_METHOD"], and return an error message if the method is not "GET" or "POST".
Publié dans code
Commentaires fermés sur Re: Hackers bypass .htaccess security by using GETS rather than GET
« Tu sais ce qui est le plus dur, là dedans ? avait-il repris doucement. C'est de se rendre compte d'un coup qu'on a passé toute sa vie justement à ne pas penser à cet instant précis. À faire comme si l'on avait jamais soi-même à passer par ce moment incontournable, le moment où l'on découvre qu'il n'y a plus d'avenir devant soi, plus de choix possible, même plus le rêve de changer de vie. Quand on doit abandonner jusqu'à l'illusion qu'on peut encore tout changer… La fin de la route, quoi. »
L'homme qui voulait vivre sa vie (ISBN 978-2-266-19460-0), p. 72, Douglas Kennedy
Publié dans quote
Commentaires fermés sur
TOTD: purge
Tip Of The Day: purge
On Mac OSX, the `purge' command can be used to free up the disk caches.
It's seems to be the equivalent of the `sync && echo 3 > /proc/sys/vm/drop_caches' on Linux.
Publié dans regular
Commentaires fermés sur TOTD: purge
flock in bash script
util-linux(-ng) flock
On Linux systems, there is a `flock' command (from `util-linux' or `util-linux-ng') that can be used to run a command inside a file lock/unlock block.
function run_lock_flock {
LOCK=$1
shift
touch "$LOCK"
flock "$LOCK" "$@"
}
portable way with perl
On other Unix systems, a portable way could be to use perl to mimic the util-linux(-ng) command shown above:
function run_lock_perl {
LOCK=$1
shift
perl -e '
use Fcntl":flock";
$l=shift;
open(L,">>",$l)||die"Error open: $!\n";flock(L,LOCK_EX)||die"Error lock: $!\n";
system(@ARGV);$?==-1&&die"Error executing command!";
flock(L,LOCK_UN);close(L);
exit($?>>8)
' "$LOCK" "$@"
}
autodetect flock
Finally, a main `run_lock' function to autodetect which type of flock to use, and run the given command with the given lock file.
function run_lock {
type -p flock
if [ $? -eq 0 ]; then
run_lock_flock "$@"
else
run_lock_perl "$@"
fi
}
run_lock mylock.lck /usr/bin/foo -c bar -l baz
Publié dans code
Commentaires fermés sur flock in bash script
Avec les mots on ne se méfie jamais suffisamment, ils ont l'air de rien les mots, pas l'air de dangers bien sûr, plutôt de petits vents, de petits sons de bouche, ni chauds, ni froids, et facilement repris dès qu'ils arrivent par l'oreille par l'énorme ennui gris mou du cerveau. On ne se méfie pas d'eux des mots et le malheur arrive
Voyage au bout de la nuit (ISBN 2070360284), p. 487, Louis-Ferdinand Céline
Publié dans quote
Commentaires fermés sur
GameBoy Emulation in JavaScript
Publié dans link
Commentaires fermés sur GameBoy Emulation in JavaScript
Postgresql 9.0 Hot-Standby and Streaming-Replication Overview [fr]
Link: Postgresql 9.0 Hot-Standby and Streaming-Replication Overview [fr]
Un petit mémo suite à des tests de mise en œuvre du hot-standby et streaming-replication de PostgreSQL 9.0.
Le peer-to-peer évolue
Link: Le peer-to-peer évolue
Publié dans link
Commentaires fermés sur Le peer-to-peer évolue
