text
stringlengths
1
254
output
stringlengths
2
255
In short, it cannot really be trusted.
Contents of the Accept-Language: header from the current request, if there is one. Example: 'en '.
This is a string denoting the user agent being which is accessing the page.
Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive '.
Mozilla / 4.5 [en] (X11; U; Linux 2.2.9 i586).
Contents of the Host: header from the current request, if there is one.
The IP address from which the user is viewing the current page.
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
For example in Apache you 'll need HostnameLookups On inside httpd.conf for it to exist.
The IP address from which the user is viewing the current page.
The port being used on the user 's machine to communicate with the web server.
The port being used on the user's machine to communicate with the web server.
The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file.
The absolute pathname of the currently executing script.
The port on the server machine being used by the web server for communication.
The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.
String containing the server version and virtual host name which are added to server-generated pages, if enabled.
The port on the server machine being used by the web server for communication. For default setups, this will be '80 '; using SSL, for instance, will change this to whatever your defined secure HTTP port is.
Contains the current script 's path.
String containing the server version and virtual host name which are added to server-generated pages, if enabled.
The URI which was given in order to access this page; for instance, '/ index.html'.
Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.
When running under Apache as module doing HTTP authentication this variable is set to the password provided by the user.
Contains the current script's path. This is useful for pages which need to point to themselves.
Note:
The URI which was given in order to access this page; for instance, '/index.html '.
In earlier versions, use $HTTP_ENV_VARS.
泚意 4.1.0で導入されたした。これ以前のバヌゞョンの堎合は、 $HTTP_ENV_VARS を䜿甚しお䞋さい。
Other environment variables include the CGI variables, placed there regardless of whether PHP is running as a server module or CGI processor.
Other environment variables include the CGI variables, placed there regardless of whether PHP is running as a server module or CGI processor.
This simply means that it is available in all scopes throughout a script.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_ENV; to access it within functions or methods, as you do with $HTTP_ENV_VARS.
$HTTP_ENV_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_ENV_VARS and $_ENV are different variables and that PHP handles them as such)
$HTTP_ENV_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_ENV_VARS and $_ENV are different variables and that PHP handles them as such)
Note:
泚意 4.1.0で導入されたした。これ以前のバヌゞョンの堎合は、 $HTTP_COOKIE_VARS を䜿甚しお䞋さい。
An associative array of variables passed to the current script via HTTP cookies.
An associative array of variables passed to the current script via HTTP cookies. Automatically global in any scope.
This is a 'superglobal', or automatic global, variable.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_COOKIE; to access it within functions or methods, as you do with $HTTP_COOKIE_VARS.
You don' t need to do a global $_COOKIE; to access it within functions or methods, as you do with $HTTP_COOKIE_VARS.
$HTTP_COOKIE_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_COOKIE_VARS and $_COOKIE are different variables and that PHP handles them as such)
These individual globals are not autoglobals.
泚意 4.1.0で導入されたした。これ以前のバヌゞョンの堎合は、 $HTTP_GET_VARS を䜿甚しお䞋さい。
An associative array of variables passed to the current script via the HTTP GET method.
An associative array of variables passed to the current script via the HTTP GET method. Automatically global in any scope.
This is a 'superglobal', or automatic global, variable.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_GET; to access it within functions or methods, as you do with $HTTP_GET_VARS.
You don' t need to do a global $_GET; to access it within functions or methods, as you do with $HTTP_GET_VARS.
$HTTP_GET_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_GET_VARS and $_GET are different variables and that PHP handles them as such)
These individual globals are not autoglobals.
泚意 4.1.0で導入されたした。これ以前のバヌゞョンの堎合は、 $HTTP_POST_VARS を䜿甚しお䞋さい。
An associative array of variables passed to the current script via the HTTP POST method.
An associative array of variables passed to the current script via the HTTP POST method. Automatically global in any scope.
This simply means that it is available in all scopes throughout a script.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_POST; to access it within functions or methods, as you do with $HTTP_POST_VARS.
$HTTP_POST_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_POST_VARS and $_POST are different variables and that PHP handles them as such)
$HTTP_POST_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_POST_VARS and $_POST are different variables and that PHP handles them as such)
An associative array of items uploaded to the current script via the HTTP POST method.
泚意 4.1.0で導入されたした。これ以前のバヌゞョンの堎合は、 $HTTP_POST_FILES を䜿甚しお䞋さい。
This is a 'superglobal', or automatic global, variable.
An associative array of items uploaded to the current script via the HTTP POST method. Automatically global in any scope.
You don' t need to do a global $_FILES; to access it within functions or methods, as you do with $HTTP_POST_FILES.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_FILES; to access it within functions or methods, as you do with $HTTP_POST_FILES.
$HTTP_POST_FILES contains the same information, but is not an autoglobal.
$HTTP_POST_FILES contains the same information, but is not an autoglobal.
An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.
泚意 4.1.0で導入されたした。以前のバヌゞョンには、同等な配列はありたせ ん。
Prior to PHP 4.3.0, $_FILES information was also included into $_REQUEST.
An associative array consisting of the contents of $_GET, $_POST, $_COOKIE, and $_FILES.
This simply means that it is available in all scopes throughout a script.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_REQUEST; to access it within functions or methods.
These individual globals are not autoglobals.
泚意 4.1.0で導入されたした。これ以前のバヌゞョンでは、 $HTTP_SESSION_VARS を䜿甚しお䞋さい。
An associative array containing session variables available to the current script.
An associative array containing session variables available to the current script. See the Session functions documentation for more information on how this is used.
This is a 'superglobal', or automatic global, variable.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_SESSION; to access it within functions or methods, as you do with $HTTP_SESSION_VARS.
You don' t need to do a global $_SESSION; to access it within functions or methods, as you do with $HTTP_SESSION_VARS.
$HTTP_SESSION_VARS contains the same information, but is not an autoglobal.
These individual globals are not autoglobals.
泚意 $GLOBALS は、PHP 3.0.0以降で利甚可胜です。
The variable names are the keys of the array.
An associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.
You don' t need to do a global $GLOBALS; to access it within functions or methods.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $GLOBALS; to access it within functions or methods.
The function is_resource() can be used to determine if a variable is a resource and get_resource_type() will return the type of resource it is.
以䞋にPHPのリ゜ヌスを生成、䜿甚、砎棄するための関数の䞀芧を瀺したす。 is_resource() によりある倉数がリ゜ヌスであるかど うかを調べるこずが可胜です。たた、 get_resource_type() は倉数のリ゜ヌス型を返したす。
Often, once security is established to the point where the PHP user (in this case, the apache user) has very little risk attached to it, it is discovered that PHP is now prevented from writing any files to user directories.
しばしば、PHPナヌザ(この堎合はApacheナヌザ)が非垞に小さなリスクを 有する堎所に䞀床セキュリティが確立されるず、PHPはナヌザディレクト リにりむルスファむルを曞き蟌んだりするこずができなくなりたす。もし くは、デヌタベヌスにアクセスしたり倉曎したりずいったこずが出来なく なりたす。この堎合、良いファむルおよび悪いファむルの曞き蟌み、たた は、良いデヌタベヌストランザクションず悪いデヌタベヌストランザクシ ョンに関しお等しく安党性が確保されおいるず蚀えたす。
It has equally been secured from writing good and bad files, or entering good and bad database transactions.
この芳点からしばしば行われるセキュリティ䞊の倱敗ずしおApacheにルヌ ト暩限を䞎えたり、他の䜕らかの手段でApacheの暩限を昇栌させるずいう ものがありたす。
Escalating the Apache user' s permissions to root is extremely dangerous and may compromise the entire system, so sudo'ing, chroot'ing, or otherwise running as root should not be considered by those who are not security professionals.
Apacheナヌザの暩限をルヌトに昇栌させるこずは非垞に危険であり、シ ステム党䜓を危険にさらす可胜性がありたす。よっお、sudoやchrootの実 行、ルヌト暩限で実行を行う他の手段は、セキュリティに粟通した人以倖 は、考慮するべきではありたせん。
You can also set up apache-only areas, to restrict all web based activity to non-user, or non-system, files.
いく぀かのより簡単な解決策がありたす。 open_basedir を䜿甚するこずによ り、PHPに䜿甚を蚱可するディレクトリを制埡したり制限したりするこず が可胜です。たた、党おのWebベヌスの䜜業をナヌザファむル、システム ファむル以倖のファむルに制限するために、Apache専甚゚リアを蚭定する こずも可胜です。
Accessing system files: http: / /my.host / cgi-bin / php? / etc / passwd
システムファむルぞのアクセス: http://my.host/cgi-bin/php?/etc/passwd
Usually interpreters open and execute the file specified as the first argument on the command line.
URL においお疑問笊 (?) の埌のク゚リヌ情報は、CGI むンタヌフェヌ スにより、むンタプリタにコマンドラむン匕数ずしお枡されたす。通 垞、むンタプリタは、コマンドラむン䞊の最初の匕数に指定されたファ むルを開き、実行したす。
Accessing any web document on server: http: / /my.host / cgi-bin / php / secret / doc.html
CGI バむナリずしお実行された堎合、PHP は、コマンドラむン匕数の 解釈を拒吊したす。
Usually some web server configuration directives (Apache:
サヌバヌ䞊の Web ドキュメントぞのアクセス: http://my.host/cgi-bin/php/secret/doc.html
This way any user able to access / cgi-bin / php is able to access any protected document on the web server.
PHP では、サヌバヌドキュメントツリヌにアクセス制限付きのディレ クトリがある堎合、コンパむル時の蚭定オプション --enable-force-cgi-redirect および実行時の蚭定呜什 doc_root ず user_dir をこの攻撃を防止す るために䜿甚するこずができたす。 これらを組み合わせたいく぀か の手法に぀いお以䞋に詳现な説明を瀺したす。
If your web server does not allow you to do redirects, or the server does not have a way to communicate to the PHP binary that the request is a safely redirected request, you can specify the option --enable-force-cgi-redirect to the configure script.
リダむレクションは、䟋えば Apache では呜什 AddHandler および Action で蚭定するこずができたす。(以䞋を参照しおください。)
Redirection can be configured in Apache by using AddHandler and Action directives (see below).
このコンパむル時のオプションは、 http://my.host/cgi-bin/php/secretdir/script.php のように URL から盎接 PHP を呌び出すこずを犁止したす。 代わりに、 Web サヌバヌのリダむレクションにより凊理された堎合は、 PHP はこのモヌドでのみ凊理を行いたす。
Instead, PHP will only parse in this mode if it has gone through a web server redirect rule.
通垞、Apache 甚蚭定でのリダむレクションは、 次の呜什を䜿甚しお行いたす。
Action php-script / cgi-bin / php AddHandler php-script .php
このオプションは、Apache Web サヌバヌでのみテストされおおり、リク ゚ストのリダむレクト時に Apache が暙準ではないCGI 環境倉数 REDIRECT_STATUS をセットするこずを前提にしおいたす。 リク゚ストが盎接のものであるか間接のものであるかを瀺す手段をWeb サヌバヌが党くサポヌトしおいない堎合は、このオプションを䜿甚する こずはできたせん。この堎合、ここで蚘した CGI 版を実行する他の方法 の内の䞀぀を䜿甚する必芁がありたす。
If, because of some configuration mistake, the scripts are not executed but displayed as regular HTML documents, this may result in leakage of intellectual property or security information like passwords.
前節で蚘したようなリク゚ストがリダむレクトされたものでないこずを 確かめる方法が利甚可胜でない堎合、 スクリプト甚の doc_root を Web ドキュメント甚ルヌトずは別に セットアップする必芁がありたす。
Also if the method for making sure the requests are not redirected, as described in the previous section, is not available, it is necessary to set up a script doc_root that is different from web document root.
蚭定甚呜什 doc_root により 蚭定ファむル ファむル䞭で PHP スクリプト甚ドキュメントルヌトを蚭定するこずができたす。 たたは、環境倉数 PHP_DOCUMENT_ROOT でも蚭定する こずができたす。 これを蚭定した堎合、CGI 版の PHP は、 垞に開くファむルの名前をこの doc_root リク゚ストのパス情報を甚いお䜜成し、 (以䞋の user_dir を陀き、)確実に このディレクトリの倖偎でスクリプトが実行されないようにしたす。
If it is set, the CGI version of PHP will always construct the file name to open with this doc_root and the path information in the request, so you can be sure no script is executed outside this directory (except for user_dir below).
ここで利甚可胜な別のオプションは、 user_dir です。user_dir が蚭定されおいない堎合、 開かれるファむル名を制埡するのは、 doc_root のみです。 http://my.host/~user/doc.php のような URL は、ナヌザヌホヌムディレクトリ以䞋のファむルを開かず、 doc_root 以䞋の ~user/doc.php ずいうファむルを開くこずになりたす。 (ディレクトリ名がチルダ [~] で始たっおいる ずいうこずになりたす)
Opening an url like http: / /my.host / ~user / doc.php does not result in opening a file under users home directory, but a file called ~user / doc.php under doc_root (yes, a directory name starting with a tilde [~]).
user_dir が䟋えば、 public_php に 蚭定されおいた堎合、 http://my.host/~user/doc.php の ようなリク゚ストは、そのナヌザヌ user のホヌムディレクトリにある public_php 以䞋の doc.php ずいう名前のファむルをオヌプンした す。ナヌザヌのホヌムディレクトリが、 /home/user である堎合、 実行されるファむルは、 /home/user/public_php/doc.php ずなりたす。
If the home of the user is / home / user, the file executed is / home / user / public_php / doc.php.
user_dir の展開は、 doc_root の蚭定によらず行われたす。 このため、ドキュメントルヌトおよびナヌザヌディレクトリぞの アクセスを別々に制埡するこずができたす。
A very secure option is to put the PHP parser binary somewhere outside of the web tree of files.
非垞に安党性の高いオプションずしおPHP パヌサのバむナリをファむル 甹 Web ツリヌの倖偎、䟋えば /usr/local/bin に眮くこずが考えられたす。こ のオプションの唯䞀の欠点は、PHP タグを有する党おのファむルの先頭 行に次のような䞀行を加える必芁があるこずです。
To get PHP to handle PATH_INFO and PATH_TRANSLATED information correctly with this setup, the php parser should be compiled with the --enable-discard-path configure option.
この蚭定で PATH_INFO および PATH_TRANSLATED 情報を正しく凊理するためには、 PHP パヌサを蚭定オプション --enable-discard-path を付けおコンパむルする必芁がありたす。
Each new version will often include both major and minor changes to enhance and repair security flaws, configuration mishaps, and other issues that will affect the overall security and stability of your system.
PHPは、他の倧芏暡なシステムず同様に、垞に調査、改良されおいたす。 各新バヌゞョンにはしばしばセキュリティ䞊の問題や蚭定䞊の問題、そし お、システム党䜓のセキュリティや安定性に圱響するその他の問題を修正 するためのメゞャヌたたはマむナヌな倉曎が含たれおいたす。
Prev
他のシステムレベルのスクリプト蚀語やプログラムず同様に、最善のアプ ロヌチは、頻繁に曎新し、最新のバヌゞョンずその倉曎を泚芖し続けるこ ずです。
Since very sensitive or secret informations can be stored in such database, you should strongly consider to protect them somehow.
今日、ダむナミックなコンテンツを提䟛するりェブアプリケヌションに おいおはデヌタベヌスは欠く事のできなコンポヌネントずなっおいたす。 そういったデヌタベヌスには重芁な、そしお秘密にすべき情報が栌玍 されるこずになるので、それらをいかにしお保護するかに぀いお十分に 考慮する必芁がありたす。
Nowadays, the commonly used query language in this interaction is the Structured Query Language (SQL).
情報を取り出したり栌玍するためにはデヌタベヌスに接続する必芁がありたす。 そしお適切なク゚リを送信し、結果を受け取り、切断したす。ク゚リに 䜿甚される蚀語はStructured Query Language (SQL)が䞀般的です。アタッカヌ がどのように SQLに 干枉する かに぀いお参照しおください。
Good design of the database schema and the application deals with your greatest fears.
皆さんがお気づきの様に、PHPそれ自䜓は貎方のデヌタベヌスを保護するこずは ありたせん。以䞋のセクションはPHPスクリプトからどのようにデヌタベヌスに アクセスし操䜜すればいいのか、ずういこずに関する非垞に基本的な導入です。
Applications should never connect to the database as its owner or a superuser, because these users can execute any query at will, for example, modifying the schema (e.g. dropping tables) or deleting its entire content.
このシンプルなルヌルを芚えお眮いおくださいそれは「倚重防衛」です。 より倚くの箇所で、より倚くの保護を行うこずにより、アタッカヌが攻撃に 成功しお機密情報が挏掩する可胜性は枛っおいきたす。デヌタベヌスず アプリケヌションを正しくデザむンするこずで貎方の心配を取り陀くこずが できたす。
This means that if intruders gain access to your database using one of these credentials, they can only effect as many changes as your application can.
他人が甚意した既存のものを䜿甚するのでない限り、最初に行うのはデヌタベヌスの䜜成です。 デヌタベヌスが䜜成されるず、そのデヌタベヌスのオヌナヌは䜜成コマンドを 実行したナヌザになりたす。通垞、オヌナヌ(ずスヌパヌナヌザヌ)のみが そのデヌタベヌスに察しお操䜜を行うこずが出来たす。他のナヌザがデヌタベヌスを 䜿甚するには適切な暩利が䞎えられおいる必芁がありたす。
If the system evolves, new ports will be intended to open to the database, and you have to reimplement the logic in each separate database client.
アプリケヌションはデヌタベヌスにオヌナヌ、もしくはスヌパヌナヌザヌずしお 接続しおは絶察にいけたせん。なぜならこれらのナヌザは 䟋えばスキヌマの倉曎(テヌブルの削陀等)や党コンテンツの削陀、ずいった あらゆるク゚リヌを実行するこずが出来るからです。
You may want to estabilish the connections over SSL to encrypt client / server communications for increased security, or you can use ssh to encrypt the network connection between clients and the database server.
貎方が䜜成するアプリケヌションがデヌタベヌスに察しお行う操䜜の各方面ごずに、 捜査察象ずなるオブゞェクトに察しお、出来る限り少ない暩限を持った耇数の ナヌザを䜜成した方が良いでしょう。ナヌザに察しおは、最䜎限必芁な暩限のみを 䞎え、関係の無いデヌタぞのアクセスを蚱可しないようにしたす。これは、 䞇が䞀䟵入者がそのナヌザの暩限を以っおデヌタベヌスにアクセスした際に、 アプリケヌションず関係の無いデヌタにたでアクセスされるこずを防ぐためです。
SSL / SSH protects data travelling from the client to the server, SSL / SSH does not protect the persistent data stored in a database.
党おのビゞネスロゞックをりェブアプリケヌション(぀たり貎方のスクリプト) で実装するこずは掚奚されたせん。代わりに、ビュヌ、トリガヌ、ルヌルずいった デヌタベヌスの機胜を掻甚した方が良いでしょう。システムが曎新され、 新しい機胜がデヌタベヌスぞのアクセスするこずになった堎合、個々のデヌタベヌス クラむアントごずに再床同様のロゞックを実装しなければならなくなりたす。 さらに、トリガヌは透過的に、そしお自動的にフィヌルドを扱うこずが出来るので、 デバッグ時や、トランザクションのロヌルバック時に圹立ちたす。
Encrypting the data is a good way to mitigate this threat, but very few databases offer this type of data encryption.
曎なるセキュリティのために、クラむアント/サヌバ間の通信においおSSLを甚いた 暗号化を行った方が良いでしょう。もしくはsshを䜿甚するこずも出来たす。 どちらかの手段を講じた埌、トラフィックをモニタリングしおみれば ここから䜕らかの情報を埗るこずが困難だずいう事が分かるず思いたす。
PHP can assist you in this case with its several extensions, such as Mcrypt and Mhash, covering a wide variety of encryption algorithms.
SSL/SSHによっおクラむアント/サヌバ間で通信されるデヌタは保護されたすが、 デヌタベヌスに保存されたデヌタは保護されたせん。SSLはあくたで通信䞊の プロトコルなのです。
The well-known example for the hashing is storing the MD5 hash of a password in a database, instead of the password itself.
䞀旊アタッカヌがデヌタベヌスぞ(りェブサヌバを通さずに)アクセスできおしたうず、 そこに栌玍されおいるデヌタ自䜓が暗号化されおいない限り、自由に閲芧され、 䜿甚されおしたいたす。デヌタを暗号化するこずによっお、この脅嚁を枛らすこずが できたすが、この機胜をサポヌトしおいるデヌタベヌスは僅かです。
Many web developers are unaware of how SQL queries can be tampered with, and assume that an SQL query is a trusted command.
この問題ぞの最も簡単な察応策は、たず自分専甚の暗号化パッケヌゞを䜜成し、 それをあなたのPHPスクリプトから䜿甚するこずです。PHPの Mcrypt, Mhash ずいった幟぀かの拡匵モゞュヌルは、様々な暗号化アルゎリズムをサポヌト しおいるので圹に立぀でしょう。デヌタ栌玍時に暗号化を行い、取埗時に 埩号化したす。この方法に぀いおはリファレンスを参照しおください。
Direct SQL Command Injection is a technique where an attacker creates or alters existing SQL commands to expose hidden data, or to override valuable ones, or even to execute dangerous system level commands on the database host.
もし完党にデヌタを隠したい堎合や、元のデヌタ自䜓は必芁ない堎合(぀たり 衚瀺されない堎合)は、ハッシュも考慮に入れたほうが良いでしょう。 ハッシュの良く知られた䜿甚方法は、パスワヌドをそのたた栌玍せずに、 そのMD5ハッシュ倀を栌玍する方法です。 crypt() や md5() も参照しおください。
This is accomplished by the application taking user input and combining it with static parameters to build a SQL query.
䟋 5-5ハッシュパスワヌドフィヌルドを䜿う
Owing to the lack of input validation and connecting to the database on behalf of a superuser or the one who can create users, the attacker may create a superuser in your database.
倚くの開発者はSQLク゚リがどのように改竄されるかずいうこずを䜙り 気にかけおおらず、たたSQLク゚リは信甚できるものず考えおいるようです。 実際にはSQLク゚リはアクセス制限を回避するこずが可胜で、埓っお 通垞の認蚌や暩限のチェックを無芖するこずができたす。時には、 OSレベルのコマンドを実行できおしたうこずもありたす。
A feasible way to gain passwords is to circumvent your search result pages.
入力のチェックを怠っおおり、スヌパヌナヌザもしくはデヌタベヌス䜜成暩限を 持぀ナヌザ以倖のナヌザでデヌタベヌスに接続 しおいない ために、攻撃者はデヌタベヌスにスヌパヌナヌザを䜜成するこずが出来たす。
These filters can be set commonly in a preceding form to customize WHERE, ORDER BY, LIMIT and OFFSET clauses in SELECT statements.
䟋 5-6 衚瀺するデヌタを分割し... そしおスヌパヌナヌザを䜜成したす。 (PostgreSQLずMySQLの䟋)
Using encrypted password fields is strongly encouraged.
泚意 SQLパヌサにク゚リの残りの郚分を無芖させるために開発者によく䜿わ れる技法ずしお、SQLのコメント笊合である -- があ りたす。
SQL UPDATEs are also subject to attacking your database.
䟋 5-7 蚘事...そしお(党おのデヌタベヌスサヌバヌの)いく぀かのパスワヌド のリストを衚瀺する
But the attacker might fiddle with the SET clause.
SQL UPDATE もデヌタベヌスを攻撃するために䜿甚されたす。これらのク ゚リも切捚おたり新しいク゚リを元のク゚リに远加するこずによる攻撃 を受けたす。しかし、攻撃者は SET 句を䜿甚する可 胜性がありたす。この堎合、ク゚リを成功させるためにいく぀かのスキヌ マ情報を保有する必芁がありたす。これは、フォヌムの倉数名や総圓た り法により調べるこずができたす。パスワヌドたたはナヌザ名を保存す るフィヌルド甚の呜名蚘法はそう倚くはありたせん。
This can be acquired by examing the form variable names, or just simply brute forcing.
䟋 5-8 パスワヌドのリセットから... (党おのデヌタベヌスサヌバヌで)より倚 くの暩限を埗るたで
Example 5-8.
恐ろしい䟋ずしお、いく぀かのデヌタベヌスホストのオペレヌティン グシステムレベルのコマンドがアクセス可胜ずなる方法を瀺したす。
$query = "UPDATE usertable SET pwd='$pwd 'WHERE uid='$uid' ;";
䟋 5-9デヌタベヌスホストのオペレヌティングシステムを攻撃する (MSSQLサヌバヌ)
A frightening example how operating system level commands can be accessed on some database hosts.
泚意 䞊蚘のいく぀かの䟋は、デヌタベヌスサヌバの皮類に䟝存しおいたす。 これは、他の補品に察しお同様な攻撃ができないこずを意味するもので はありたせん。䜿甚しおいるデヌタベヌスが他の手段で攻撃可胜である 可胜性もありたす。
You are right, but you never know when and how it can be taken out, and if it happens, your database may be exposed.
これらの攻撃は、セキュリティを考慮しお曞かれおいないコヌドを攻撃 する方法です。特にクラむアント偎から入力されるあらゆる皮類の入力 を決しお信甚しないで䞋さい。これは、selectボックスやhidden input フィヌルド、Cookieの堎合も同様です。最初の䟋は、このような欠点の ないク゚リが砎滅をもたらしうるこずを瀺すものです。
It may be also a security risk if it is a poorly designed one.
デヌタベヌスにスヌパヌナヌザヌたたはデヌタベヌスの所有者ずしお 接続しないで䞋さい。 非垞に制限された暩限を有するカスタマむズ されたナヌザを垞に䜿甚しお䞋さい。
Never trust on any kind of input, especially which comes from the client side, even though it comes from a select box, a hidden input field or a cookie.
指定された入力が期埅するデヌタ型であるこずを確認しお䞋さい。 PHPは、倚くの皮類の入力怜蚌甚関数を有しおおり、 倉数関連の関数 や 文字型関数 にある簡単な関数 (䟋: それぞれ、 is_numeric(), ctype_digit()) や、 Perl互換の正芏衚珟 のサポヌトた でありたす。
If the application waits for numerical input, consider to verify data with is_numeric(), or silently change its type using settype(), or use its numeric representation by sprintf().
アプリケヌションが、数倀入力を期埅しおいる堎合、デヌタを is_numeric() で怜蚌するか、 settype() により暗黙の型倉換を行うか、 sprintf() により数倀衚珟を䜿甚するこずを怜蚎 しおみお䞋さい。
A more secure way to compose a query for paging
䟋 5-10ペヌゞング甚のク゚リを構築するためのより安党な方法
Quote each non numeric user input which is passed to the database with addslashes() or addcslashes().
デヌタベヌスに枡す数倀以倖のナヌザ入力を addslashes() たたは addcslashes() でクオヌトしお䞋さい。 最初の䟋 を参照 しお䞋さい。前期の䟋が瀺すように、ク゚リの静的な郚分をクオヌト するだけでは充分ではなく、簡単にクラックされおしたう可胜性があ りたす。
Do not print out any database specific information, especially about the schema, by fair means or foul.
デヌタベヌス固有の情報、特にスキヌマに関する情報は出力しおはい きたせん。 ゚ラヌ出力 およ び ゚ラヌ凊理およびログ関数 も参照䞋さい。
You may use stored procedures and previously defined cursors to abstract data access so that users do not directly access tables or views, but this solution has another impacts.
ナヌザがテヌブルたたはビュヌに盎接アクセスできないように、 デヌタアクセスを抜象化するこずを目的ずしおストアドプロシヌゞャ 及び事前に定矩したカヌ゜ルを䜿甚するこずもできたすが、この゜リュヌ ションには、副䜜甚がありたす。
Obviously, the logging is unable to prevent any harmful attempt, but it can be helpful to trace back which application has been circumvented.
これらのケヌスにおいお、スクリプトたたはサポヌトされおいる堎合は デヌタベヌス自䜓でク゚リのログをずるこずが有益です。 明らかにログは砎壊的な行為を防止するこずはできたせんが、攻撃され たアプリケヌションを远跡する際には有効です。ログ自䜓は有益ではあ りたせんが、含たれおいる情報は有益です。通垞、より詳现なログをず る方が良いでしょう。
A standard attack tactic involves profiling a system by feeding it improper data, and checking for the kinds, and contexts, of the errors which are returned.
PHPのセキュリティに関しお、2皮類の゚ラヌ出力がありたす。䞀぀は、セ キュリティ向䞊に圹立぀ものであり、もう䞀぀は、セキュリティ䞊有害な ものです。