svn: /phpdoc/ja/trunk/reference/pcre/ pattern.modifiers.xml

From: Date: Sat, 04 Jan 2020 03:24:08 +0000
Subject: svn: /phpdoc/ja/trunk/reference/pcre/ pattern.modifiers.xml
Groups: php.doc.ja 
Request: Send a blank email to doc-ja+get-5302@lists.php.net to get a copy of this message
mumumu Sat, 04 Jan 2020 03:24:08 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=348783 Log: Remove RCE example This example is (not incorrectly) flagged as Backdoor:PHP/Remoteshell.A by Windows defender (and possibly other AV engines), so we rewrite the respective part of the manual. Changed paths: U phpdoc/ja/trunk/reference/pcre/pattern.modifiers.xml Modified: phpdoc/ja/trunk/reference/pcre/pattern.modifiers.xml =================================================================== --- phpdoc/ja/trunk/reference/pcre/pattern.modifiers.xml 2020-01-04 03:04:32 UTC (rev 348782) +++ phpdoc/ja/trunk/reference/pcre/pattern.modifiers.xml 2020-01-04 03:24:08 UTC (rev 348783) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 346848 Maintainer: takagi Status: ready --> -<!-- Credits: hirokawa,haruki --> +<!-- EN-Revision: 348780 Maintainer: takagi Status: ready --> +<!-- Credits: hirokawa,haruki,mumumu --> <article xml:id="reference.pcre.pattern.modifiers" xmlns="http://docbook.org/ns/docbook"> <title>パターン修飾子</title> <titleabbrev>正規表現パターンに使用可能な修飾子</titleabbrev> @@ -108,7 +108,9 @@ <caution> <para> この修飾子を使うことは<emphasis>おすすめしません</emphasis>。 - セキュリティに関する脆弱性を作ってしまいがちだからです。 + リモートから実行可能な脆弱性を作ってしまいがちだからです。 + これを防ぐには、<function>preg_replace_callback</function> + 関数を代わりに使うべきです: </para> <informalexample> <programlisting role="php"> @@ -126,33 +128,14 @@ </programlisting> </informalexample> <para> - このサンプルを攻撃するのは簡単で、 + このサンプルが + <function>preg_replace</function> と <literal>e</literal> 修飾子を使って書かれている場合、 + 攻撃するのは簡単で、 <literal>&lt;h1&gt;{${eval($_GET[php_code])}}&lt;/h1&gt;</literal> のような文字列を渡すだけで攻略できます。 攻撃者は任意の PHP コードを実行でき、 サーバーに対するほぼ完全なアクセス権を与えることになってしまいます。 </para> - <para> - この種のリモートコード実行脆弱性を回避するには、 - <function>preg_replace_callback</function> 関数を使うようにしなければなりません。 - </para> - <informalexample> - <programlisting role="php"> -<![CDATA[ -<?php -$html = $_POST['html']; - -// 見出しを大文字にします -$html = preg_replace_callback( - '(<h([1-6])>(.*?)</h\1>)', - function ($m) { - return "<h$m[1]>" . strtoupper($m[2]) . "</h$m[1]>"; - }, - $html -); -]]> - </programlisting> - </informalexample> </caution> <note> <para> @@ -160,9 +143,9 @@ 他の PCRE 関数では無視されます。 </para> </note> - </listitem> - </varlistentry> - <varlistentry> + </listitem> + </varlistentry> + <varlistentry> <term><emphasis>A</emphasis> (<literal>PCRE_ANCHORED</literal>)</term> <listitem> <simpara>

« previous php.doc.ja (#5302) next »