by shigemk2

当面は技術的なことしか書かない

MySQLのgrantとかで思い出すこと

stackoverflow.com

アクセスする側のドメインでアクセスを制御したりできる。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%.example.com' 
    IDENTIFIED BY 'some_characters' 
    WITH GRANT OPTION;
FLUSH PRIVILEGES;

stackoverflow.com

The percent sign means all ip's so localhost is superfluous ... There is no need of the second record with the localhost .

ディレクトリトラバーサルとは

利用者が供給した入力ファイル名のセキュリティ検証/無害化が不十分であるため、ファイルAPIに対して「親ディレクトリへの横断 (traverse)」を示すような文字がすり抜けて渡されてしまうような攻略方法のこと

ディレクトリトラバーサル - Wikipedia

e-words.jp

以下、引用。

<?php
$template = 'blue.php';
if ( is_set( $_COOKIE['TEMPLATE'] ) )
   $template = $_COOKIE['TEMPLATE'];
include ( "/home/users/phpguru/templates/" . $template );
?>

こんなのがあったとして、こういうクッキーを送信すると、/etc/passwdの中身が見れてしまう。

GET /vulnerable.php HTTP/1.0
Cookie: TEMPLATE=../../../../../../../../../etc/passwd

っていう脆弱性のこと。

What is directory traversal attack?

Directory traversal attack

Directory traversal attack - Wikipedia, the free encyclopedia

A directory traversal (or path traversal) consists in exploiting insufficient security validation / sanitization of user-supplied input file names, so that characters representing "traverse to parent directory" are passed through to the file APIs.

It's sample code.

<?php
$template = 'red.php';
if (isset($_COOKIE['TEMPLATE']))
   $template = $_COOKIE['TEMPLATE'];
include ("/home/users/phpguru/templates/" . $template);
?>

The repeated ../ characters after /home/users/phpguru/templates/ has caused include() to traverse to the root directory, and then include the Unix password file /etc/passwd.