cvs: phpdoc /kr preface.xml /kr/chapters security.xml
| From: | WonHee Hwang | Date: | Wed, 14 Feb 2001 03:12:50 +0000 |
| Subject: | cvs: phpdoc /kr preface.xml /kr/chapters security.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969334285@lists.php.net to get a copy of this message | ||
regina Tue Feb 13 19:12:50 2001 EDT
Modified files:
/phpdoc/kr preface.xml
/phpdoc/kr/chapters security.xml
Log:
PR: v1.6 in English version
Submitted by:
Reviewed by:
Obtained from:
Index: phpdoc/kr/preface.xml diff -u phpdoc/kr/preface.xml:1.2 phpdoc/kr/preface.xml:1.3 --- phpdoc/kr/preface.xml:1.2 Sun Jan 7 19:07:25 2001 +++ phpdoc/kr/preface.xml Tue Feb 13 19:12:49 2001 @@ -3,26 +3,36 @@ <abstract> <simpara> <acronym>PHP</acronym>ë HTMLì ë´ì¥ëì´ ëìíë ì¤í¬ë¦½í¸ ì¸ì´ì´ë¤.(HTML-embedded scripting language) -PHPë Cì Java, Perlë±ì¼ë¡ë¶í° ë§ì ë¬¸ì¥ íìì ë¹ë ¤ì°ê³ ìê³ , ëªê°ì§ë ê³ ì í ê²ë ìë¤. -ì´ ì¸ì´ì 목ì ì ì¹ê°ë°ìë¤ì´ ëì ì¸ ì¹ë¬¸ì를 ë¹ ë¥´ê³ ì½ê² ìì±í ì ìëë¡ íë ê²ì´ë¤. + PHPë Cì Java, Perlë±ì¼ë¡ë¶í° ë§ì ë¬¸ì¥ íìì ë¹ë ¤ì°ê³ ìê³ , ëªê°ì§ë ê³ ì í ê²ë ìë¤. + ì´ ì¸ì´ì 목ì ì ì¹ê°ë°ìë¤ì´ ëì ì¸ ì¹ë¬¸ì를 ë¹ ë¥´ê³ ì½ê² ìì±í ì ìëë¡ íë ê²ì´ë¤. </simpara> </abstract> <sect1 id="about"> <title>ì´ ë§¤ë´ì¼ì ëíì¬</title> <para> - ì´ ë§¤ë´ì¼ì <ulink url="&url.docbook.xml;">DocBook XML DTD</ulink>를 ì¬ì©í <acronym>XML</acronym>ë¡ ëì´ìê³ , - 문ìì í¬ë§¤í ì ìí´ì <ulink url="&url.dsssl;"> - <acronym>DSSSL</acronym> - </ulink> - (Document Style and Semantics Specification Language) ì ì¬ì©íë¤. - <acronym>HTML</acronym>, <acronym>TeX</acronym>, <acronym>RTF</acronym> 문ìë¡ì í¬ë§¤í ì - <ulink url="&url.jclark;">James Clark</ulink>ì´ ì ìí <ulink url="&url.jade;">Jade</ulink>ì, - <ulink url="&url.nwalsh;">Norman Walsh</ulink>ê° ì ìí <ulink url="&url.dbstyle;">The Modular DocBook Stylesheets</ulink>를 ì¬ì©íìë¤. - PHP'ì 문ì ííë &link.stig; ì´ ê´ë¦¬íë¤. - </para> + ì´ ë§¤ë´ì¼ì <ulink url="&url.docbook.xml;">DocBook XML DTD</ulink>를 ì¬ì©í <acronym>XML</acronym>ë¡ ëì´ìê³ , + 문ìì í¬ë§¤í ì ìí´ì <ulink url="&url.dsssl;"><acronym>DSSSL</acronym></ulink> + (Document Style and Semantics Specification Language) ì ì¬ì©íë¤. + <acronym>HTML</acronym>, <acronym>TeX</acronym>, <acronym>RTF</acronym> 문ìë¡ì í¬ë§¤í ì + <ulink url="&url.jclark;">James Clark</ulink>ì´ ì ìí <ulink url="&url.jade;">Jade</ulink>ì, + <ulink url="&url.nwalsh;">Norman Walsh</ulink>ê° ì ìí + <ulink url="&url.dbstyle;">The Modular DocBook Stylesheets</ulink>를 ì¬ì©íìë¤. + PHPì 문ì ííë &link.stig; ì´ ê´ë¦¬íë¤. + </para> <para> - ë§¤ì¼ ìì±ëë 매ë´ì¼ì HTML ì¤ë ì·(ë²ì본 í¬í¨)ì <ulink url="&url.php.snaps.manual;">&url.php.snaps.manual;</ulink>ì ìë¤. - </para> + ë¤ìí ì¸ì´ì <acronym>PDF</acronym>, ì¼ë° í ì¤í¸, ì¼ë° <acronym>HTML</acronym>, + WinHelp, <acronym>RTF</acronym> ë±ì ë¤ìí í¬ë§·ì 매ë´ì¼ì + <ulink url="&url.php.docs;">&url.php.docs;</ulink>ìì ì°¾ì ì ìë¤. + </para> + <para> + ë§¤ì¼ ìì±ëë 매ë´ì¼ì HTML ì¤ë ì·(ë²ì본 í¬í¨)ì + <ulink url="&url.php.snaps.manual;">&url.php.snaps.manual;</ulink>ì ìë¤. + </para> + <para> + ì´ ë¬¸ìì <acronym>XML</acronym> ìì¤ì½ë를 ë¤ì´ë°ëë° íìí ìì¸í ì ë³´ë + <ulink url="&url.php.cvs;">&url.php.cvs;</ulink>ì ìë¤. + 문ìë <literal>phpdoc</literal> 모ëìì ì ì¥ëì´ ìë¤. + </para> </sect1> </preface> <!-- Keep this comment at the end of the file Index: phpdoc/kr/chapters/security.xml diff -u phpdoc/kr/chapters/security.xml:1.1 phpdoc/kr/chapters/security.xml:1.2 --- phpdoc/kr/chapters/security.xml:1.1 Mon Jan 8 19:00:50 2001 +++ phpdoc/kr/chapters/security.xml Tue Feb 13 19:12:49 2001 @@ -2,7 +2,7 @@ <title>Security</title> <simpara> PHPë ë§¤ì° ê°ë ¥í ì¸ì´ì´ë¤. - ì´ ì¸í°í리í°ë ì¹ìë²ì 모ëë¡ ëì´ ìê±´ <acronym>CGI</acronym> binaryë¡ ëì´ ìê±´, ìì¤í ë´ì íì¼ì ì¬ì©í ì ìê³ , + ì´ ì¸í°í리í°ë ì¹ìë²ì 모ëë¡ ëì´ ìê±´ <acronym>CGI</acronym> ë°ì´ëë¦¬ë¡ ëì´ ìê±´, ìì¤í ë´ì íì¼ì ì¬ì©í ì ìê³ , ì¬íì ëª ë ¹ì´ë íë¡ê·¸ë¨ì ì¤íí ì ììë¿ ìëë¼, ë¤í¸ìì íµí´ ë¤ë¥¸ ìë²ë¡ ì°ê²°ì í ìë ìë¤. ì´ë° 기ë¥ë¤ì ì ì를 ê°ì§ ì¬ì©ìë ì´ë³´ìê° ì´ë¤ íë¡ê·¸ë¨ì´ë ì¤íìì¼ ì¹ìë²ë¥¼ ë³´ìì ë¶ìí ìíë¡ ë§ë¤ ì ìë¤. PHPë ë¶ëª í Perlì´ë Cë³´ë¤ ì¢ë ìì í CGI íë¡ê·¸ë¨ì ë§ë¤ ì ìëë¡ ëì´ ìë¤. @@ -14,25 +14,21 @@ ì´ ìµì ë¤ì ì¡°í©ê³¼ ìë²ì ì¤ì ì ë°ë¼ ë³´ììì íì ì ë ¸ì¶ìí¬ ìë ìë¤. </simpara> <simpara> - The configuration flexibility of PHP is equally rivalled by the - code flexibility. PHP can be used to build complete server - applications, with all the power of a shell user, or it can be used - for simple server-side includes with little risk in a tightly - controlled environment. How you build that environment, and how - secure it is, is largely up to the PHP developer. + PHPìì ì¤ì ì ì ì°ì±ì ì½ëì ì ì°ì±ê³¼ ë¹ê²¬ë ë§í¼ íë¥íë¤. + PHPë ì ì¬ì©ìì ëì¼í ê¶íì¼ë¡ ìì í ìë² ì´í리ì¼ì´ì ì ë§ëëë° ì¬ì©ë ìë ìê³ , + ìíì´ ê±°ì ìë ë§¤ì° ì íë íê²½ìì ê°ë¨í server-side includeìë ì¬ì©ë ì ìë¤. + íê²½ì ì´ë»ê² ë§ëëê°, ë³´ìì ì´ë»ê² ì¤ì íëê°ë ì ì ì¼ë¡ PHP ê°ë°ììê² ë¬ë ¤ìë¤. </simpara> <simpara> - This chapter starts by explaining the different configuration - option combinations and the situations they can be safely used. It - then describes different considerations in coding for different - levels of security, and ends with some general security advice. + ì´ ì¥ì PHP를 ìì íê² ì¬ì©í ì ìë ì¬ë¬ ë¤ë¥¸ ì¤ì ìµì ì ì¡°í©ê³¼ ìí©ì ì¤ëª íë ê²ì¼ë¡ ììíë¤. + ê·¸ë¦¬ê³ , ê°ê° ìì´í ë³´ì ë 벨ììì ì½ë©ì ìì´ì ì¬ë¬ê°ì§ ê³ ë ¤ì¬íì ì¤ëª íë¤. </simpara> <sect1 id="security.cgi"> <title>Installed as CGI binary</title> <sect2 id="security.cgi.attacks"> <title>ê°ë¥í 공격 (Possible attacks)</title> <simpara> - <acronym>CGI</acronym> binary ííì PHPë ì´ë¤ ì´ì ë¡ (ìíì¹ ê°ì) ìë² ìíí¸ì¨ì´ì 모ëë¡ + <acronym>CGI</acronym> binary ííì PHPë ì´ë¤ ì´ì ë¡ (ìíì¹ ê°ì) ìë² ìíí¸ì¨ì´ì 모ëë¡ ì¬ì©ë기를 ìíì§ ìë ê²½ì°ì ì¬ì©í ì ìê³ , PHP를 ë¤ë¥¸ ì¢ ë¥ì CGI wrapperì í¨ê» ìì í chrootì setuid íê²½ì ë§ë¤ì´ ë´ë ê³³ì ëì ì¬ì©í ì ìë¤. ì´ ì¤ì ì ë³´íµ ì¤íí PHP binary를 ì¹ìë²ì cgi-binëë í 리ì ì¤ì¹í´ì¼ íë¤. @@ -60,11 +56,11 @@ <simpara> ì´ urlì PHP binary ì´íì path ì ë³´(<filename role="uri">/secret/doc.html</filename>)ë ì¼ë°ì ì¼ë¡ <acronym>CGI</acronym> íë¡ê·¸ë¨ì ìí´ ì½ê³ í´ìë íì¼ ì´ë¦ì¼ë¡ ì¬ì©ëë¤. - ë³´íµ ì¹ìë²ë ì¤ì ì§ìì(Apacheì ê²½ì° Action)를 ì¬ì©íì¬ <filename role="url">http://my.host/secret/script.php3</filename>ê°ì + ë³´íµ ì¹ìë²ë ì¤ì ì§ìì(Apacheì ê²½ì° Action)를 ì¬ì©íì¬ <filename role="url">http://my.host/secret/script.php</filename>ê°ì 문ì ìì²ì PHP ì¸í°í리í°ë¡ ë°ë¡ 리ëë í¸ íëë¡ í ì ìë¤. ì´ë ê² ì¤ì íë©´, ì¹ìë²ë ì°ì <filename role="uri">/secret</filename> ëë í 리ì ì ê·¼ ê¶íì ê²ì¬í íì - <filename role="url">http://my.host/cgi-bin/php/secret/script.php3</filename>ë¡ ë¦¬ëë í¸ë¥¼ íë¤. - ë¶ííë, ì´ ìì²ì´ ìëì formìì 주ì´ì§ ê²ì´ë¼ë©´, ì¹ìë²ë <filename role="uri">/secret/script.php3</filename> + <filename role="url">http://my.host/cgi-bin/php/secret/script.php</filename>ë¡ ë¦¬ëë í¸ë¥¼ íë¤. + ë¶ííë, ì´ ìì²ì´ ìëì formìì 주ì´ì§ ê²ì´ë¼ë©´, ì¹ìë²ë <filename role="uri">/secret/script.php</filename> íì¼ì ëí ì ê·¼ ê¶í ê²ì¬ë¥¼ íì§ ìê³ , <filename role="uri">/cgi-bin/php</filename> íì¼ì ëí ê²ì¬ë§ì ííë¤. ì´ ë°©ë²ì ì¬ì©íë©´ <filename role="uri">/cgi-bin/php</filename>ì ì ê·¼ ê°ë¥í ì¬ì©ìë ì¹ìë²ìì 모ë ë³´í¸ë 문ìë¤ë ì ê·¼í ì ìë¤. </simpara> @@ -85,8 +81,8 @@ ë§ì½ ì¬ë¬ë¶ì ì¹ìë²ê° 리ëë í¸ë¥¼ íì©íì§ ìê±°ë, ìë²ê° í´ë¹ ìêµ¬ê° ìì íê² ë¦¬ëë í¸ë ì구ì¸ì§ ëí ì 보를 PHP binaryì ì ë¬í ì ìë ë°©ë²ì´ ìì ê²½ì°, config ì¤í¬ë¦½í¸ìì <link linkend="install.configure.enable-force-cgi-redirect">--enable-force-cgi-redirect</link> ìµì ì 주ë ê²ì´ ì¢ë¤. - ê·¸ë¬ë ì¬ì í PHP ì¤í¬ë¦½í¸ê°, <filename role="php">http://my.host/cgi-bin/php/dir/script.php3</filename>ê°ì ì§ì ì ê·¼ ë°©ë²ì´ë - <filename role="php">http://my.host/dir/script.php3</filename>ê°ì 리ëë ì ì ë°©ë² ì´ì¸ì, + ê·¸ë¬ë ì¬ì í PHP ì¤í¬ë¦½í¸ê°, <filename role="php">http://my.host/cgi-bin/php/dir/script.php</filename>ê°ì ì§ì ì ê·¼ ë°©ë²ì´ë + <filename role="php">http://my.host/dir/script.php</filename>ê°ì 리ëë ì ì ë°©ë² ì´ì¸ì, ë¤ë¥¸ ë¯¿ì§ ëª»í ë°©ë²ì ìí´ ë¶ë ¤ ì§ ë를 ëë¹íì¬ ëì± ì ê°êµ¬í´ ëì´ì¼ í©ëë¤ </simpara> <simpara> @@ -96,7 +92,7 @@ <sect2 id="security.cgi.force-redirect"> <title>Case 2: --enable-force-cgi-redirect ìµì ì¬ì©</title> <simpara> - ì´ ìµì ì ì£¼ê³ PHP를 ì»´íì¼ íë©´, ì¬ì©ìê° <filename role="php">http://my.host/cgi-bin/php/secretdir/script.php3</filename>ì + ì´ ìµì ì ì£¼ê³ PHP를 ì»´íì¼ íë©´, ì¬ì©ìê° <filename role="php">http://my.host/cgi-bin/php/secretdir/script.php</filename>ì ê°ì´ PHP를 ì§ì í¸ì¶íë ê²ì ë§ìì¤ë¤. ëì , ì´ ëª¨ëìì PHPë ì¬ì©ìì ì구(request)ê° ì¹ìë²ì 리ëë í¸ ê·ì¹ì íµê³¼í ê²½ì°ìë§ ëì í ê²ì´ë¤. </simpara> @@ -104,8 +100,8 @@ ì¼ë°ì ì¼ë¡ ìíì¹ìì 리ëë í¸ ì¤ì ì ë¤ìê³¼ ê°ì ì§ìì를 ì¬ì©íì¬ íë¤. : </simpara> <programlisting role="apache-conf"> -Action php3-script /cgi-bin/php -AddHandler php3-script .php3 +Action php-script /cgi-bin/php +AddHandler php-script .php </programlisting> <simpara> ì´ ìµì ì ìíì¹ ì¹ìë²ììë§ ê²ì¦ëìë¤. @@ -128,7 +124,7 @@ ì¹ìë²ì document rootìë ë³ëì script doc_root를 ì¤ì í´ ì£¼ë ê²ì´ ë°ëì íìíë¤. </simpara> <simpara> - <link linkend="configuration.file">configuration file (php.ini)</link>ì <link linkend="ini.doc-root">doc_root</link> ì§ìì를 ì¤ì íê±°ë, <envar> PHP_DOCUMENT_ROOT</envar>ë¼ë íê²½ë³ì를 ì¤ì íì¬, PHP script document root를 ì¤ì í ì ìë¤. + <link linkend="configuration.file">configuration file (php.ini)</link>ì <link linkend="ini.doc-root">doc_root</link> ì§ìì를 ì¤ì íê±°ë, <envar> PHP_DOCUMENT_ROOT</envar>ë¼ë íê²½ë³ì를 ì¤ì íì¬, PHP script document root를 ì¤ì í ì ìë¤. ë§ì½ ì´ê²ì´ ì¤ì ëì´ ìë¤ë©´, CGI ë²ì ì PHPë ì ê·¼íë ¤ë íì¼ì ì´ë¦ì ì´ <parameter>doc_root</parameter>ì requestì ìë ê²½ë¡ ì 보를 ì´ì©íì¬ ë§ë¤ì´ë¸ë¤. ë°ë¼ì ì¬ë¬ë¶ì ì´ ëë í 리 ë°ììë ì´ë í ì¤í¬ë¦½í¸ë ì¤íë ì ìëë¡ ë§ë¤ê² ëë¤. (ìëì ìë user_dir ë§ì ìì¸ì´ë¤) @@ -136,19 +132,19 @@ <simpara> ì¬ê¸°ì ì¬ì©í ì ìë ëë¤ë¥¸ ìµì ì <link linkend="ini.user-dir">user_dir</link>ì´ë¤. user_dirì´ ì¤ì ëì´ ìì§ ìì¼ë©´ ì ê·¼ ê°ë¥í íì¼ì <parameter>doc_root</parameter> ë°ì ìë ê² ë¿ì´ë¤. - <filename role="url">http://my.host/~user/doc.php3</filename>ê°ì urlë¡ë user home directoryì ìë íì¼ì ì´ ì ìë¤. - ë¨ì§ doc_rootìëì <filename role="uri">~user/doc.php3</filename> íì¼ì ë¶ë¥¼ ë¿ì´ë¤. + <filename role="url">http://my.host/~user/doc.php</filename>ê°ì urlë¡ë user home directoryì ìë íì¼ì ì´ ì ìë¤. + ë¨ì§ doc_rootìëì <filename role="uri">~user/doc.php</filename> íì¼ì ë¶ë¥¼ ë¿ì´ë¤. (ë¬¼ë¡ í¸ë°[<literal>~</literal>]ë¡ ììíë "~user"ë¼ë ëë í 리ì´ë¤.) </simpara> <simpara> ì를 ë¤ì´, ë§ì½ user_dirì´ <filename role="dir">public_php</filename>ë¡ ì¤ì ëì´ ìë¤ë©´, - <filename role="url">http://my.host/~user/doc.php3</filename>ì ê°ì ì구ë userì home ëë í 리 ë°ì - <filename role="dir">public_php</filename>ë¼ë ëë í 리 ë°ì ìë doc.php3ë¼ë íì¼ì í¸ì¶ í ê²ì´ë¤. + <filename role="url">http://my.host/~user/doc.php</filename>ì ê°ì ì구ë userì home ëë í 리 ë°ì + <filename role="dir">public_php</filename>ë¼ë ëë í 리 ë°ì ìë doc.phpë¼ë íì¼ì í¸ì¶ í ê²ì´ë¤. ë§ì½ ì¬ì©ìì homeì´ <filename role="dir">/home/user</filename>ë¼ë©´, - ì¤íëë íì¼ì <filename>/home/user/public_php/doc.php3</filename>ì´ ëë¤. + ì¤íëë íì¼ì <filename>/home/user/public_php/doc.php</filename>ê° ëë¤. </simpara> <simpara> - <parameter>user_dir</parameter> íì¥ì <parameter>doc_root</parameter> ì¤ì ê³¼ ê´ë ¨ìì¼ë¯ë¡, + <parameter>user_dir</parameter> íì¥ì <parameter>doc_root</parameter> ì¤ì ê³¼ ê´ë ¨ìì¼ë¯ë¡, ì¬ë¬ë¶ì document rootì user directory ì ê·¼ íµì 를 ë°ë¡ë°ë¡ í ì ìë¤. </simpara> </sect2> @@ -159,15 +155,15 @@ ì를 ë¤ì´ <filename role="dir">/usr/local/bin</filename> ê°ì ê³³ì ëë¤. ì´ ìµì ì ë¨ì ì, 모ë PHP íì í¬í¨íê³ ìë íì¼ì 첫ë²ì§¸ ë¼ì¸ì ë¤ìê³¼ ê°ì´ ì ì´ì£¼ë ê² ë¿ì´ë¤. : <informalexample> - <programlisting> + <programlisting> #!/usr/local/bin/php </programlisting> - </informalexample> + </informalexample> ëí íì¼ì ì¤í ê°ë¥ì¼ë¡ ë§ë¤ì´ 주ì´ì¼ íë¤. ì¦, ìì ì ì¤íì ìí´ì <literal>#!</literal> shell-escape ë©ì¹´ëì¦ì ì¬ì©íë Perlì´ë sh í¹ì ë¤ë¥¸ ì¤í¬ë¦½í¸ ì¸ì´ì ê°ì ë°©ìì¼ë¡ ë¤ë£¨ë ê²ì´ë¤. </para> - <para> + <para> ì´ ì¤ì ìì PHPê° <envar>PATH_INFO</envar>ì <envar>PATH_TRANSLATED</envar>ì 보를 ì íí ë¤ë£¨ë ¤ë©´, php parserê° <link linkend="install.configure.enable-discard-path">--enable-discard-path</link> ì¤ì ìµì ì¼ë¡ ì»´íì¼ ëì´ì¼ íë¤. </para> @@ -176,6 +172,16 @@ <sect1 id="security.apache"> <title>Installed as an Apache module</title> <simpara> + PHPê° ìíì¹ ëª¨ëë¡ ì¬ì©ëë©´ ìíì¹ ì¬ì©ì ê¶íì ê·¸ëë¡ ì´ì´ë°ëë¤. (ë³´íµ 'nobody' user) + ì´ê²ì ë³´ìê³¼ ì¸ì¦ì ëí´ ê°ê° ìí¥ì 미ì¹ë¤. ì를ë¤ì´ PHPë¡ ë°ì´íë² ì´ì¤ì ì ê·¼íê³ , + ì´ ë°ì´íë² ì´ì¤ì ìì²´ì ì¸ ë´ì¥ ì ê·¼ íµì 를 ì¬ì©íì§ ìëë¤ë©´, "nobody" ì¬ì©ì를 + ë°ì´íë² ì´ì¤ì ì ê·¼ ê°ë¥íëë¡ ì¤ì í´ ëì´ì¼ íë¤. + ì´ê²ì usernameê³¼ password를 몰ë¼ë ì ìì ì¸ ì¤í¬ë¦½í¸ë¥¼ ì¬ì©íì¬ ë°ì´íë² ì´ì¤ì ì ê·¼íê³ + ë°ì´í를 ìì í ì ìë¤ë ê²ì ì미íë¤. ëí í¬ëì»¤ê° ê´ë¦¬ìì© ì¹íì´ì§ë¥¼ ë¤ë½ê±°ë¦¬ê³ , + ë°ì´íë² ì´ì¤ë¥¼ ìì í´ ë²ë¦¬ë ê²ë ê°ë¥íë¤. ì¬ë¬ë¶ì ìíì¹ì ì¸ì¦ 기ë¥ì ì¬ì©íì¬ + ì´ë° 공격ì ëííë ë°©ì´ë¥¼ í ì ìë¤. + + ì¬ì© When PHP is used as an Apache module it inherits Apache's user permissions (typically those of the "nobody" user). This has several impacts on security and authorization. For example, if you are using @@ -244,7 +250,7 @@ $file_to_delete = "$userfile"; unlink ($homedir/$userfile); echo "$file_to_delete has been deleted!"; -?> +?> </programlisting> </example> Since the username is postable from a user form, they can submit @@ -263,7 +269,7 @@ $file_to_delete = "passwd"; unlink ("/home/../etc/passwd"); echo "/home/../etc/passwd has been deleted!"; -?> +?> </programlisting> </example> There are two important measures you should take to prevent these @@ -300,7 +306,7 @@ fclose($fp); echo "$file_to_delete has been deleted!"; -?> +?> </programlisting> </example> Alternately, you may prefer to write a more customized check: @@ -308,14 +314,14 @@ <title>More secure file name checking</title> <programlisting role="php"> <?php -$username = $HTTP_REMOTE_USER; +$username = getenv("REMOTE_USER"); $homedir = "/home/$username"; if (!ereg('^[^./][^/]*$', $userfile)) die('bad filename'); //die, do not process //etc... -?> +?> </programlisting> </example> Depending on your operating system, there are a wide variety of files @@ -339,14 +345,19 @@ developer who is trying to debug a script, indicating such things as the function or file that failed, the PHP file it failed in, and the line number which the failure occured in. This is all - information that can be exploited. + information that can be exploited. It is not uncommon for a php + developer to use <function>show_source</function>, + <function>highlight_string</function>, or + <function>highlight_file</function> as a debugging measure, but in + a live site, this can expose hidden variables, unchecked syntax, + and other dangerous information. </simpara> <simpara> - For example, the very style of error indicates a system is running - PHP. If the attacker was looking at an .html page, and wanted to - probe for the back-end (to look for known weaknesses in the system), - by feeding it the wrong data they may be able to determine that a - system was built with PHP. + For example, the very style of a generic error indicates a system + is running PHP. If the attacker was looking at an .html page, and + wanted to probe for the back-end (to look for known weaknesses in + the system), by feeding it the wrong data they may be able to + determine that a system was built with PHP. </simpara> <simpara> A function error can indicate whether a system may be running a @@ -361,7 +372,9 @@ <simpara> A filesystem or general PHP error can indicate what permissions the webserver has, as well as the structure and organization of - files on the web server. + files on the web server. Developer written error code can aggravate + this problem, leading to easy exploitation of formerly "hidden" + information. </simpara> <simpara> There are three major solutions to this issue. The first is to @@ -396,7 +409,7 @@ system ($evil_var); exec ($evil_var); -?> +?> </programlisting> </example> You should always carefully examine your code to make sure that any @@ -491,6 +504,21 @@ connected to. Many cracking programs do not discern by size, they simply trawl massive IP blocks looking for victims. Try not to become one. + </simpara> + </sect1> + <sect1 id="security.current"> + <title>Keeping Current</title> + <simpara> + PHP, like any other large system, is under constant scrutiny and + improvement. 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. + </simpara> + <simpara> + Like other system-level scripting languages and programs, the best + approach is to update often, and maintain awareness of the latest + versions and their changes. </simpara> </sect1> </chapter>
Index: phpdoc/kr/preface.xml diff -u phpdoc/kr/preface.xml:1.2 phpdoc/kr/preface.xml:1.3 --- phpdoc/kr/preface.xml:1.2 Sun Jan 7 19:07:25 2001 +++ phpdoc/kr/preface.xml Tue Feb 13 19:12:49 2001 @@ -3,26 +3,36 @@ <abstract> <simpara> <acronym>PHP</acronym>ë HTMLì ë´ì¥ëì´ ëìíë ì¤í¬ë¦½í¸ ì¸ì´ì´ë¤.(HTML-embedded scripting language) -PHPë Cì Java, Perlë±ì¼ë¡ë¶í° ë§ì ë¬¸ì¥ íìì ë¹ë ¤ì°ê³ ìê³ , ëªê°ì§ë ê³ ì í ê²ë ìë¤. -ì´ ì¸ì´ì 목ì ì ì¹ê°ë°ìë¤ì´ ëì ì¸ ì¹ë¬¸ì를 ë¹ ë¥´ê³ ì½ê² ìì±í ì ìëë¡ íë ê²ì´ë¤. + PHPë Cì Java, Perlë±ì¼ë¡ë¶í° ë§ì ë¬¸ì¥ íìì ë¹ë ¤ì°ê³ ìê³ , ëªê°ì§ë ê³ ì í ê²ë ìë¤. + ì´ ì¸ì´ì 목ì ì ì¹ê°ë°ìë¤ì´ ëì ì¸ ì¹ë¬¸ì를 ë¹ ë¥´ê³ ì½ê² ìì±í ì ìëë¡ íë ê²ì´ë¤. </simpara> </abstract> <sect1 id="about"> <title>ì´ ë§¤ë´ì¼ì ëíì¬</title> <para> - ì´ ë§¤ë´ì¼ì <ulink url="&url.docbook.xml;">DocBook XML DTD</ulink>를 ì¬ì©í <acronym>XML</acronym>ë¡ ëì´ìê³ , - 문ìì í¬ë§¤í ì ìí´ì <ulink url="&url.dsssl;"> - <acronym>DSSSL</acronym> - </ulink> - (Document Style and Semantics Specification Language) ì ì¬ì©íë¤. - <acronym>HTML</acronym>, <acronym>TeX</acronym>, <acronym>RTF</acronym> 문ìë¡ì í¬ë§¤í ì - <ulink url="&url.jclark;">James Clark</ulink>ì´ ì ìí <ulink url="&url.jade;">Jade</ulink>ì, - <ulink url="&url.nwalsh;">Norman Walsh</ulink>ê° ì ìí <ulink url="&url.dbstyle;">The Modular DocBook Stylesheets</ulink>를 ì¬ì©íìë¤. - PHP'ì 문ì ííë &link.stig; ì´ ê´ë¦¬íë¤. - </para> + ì´ ë§¤ë´ì¼ì <ulink url="&url.docbook.xml;">DocBook XML DTD</ulink>를 ì¬ì©í <acronym>XML</acronym>ë¡ ëì´ìê³ , + 문ìì í¬ë§¤í ì ìí´ì <ulink url="&url.dsssl;"><acronym>DSSSL</acronym></ulink> + (Document Style and Semantics Specification Language) ì ì¬ì©íë¤. + <acronym>HTML</acronym>, <acronym>TeX</acronym>, <acronym>RTF</acronym> 문ìë¡ì í¬ë§¤í ì + <ulink url="&url.jclark;">James Clark</ulink>ì´ ì ìí <ulink url="&url.jade;">Jade</ulink>ì, + <ulink url="&url.nwalsh;">Norman Walsh</ulink>ê° ì ìí + <ulink url="&url.dbstyle;">The Modular DocBook Stylesheets</ulink>를 ì¬ì©íìë¤. + PHPì 문ì ííë &link.stig; ì´ ê´ë¦¬íë¤. + </para> <para> - ë§¤ì¼ ìì±ëë 매ë´ì¼ì HTML ì¤ë ì·(ë²ì본 í¬í¨)ì <ulink url="&url.php.snaps.manual;">&url.php.snaps.manual;</ulink>ì ìë¤. - </para> + ë¤ìí ì¸ì´ì <acronym>PDF</acronym>, ì¼ë° í ì¤í¸, ì¼ë° <acronym>HTML</acronym>, + WinHelp, <acronym>RTF</acronym> ë±ì ë¤ìí í¬ë§·ì 매ë´ì¼ì + <ulink url="&url.php.docs;">&url.php.docs;</ulink>ìì ì°¾ì ì ìë¤. + </para> + <para> + ë§¤ì¼ ìì±ëë 매ë´ì¼ì HTML ì¤ë ì·(ë²ì본 í¬í¨)ì + <ulink url="&url.php.snaps.manual;">&url.php.snaps.manual;</ulink>ì ìë¤. + </para> + <para> + ì´ ë¬¸ìì <acronym>XML</acronym> ìì¤ì½ë를 ë¤ì´ë°ëë° íìí ìì¸í ì ë³´ë + <ulink url="&url.php.cvs;">&url.php.cvs;</ulink>ì ìë¤. + 문ìë <literal>phpdoc</literal> 모ëìì ì ì¥ëì´ ìë¤. + </para> </sect1> </preface> <!-- Keep this comment at the end of the file Index: phpdoc/kr/chapters/security.xml diff -u phpdoc/kr/chapters/security.xml:1.1 phpdoc/kr/chapters/security.xml:1.2 --- phpdoc/kr/chapters/security.xml:1.1 Mon Jan 8 19:00:50 2001 +++ phpdoc/kr/chapters/security.xml Tue Feb 13 19:12:49 2001 @@ -2,7 +2,7 @@ <title>Security</title> <simpara> PHPë ë§¤ì° ê°ë ¥í ì¸ì´ì´ë¤. - ì´ ì¸í°í리í°ë ì¹ìë²ì 모ëë¡ ëì´ ìê±´ <acronym>CGI</acronym> binaryë¡ ëì´ ìê±´, ìì¤í ë´ì íì¼ì ì¬ì©í ì ìê³ , + ì´ ì¸í°í리í°ë ì¹ìë²ì 모ëë¡ ëì´ ìê±´ <acronym>CGI</acronym> ë°ì´ëë¦¬ë¡ ëì´ ìê±´, ìì¤í ë´ì íì¼ì ì¬ì©í ì ìê³ , ì¬íì ëª ë ¹ì´ë íë¡ê·¸ë¨ì ì¤íí ì ììë¿ ìëë¼, ë¤í¸ìì íµí´ ë¤ë¥¸ ìë²ë¡ ì°ê²°ì í ìë ìë¤. ì´ë° 기ë¥ë¤ì ì ì를 ê°ì§ ì¬ì©ìë ì´ë³´ìê° ì´ë¤ íë¡ê·¸ë¨ì´ë ì¤íìì¼ ì¹ìë²ë¥¼ ë³´ìì ë¶ìí ìíë¡ ë§ë¤ ì ìë¤. PHPë ë¶ëª í Perlì´ë Cë³´ë¤ ì¢ë ìì í CGI íë¡ê·¸ë¨ì ë§ë¤ ì ìëë¡ ëì´ ìë¤. @@ -14,25 +14,21 @@ ì´ ìµì ë¤ì ì¡°í©ê³¼ ìë²ì ì¤ì ì ë°ë¼ ë³´ììì íì ì ë ¸ì¶ìí¬ ìë ìë¤. </simpara> <simpara> - The configuration flexibility of PHP is equally rivalled by the - code flexibility. PHP can be used to build complete server - applications, with all the power of a shell user, or it can be used - for simple server-side includes with little risk in a tightly - controlled environment. How you build that environment, and how - secure it is, is largely up to the PHP developer. + PHPìì ì¤ì ì ì ì°ì±ì ì½ëì ì ì°ì±ê³¼ ë¹ê²¬ë ë§í¼ íë¥íë¤. + PHPë ì ì¬ì©ìì ëì¼í ê¶íì¼ë¡ ìì í ìë² ì´í리ì¼ì´ì ì ë§ëëë° ì¬ì©ë ìë ìê³ , + ìíì´ ê±°ì ìë ë§¤ì° ì íë íê²½ìì ê°ë¨í server-side includeìë ì¬ì©ë ì ìë¤. + íê²½ì ì´ë»ê² ë§ëëê°, ë³´ìì ì´ë»ê² ì¤ì íëê°ë ì ì ì¼ë¡ PHP ê°ë°ììê² ë¬ë ¤ìë¤. </simpara> <simpara> - This chapter starts by explaining the different configuration - option combinations and the situations they can be safely used. It - then describes different considerations in coding for different - levels of security, and ends with some general security advice. + ì´ ì¥ì PHP를 ìì íê² ì¬ì©í ì ìë ì¬ë¬ ë¤ë¥¸ ì¤ì ìµì ì ì¡°í©ê³¼ ìí©ì ì¤ëª íë ê²ì¼ë¡ ììíë¤. + ê·¸ë¦¬ê³ , ê°ê° ìì´í ë³´ì ë 벨ììì ì½ë©ì ìì´ì ì¬ë¬ê°ì§ ê³ ë ¤ì¬íì ì¤ëª íë¤. </simpara> <sect1 id="security.cgi"> <title>Installed as CGI binary</title> <sect2 id="security.cgi.attacks"> <title>ê°ë¥í 공격 (Possible attacks)</title> <simpara> - <acronym>CGI</acronym> binary ííì PHPë ì´ë¤ ì´ì ë¡ (ìíì¹ ê°ì) ìë² ìíí¸ì¨ì´ì 모ëë¡ + <acronym>CGI</acronym> binary ííì PHPë ì´ë¤ ì´ì ë¡ (ìíì¹ ê°ì) ìë² ìíí¸ì¨ì´ì 모ëë¡ ì¬ì©ë기를 ìíì§ ìë ê²½ì°ì ì¬ì©í ì ìê³ , PHP를 ë¤ë¥¸ ì¢ ë¥ì CGI wrapperì í¨ê» ìì í chrootì setuid íê²½ì ë§ë¤ì´ ë´ë ê³³ì ëì ì¬ì©í ì ìë¤. ì´ ì¤ì ì ë³´íµ ì¤íí PHP binary를 ì¹ìë²ì cgi-binëë í 리ì ì¤ì¹í´ì¼ íë¤. @@ -60,11 +56,11 @@ <simpara> ì´ urlì PHP binary ì´íì path ì ë³´(<filename role="uri">/secret/doc.html</filename>)ë ì¼ë°ì ì¼ë¡ <acronym>CGI</acronym> íë¡ê·¸ë¨ì ìí´ ì½ê³ í´ìë íì¼ ì´ë¦ì¼ë¡ ì¬ì©ëë¤. - ë³´íµ ì¹ìë²ë ì¤ì ì§ìì(Apacheì ê²½ì° Action)를 ì¬ì©íì¬ <filename role="url">http://my.host/secret/script.php3</filename>ê°ì + ë³´íµ ì¹ìë²ë ì¤ì ì§ìì(Apacheì ê²½ì° Action)를 ì¬ì©íì¬ <filename role="url">http://my.host/secret/script.php</filename>ê°ì 문ì ìì²ì PHP ì¸í°í리í°ë¡ ë°ë¡ 리ëë í¸ íëë¡ í ì ìë¤. ì´ë ê² ì¤ì íë©´, ì¹ìë²ë ì°ì <filename role="uri">/secret</filename> ëë í 리ì ì ê·¼ ê¶íì ê²ì¬í íì - <filename role="url">http://my.host/cgi-bin/php/secret/script.php3</filename>ë¡ ë¦¬ëë í¸ë¥¼ íë¤. - ë¶ííë, ì´ ìì²ì´ ìëì formìì 주ì´ì§ ê²ì´ë¼ë©´, ì¹ìë²ë <filename role="uri">/secret/script.php3</filename> + <filename role="url">http://my.host/cgi-bin/php/secret/script.php</filename>ë¡ ë¦¬ëë í¸ë¥¼ íë¤. + ë¶ííë, ì´ ìì²ì´ ìëì formìì 주ì´ì§ ê²ì´ë¼ë©´, ì¹ìë²ë <filename role="uri">/secret/script.php</filename> íì¼ì ëí ì ê·¼ ê¶í ê²ì¬ë¥¼ íì§ ìê³ , <filename role="uri">/cgi-bin/php</filename> íì¼ì ëí ê²ì¬ë§ì ííë¤. ì´ ë°©ë²ì ì¬ì©íë©´ <filename role="uri">/cgi-bin/php</filename>ì ì ê·¼ ê°ë¥í ì¬ì©ìë ì¹ìë²ìì 모ë ë³´í¸ë 문ìë¤ë ì ê·¼í ì ìë¤. </simpara> @@ -85,8 +81,8 @@ ë§ì½ ì¬ë¬ë¶ì ì¹ìë²ê° 리ëë í¸ë¥¼ íì©íì§ ìê±°ë, ìë²ê° í´ë¹ ìêµ¬ê° ìì íê² ë¦¬ëë í¸ë ì구ì¸ì§ ëí ì 보를 PHP binaryì ì ë¬í ì ìë ë°©ë²ì´ ìì ê²½ì°, config ì¤í¬ë¦½í¸ìì <link linkend="install.configure.enable-force-cgi-redirect">--enable-force-cgi-redirect</link> ìµì ì 주ë ê²ì´ ì¢ë¤. - ê·¸ë¬ë ì¬ì í PHP ì¤í¬ë¦½í¸ê°, <filename role="php">http://my.host/cgi-bin/php/dir/script.php3</filename>ê°ì ì§ì ì ê·¼ ë°©ë²ì´ë - <filename role="php">http://my.host/dir/script.php3</filename>ê°ì 리ëë ì ì ë°©ë² ì´ì¸ì, + ê·¸ë¬ë ì¬ì í PHP ì¤í¬ë¦½í¸ê°, <filename role="php">http://my.host/cgi-bin/php/dir/script.php</filename>ê°ì ì§ì ì ê·¼ ë°©ë²ì´ë + <filename role="php">http://my.host/dir/script.php</filename>ê°ì 리ëë ì ì ë°©ë² ì´ì¸ì, ë¤ë¥¸ ë¯¿ì§ ëª»í ë°©ë²ì ìí´ ë¶ë ¤ ì§ ë를 ëë¹íì¬ ëì± ì ê°êµ¬í´ ëì´ì¼ í©ëë¤ </simpara> <simpara> @@ -96,7 +92,7 @@ <sect2 id="security.cgi.force-redirect"> <title>Case 2: --enable-force-cgi-redirect ìµì ì¬ì©</title> <simpara> - ì´ ìµì ì ì£¼ê³ PHP를 ì»´íì¼ íë©´, ì¬ì©ìê° <filename role="php">http://my.host/cgi-bin/php/secretdir/script.php3</filename>ì + ì´ ìµì ì ì£¼ê³ PHP를 ì»´íì¼ íë©´, ì¬ì©ìê° <filename role="php">http://my.host/cgi-bin/php/secretdir/script.php</filename>ì ê°ì´ PHP를 ì§ì í¸ì¶íë ê²ì ë§ìì¤ë¤. ëì , ì´ ëª¨ëìì PHPë ì¬ì©ìì ì구(request)ê° ì¹ìë²ì 리ëë í¸ ê·ì¹ì íµê³¼í ê²½ì°ìë§ ëì í ê²ì´ë¤. </simpara> @@ -104,8 +100,8 @@ ì¼ë°ì ì¼ë¡ ìíì¹ìì 리ëë í¸ ì¤ì ì ë¤ìê³¼ ê°ì ì§ìì를 ì¬ì©íì¬ íë¤. : </simpara> <programlisting role="apache-conf"> -Action php3-script /cgi-bin/php -AddHandler php3-script .php3 +Action php-script /cgi-bin/php +AddHandler php-script .php </programlisting> <simpara> ì´ ìµì ì ìíì¹ ì¹ìë²ììë§ ê²ì¦ëìë¤. @@ -128,7 +124,7 @@ ì¹ìë²ì document rootìë ë³ëì script doc_root를 ì¤ì í´ ì£¼ë ê²ì´ ë°ëì íìíë¤. </simpara> <simpara> - <link linkend="configuration.file">configuration file (php.ini)</link>ì <link linkend="ini.doc-root">doc_root</link> ì§ìì를 ì¤ì íê±°ë, <envar> PHP_DOCUMENT_ROOT</envar>ë¼ë íê²½ë³ì를 ì¤ì íì¬, PHP script document root를 ì¤ì í ì ìë¤. + <link linkend="configuration.file">configuration file (php.ini)</link>ì <link linkend="ini.doc-root">doc_root</link> ì§ìì를 ì¤ì íê±°ë, <envar> PHP_DOCUMENT_ROOT</envar>ë¼ë íê²½ë³ì를 ì¤ì íì¬, PHP script document root를 ì¤ì í ì ìë¤. ë§ì½ ì´ê²ì´ ì¤ì ëì´ ìë¤ë©´, CGI ë²ì ì PHPë ì ê·¼íë ¤ë íì¼ì ì´ë¦ì ì´ <parameter>doc_root</parameter>ì requestì ìë ê²½ë¡ ì 보를 ì´ì©íì¬ ë§ë¤ì´ë¸ë¤. ë°ë¼ì ì¬ë¬ë¶ì ì´ ëë í 리 ë°ììë ì´ë í ì¤í¬ë¦½í¸ë ì¤íë ì ìëë¡ ë§ë¤ê² ëë¤. (ìëì ìë user_dir ë§ì ìì¸ì´ë¤) @@ -136,19 +132,19 @@ <simpara> ì¬ê¸°ì ì¬ì©í ì ìë ëë¤ë¥¸ ìµì ì <link linkend="ini.user-dir">user_dir</link>ì´ë¤. user_dirì´ ì¤ì ëì´ ìì§ ìì¼ë©´ ì ê·¼ ê°ë¥í íì¼ì <parameter>doc_root</parameter> ë°ì ìë ê² ë¿ì´ë¤. - <filename role="url">http://my.host/~user/doc.php3</filename>ê°ì urlë¡ë user home directoryì ìë íì¼ì ì´ ì ìë¤. - ë¨ì§ doc_rootìëì <filename role="uri">~user/doc.php3</filename> íì¼ì ë¶ë¥¼ ë¿ì´ë¤. + <filename role="url">http://my.host/~user/doc.php</filename>ê°ì urlë¡ë user home directoryì ìë íì¼ì ì´ ì ìë¤. + ë¨ì§ doc_rootìëì <filename role="uri">~user/doc.php</filename> íì¼ì ë¶ë¥¼ ë¿ì´ë¤. (ë¬¼ë¡ í¸ë°[<literal>~</literal>]ë¡ ììíë "~user"ë¼ë ëë í 리ì´ë¤.) </simpara> <simpara> ì를 ë¤ì´, ë§ì½ user_dirì´ <filename role="dir">public_php</filename>ë¡ ì¤ì ëì´ ìë¤ë©´, - <filename role="url">http://my.host/~user/doc.php3</filename>ì ê°ì ì구ë userì home ëë í 리 ë°ì - <filename role="dir">public_php</filename>ë¼ë ëë í 리 ë°ì ìë doc.php3ë¼ë íì¼ì í¸ì¶ í ê²ì´ë¤. + <filename role="url">http://my.host/~user/doc.php</filename>ì ê°ì ì구ë userì home ëë í 리 ë°ì + <filename role="dir">public_php</filename>ë¼ë ëë í 리 ë°ì ìë doc.phpë¼ë íì¼ì í¸ì¶ í ê²ì´ë¤. ë§ì½ ì¬ì©ìì homeì´ <filename role="dir">/home/user</filename>ë¼ë©´, - ì¤íëë íì¼ì <filename>/home/user/public_php/doc.php3</filename>ì´ ëë¤. + ì¤íëë íì¼ì <filename>/home/user/public_php/doc.php</filename>ê° ëë¤. </simpara> <simpara> - <parameter>user_dir</parameter> íì¥ì <parameter>doc_root</parameter> ì¤ì ê³¼ ê´ë ¨ìì¼ë¯ë¡, + <parameter>user_dir</parameter> íì¥ì <parameter>doc_root</parameter> ì¤ì ê³¼ ê´ë ¨ìì¼ë¯ë¡, ì¬ë¬ë¶ì document rootì user directory ì ê·¼ íµì 를 ë°ë¡ë°ë¡ í ì ìë¤. </simpara> </sect2> @@ -159,15 +155,15 @@ ì를 ë¤ì´ <filename role="dir">/usr/local/bin</filename> ê°ì ê³³ì ëë¤. ì´ ìµì ì ë¨ì ì, 모ë PHP íì í¬í¨íê³ ìë íì¼ì 첫ë²ì§¸ ë¼ì¸ì ë¤ìê³¼ ê°ì´ ì ì´ì£¼ë ê² ë¿ì´ë¤. : <informalexample> - <programlisting> + <programlisting> #!/usr/local/bin/php </programlisting> - </informalexample> + </informalexample> ëí íì¼ì ì¤í ê°ë¥ì¼ë¡ ë§ë¤ì´ 주ì´ì¼ íë¤. ì¦, ìì ì ì¤íì ìí´ì <literal>#!</literal> shell-escape ë©ì¹´ëì¦ì ì¬ì©íë Perlì´ë sh í¹ì ë¤ë¥¸ ì¤í¬ë¦½í¸ ì¸ì´ì ê°ì ë°©ìì¼ë¡ ë¤ë£¨ë ê²ì´ë¤. </para> - <para> + <para> ì´ ì¤ì ìì PHPê° <envar>PATH_INFO</envar>ì <envar>PATH_TRANSLATED</envar>ì 보를 ì íí ë¤ë£¨ë ¤ë©´, php parserê° <link linkend="install.configure.enable-discard-path">--enable-discard-path</link> ì¤ì ìµì ì¼ë¡ ì»´íì¼ ëì´ì¼ íë¤. </para> @@ -176,6 +172,16 @@ <sect1 id="security.apache"> <title>Installed as an Apache module</title> <simpara> + PHPê° ìíì¹ ëª¨ëë¡ ì¬ì©ëë©´ ìíì¹ ì¬ì©ì ê¶íì ê·¸ëë¡ ì´ì´ë°ëë¤. (ë³´íµ 'nobody' user) + ì´ê²ì ë³´ìê³¼ ì¸ì¦ì ëí´ ê°ê° ìí¥ì 미ì¹ë¤. ì를ë¤ì´ PHPë¡ ë°ì´íë² ì´ì¤ì ì ê·¼íê³ , + ì´ ë°ì´íë² ì´ì¤ì ìì²´ì ì¸ ë´ì¥ ì ê·¼ íµì 를 ì¬ì©íì§ ìëë¤ë©´, "nobody" ì¬ì©ì를 + ë°ì´íë² ì´ì¤ì ì ê·¼ ê°ë¥íëë¡ ì¤ì í´ ëì´ì¼ íë¤. + ì´ê²ì usernameê³¼ password를 몰ë¼ë ì ìì ì¸ ì¤í¬ë¦½í¸ë¥¼ ì¬ì©íì¬ ë°ì´íë² ì´ì¤ì ì ê·¼íê³ + ë°ì´í를 ìì í ì ìë¤ë ê²ì ì미íë¤. ëí í¬ëì»¤ê° ê´ë¦¬ìì© ì¹íì´ì§ë¥¼ ë¤ë½ê±°ë¦¬ê³ , + ë°ì´íë² ì´ì¤ë¥¼ ìì í´ ë²ë¦¬ë ê²ë ê°ë¥íë¤. ì¬ë¬ë¶ì ìíì¹ì ì¸ì¦ 기ë¥ì ì¬ì©íì¬ + ì´ë° 공격ì ëííë ë°©ì´ë¥¼ í ì ìë¤. + + ì¬ì© When PHP is used as an Apache module it inherits Apache's user permissions (typically those of the "nobody" user). This has several impacts on security and authorization. For example, if you are using @@ -244,7 +250,7 @@ $file_to_delete = "$userfile"; unlink ($homedir/$userfile); echo "$file_to_delete has been deleted!"; -?> +?> </programlisting> </example> Since the username is postable from a user form, they can submit @@ -263,7 +269,7 @@ $file_to_delete = "passwd"; unlink ("/home/../etc/passwd"); echo "/home/../etc/passwd has been deleted!"; -?> +?> </programlisting> </example> There are two important measures you should take to prevent these @@ -300,7 +306,7 @@ fclose($fp); echo "$file_to_delete has been deleted!"; -?> +?> </programlisting> </example> Alternately, you may prefer to write a more customized check: @@ -308,14 +314,14 @@ <title>More secure file name checking</title> <programlisting role="php"> <?php -$username = $HTTP_REMOTE_USER; +$username = getenv("REMOTE_USER"); $homedir = "/home/$username"; if (!ereg('^[^./][^/]*$', $userfile)) die('bad filename'); //die, do not process //etc... -?> +?> </programlisting> </example> Depending on your operating system, there are a wide variety of files @@ -339,14 +345,19 @@ developer who is trying to debug a script, indicating such things as the function or file that failed, the PHP file it failed in, and the line number which the failure occured in. This is all - information that can be exploited. + information that can be exploited. It is not uncommon for a php + developer to use <function>show_source</function>, + <function>highlight_string</function>, or + <function>highlight_file</function> as a debugging measure, but in + a live site, this can expose hidden variables, unchecked syntax, + and other dangerous information. </simpara> <simpara> - For example, the very style of error indicates a system is running - PHP. If the attacker was looking at an .html page, and wanted to - probe for the back-end (to look for known weaknesses in the system), - by feeding it the wrong data they may be able to determine that a - system was built with PHP. + For example, the very style of a generic error indicates a system + is running PHP. If the attacker was looking at an .html page, and + wanted to probe for the back-end (to look for known weaknesses in + the system), by feeding it the wrong data they may be able to + determine that a system was built with PHP. </simpara> <simpara> A function error can indicate whether a system may be running a @@ -361,7 +372,9 @@ <simpara> A filesystem or general PHP error can indicate what permissions the webserver has, as well as the structure and organization of - files on the web server. + files on the web server. Developer written error code can aggravate + this problem, leading to easy exploitation of formerly "hidden" + information. </simpara> <simpara> There are three major solutions to this issue. The first is to @@ -396,7 +409,7 @@ system ($evil_var); exec ($evil_var); -?> +?> </programlisting> </example> You should always carefully examine your code to make sure that any @@ -491,6 +504,21 @@ connected to. Many cracking programs do not discern by size, they simply trawl massive IP blocks looking for victims. Try not to become one. + </simpara> + </sect1> + <sect1 id="security.current"> + <title>Keeping Current</title> + <simpara> + PHP, like any other large system, is under constant scrutiny and + improvement. 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. + </simpara> + <simpara> + Like other system-level scripting languages and programs, the best + approach is to update often, and maintain awareness of the latest + versions and their changes. </simpara> </sect1> </chapter>