=encoding euc-jp =head1 NAME =begin original perlsec - Perl security =end original perlsec - Perl �Υ������ƥ� =head1 DESCRIPTION =begin original Perl is designed to make it easy to program securely even when running with extra privileges, like setuid or setgid programs. Unlike most command line shells, which are based on multiple substitution passes on each line of the script, Perl uses a more conventional evaluation scheme with fewer hidden snags. Additionally, because the language has more builtin functionality, it can rely less upon external (and possibly untrustworthy) programs to accomplish its purposes. =end original Perl�ϡ��ץ�����ब setuid �� setgid �����褦�����̤ʸ��¤��ղä���� �¹Ԥ��줿�Ȥ��Ǥ⥻�����ƥ��ݻ����ưפˤʤ�褦���߷פ���Ƥ��ޤ��� ������ץȤΰ�Ԥ��Ȥ�¿���ִ���Ԥ����Ȥ˴�Ť��Ƥ���褦������ʬ�� ���ޥ�ɥ饤�󥷥���Ȥϰ�äơ�Perl �ϱ��줿�㳲�����ʤ��褦�ʡ� ���������ɾ����ˡ���Ѥ��Ƥ��ޤ��� ����˲ä��� Perl �Ϥ��¿�����Ȥ߹��ߴؿ�����äƤ���Τǡ� ������Ū��ã�����뤿���(����Ǥ��ʤ����⤷��ʤ��褦��) �����ץ�������Ȥ����Ȥ����ʤ��Ƥ���ΤǤ��� =head1 SECURITY VULNERABILITY CONTACT INFORMATION (�������ƥ��ȼ���Ϣ�����) =begin original If you believe you have found a security vulnerability in Perl, please email perl5-security-report@perl.org with details. This points to a closed subscription, unarchived mailing list. Please only use this address for security issues in the Perl core, not for modules independently distributed on CPAN. =end original Perl �Υ������ƥ��ȼ�����ȯ�������ȳο������Ȥ��ˤϡ��ɤ����ܺ٤� perl5-security-report@perl.org �˥᡼�뤷�Ƥ��������� ����ϥ��������ɤǡ����������֤��Ĥ�ʤ��᡼��󥰥ꥹ�ȤˤʤäƤ��ޤ��� Perl �����Υ������ƥ�����ˤĤ��Ƥ������Υ��ɥ쥹��Ȥäơ��ȼ��� CPAN �����ۤ���Ƥ���⥸�塼��ˤĤ��ƤϻȤ�ʤ��Ǥ��������� =head1 SECURITY MECHANISMS AND CONCERNS =head2 Taint mode =begin original Perl automatically enables a set of special security checks, called I, when it detects its program running with differing real and effective user or group IDs. The setuid bit in Unix permissions is mode 04000, the setgid bit mode 02000; either or both may be set. You can also enable taint mode explicitly by using the B<-T> command line flag. This flag is I suggested for server programs and any program run on behalf of someone else, such as a CGI script. Once taint mode is on, it's on for the remainder of your script. =end original Perl �ϡ����Υץ�����ब�ۤʤ�¥桼���� ID���¸��桼���� ID���¥��롼�� ID�� �¸����롼�� ID ��ȤäƼ¹Ԥ���뤳�Ȥ򸡽Ф����Ȥ��ˡ� ��ưŪ�� I<�����⡼��> (taint mode) �ȸƤФ�����̤ʥ������ƥ������å��� ���åȤ�ͭ���ˤ��ޤ��� UNIX �ѡ��ߥå����ˤ����� setuid �ӥåȤϥ⡼�� 04000 �ǡ� setgid �ӥåȤϥ⡼�� 02000 �Ǥ��� �����Ͻ�ʣ���ƥ��åȤ��뤳�Ȥ�Ǥ��ޤ��� �����⡼�ɤϡ����ޥ�ɥ饤��ե饰 B<-T> ��Ȥä��ۤ�ͭ���ˤ��뤳�Ȥ�Ǥ��ޤ��� ���Υե饰�ϥ����С��ץ������Ǥ���Ȥ��� CGI ������ץȤΤ褦�ʡ�¾��ï���ˤ��꤫��äƼ¹Ԥ����ץ������� �Ȥ����Ȥ� B<����> ����ޤ��� =begin original While in this mode, Perl takes special precautions called I to prevent both obvious and subtle traps. Some of these checks are reasonably simple, such as verifying that path directories aren't writable by others; careful programmers have always used checks like these. Other checks, however, are best supported by the language itself, and it is these checks especially that contribute to making a set-id Perl program more secure than the corresponding C program. =end original ���Υ⡼�ɤ�ư��Ƥ���Ȥ���Perl �������櫤ȱ��줿櫤�ξ�����н褹�뤿��� I<��������> (taint check) �ȸƤФ�����̤ʷٲ���Ԥ��ޤ��� �����Υ����å��δ��Ĥ��ϡ�ñ��Ǥ��� path �ǥ��쥯�ȥ꤬¾����񤭹��߲�ǽ�Ǥʤ����Ȥ򸡺�����Ȥ��ä����Ȥ������Ǥ��� ���տ����ץ�����ޡ��Ͼ�ˤ����Τ��Ȥϥ����å����Ƥ��ޤ��� ���Τۤ��Υ����å��Ϥ������ʤ��顢���켫�Ȥˤ�äƺǤ��ɤ����ݡ��Ȥ���ޤ��� �����ơ������Υ����å����ä� set-id ���줿 Perl �ץ������� �б����� C �ץ�������������ˤ���Τ˹׸�����ΤǤ��� =begin original You may not use data derived from outside your program to affect something else outside your program--at least, not by accident. All command line arguments, environment variables, locale information (see L), results of certain system calls (C, C, the variable of C, the messages returned by C, the password, gcos and shell fields returned by the C calls), and all file input are marked as "tainted". Tainted data may not be used directly or indirectly in any command that invokes a sub-shell, nor in any command that modifies files, directories, or processes, B: =end original ��ʬ�Υץ������γ�¦�����褿�ǡ�����ץ������γ��β����˱ƶ��� �ڤܤ�����˻Ȥ����Ȥϡ����ʤ��Ȥ⥢�����ǥ�ȤǤǤ�ʤ���С��Ǥ��ޤ��� ���٤ƤΥ��ޥ�ɥ饤��������Ķ��ѿ��������������(L �򻲾�)�� ���Ĥ��Υ����ƥॳ����η��(C, C, C ���ѿ��� C ���֤�����å��������ѥ���ɡ�C �ƤӽФ����֤��� gecos �ե�����ɤȥ�����ե������)�����٤ƤΥե��������ϤȤ��ä���Τ� �ȱ������줿��(tainted) ���ܰ����դ����ޤ��� �������줿�ǡ�����ľ�ܡ����ܤ���鷺���֥������ư���륳�ޥ�ɤ˻Ȥ����Ȥ⡢ �ե������ǥ��쥯�ȥꡢ�ץ��������ѹ���ä���褦�ʥ��ޥ�ɤ� �Ȥ����Ȥ�Ǥ��ޤ��� â�� B<�ʲ����㳰> ������ޤ��� =over 4 =item * =begin original Arguments to C and C are B checked for taintedness. =end original C �� C �ΰ������Ф������������ B<�Ԥ��ޤ���>�� =item * =begin original Symbolic methods =end original ����ܥ�å��᥽�å� $obj->$method(@args); =begin original and symbolic sub references =end original �ȥ���ܥ�å����֥롼�����ե���� &{$foo}(@args); $foo->(@args); =begin original are not checked for taintedness. This requires extra carefulness unless you want external data to affect your control flow. Unless you carefully limit what these symbolic values are, people are able to call functions B your Perl code, such as POSIX::system, in which case they are able to run arbitrary external code. =end original �ϱ������������å�����ޤ��� ����ϡ����ʤ�������ե����������ǡ����˱ƶ����줿���Ȼפ�ʤ��ʤ顢 ����ʤ뿵�Ť����׵ᤷ�ޤ��� �����Υ���ܥ�å����ͤ����������տ������¤��ʤ��ȡ�POSIX::system �Τ褦�� ���ʤ��� Perl �����ɤ� B<��¦> �δؿ���ƤӽФ����Ȥ��ǽ�ˤ������ξ�� Ǥ�դγ��������ɤ�¹ԤǤ���褦�ˤʤ�ޤ��� =item * =begin original Hash keys are B tainted. =end original �ϥå���Υ����� B<�褷��> ��������ޤ��� =back =begin original For efficiency reasons, Perl takes a conservative view of whether data is tainted. If an expression contains tainted data, any subexpression may be considered tainted, even if the value of the subexpression is not itself affected by the tainted data. =end original ��Ψ�����ͳ���顢Perl �ϥǡ�������������Ƥ��뤫�ɤ����ˤĤ����ݼ�Ū�� �����򤷤ޤ��� ��������Ƥ���ǡ��������˴ޤޤ�Ƥ����硢���Ȥ��������ͼ��Ȥϱ������줿 �ǡ����˱ƶ�������ʤ����Ǥ⡢���Ƥ�������������줿��ΤȤ��� �����ޤ��� =begin original Because taintedness is associated with each scalar value, some elements of an array or hash can be tainted and others not. The keys of a hash are B tainted. =end original �����ϳƥ������ͤ˷���դ�����Τǡ�����δ��Ĥ������Ǥ���������Ƥ��ơ� ���Τۤ������ǤϤ����ǤϤʤ��Ȥ������Ȥ⤢�ꤨ�ޤ��� �ϥå���Υ����� B<�褷��> ��������ޤ��� =begin original For example: =end original ��򼨤��ޤ�: =begin original $arg = shift; # $arg is tainted $hid = $arg, 'bar'; # $hid is also tainted $line = <>; # Tainted $line = ; # Also tainted open FOO, "/home/me/bar" or die $!; $line = ; # Still tainted $path = $ENV{'PATH'}; # Tainted, but see below $data = 'abc'; # Not tainted =end original $arg = shift; # $arg �ϱ������줿 $hid = $arg, 'bar'; # $hid ��������줿 $line = <>; # �������줿 $line = ; # �����������줿 open FOO, "/home/me/bar" or die $!; $line = ; # �ޤ���������Ƥ��� $path = $ENV{'PATH'}; # ��������Ƥ��뤬�������򻲾ȤΤ��� $data = 'abc'; # ��������Ƥ��ʤ� =begin original system "echo $arg"; # Insecure system "/bin/echo", $arg; # Considered insecure # (Perl doesn't know about /bin/echo) system "echo $hid"; # Insecure system "echo $data"; # Insecure until PATH set =end original system "echo $arg"; # �����ǤϤʤ� system "/bin/echo", $arg; # �����ǤϤʤ��ȹͤ����� # (Perl �� /bin/echo �ˤĤ����Τ�ʤ�) system "echo $hid"; # �����ǤϤʤ� system "echo $data"; # PATH�����ꤹ��ޤǤϰ����ǤϤʤ� =begin original $path = $ENV{'PATH'}; # $path now tainted =end original $path = $ENV{'PATH'}; # $path ���������줿 $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; =begin original $path = $ENV{'PATH'}; # $path now NOT tainted system "echo $data"; # Is secure now! =end original $path = $ENV{'PATH'}; # $path �ϱ�������Ƥ��ʤ� system "echo $data"; # ����ǰ���! =begin original open(FOO, "< $arg"); # OK - read-only file open(FOO, "> $arg"); # Not OK - trying to write =end original open(FOO, "< $arg"); # OK - �ɤ߹��ߤΤߤΥե����� open(FOO, "> $arg"); # Not OK - �񤭹��ߤ��褦�Ȥ��Ƥ��� open(FOO,"echo $arg|"); # Not OK open(FOO,"-|") or exec 'echo', $arg; # Also not OK =begin original $shout = `echo $arg`; # Insecure, $shout now tainted =end original $shout = `echo $arg`; # �����Ǥʤ���$shout�ϱ������줿�� =begin original unlink $data, $arg; # Insecure umask $arg; # Insecure =end original unlink $data, $arg; # �����Ǥʤ� umask $arg; # �����Ǥʤ� =begin original exec "echo $arg"; # Insecure exec "echo", $arg; # Insecure exec "sh", '-c', $arg; # Very insecure! =end original exec "echo $arg"; # �����Ǥʤ� exec "echo", $arg; # �����Ǥʤ� exec "sh", '-c', $arg; # �ȤƤ�����ǤϤʤ�! =begin original @files = <*.c>; # insecure (uses readdir() or similar) @files = glob('*.c'); # insecure (uses readdir() or similar) =end original @files = <*.c>; # �����Ǥʤ� (readdir() �Τ褦�ʤ�Τ�Ȥ�) @files = glob('*.c'); # �����Ǥʤ� (readdir() �Τ褦�ʤ�Τ�Ȥ�) # In Perl releases older than 5.6.0 the <*.c> and glob('*.c') would # have used an external program to do the filename expansion; but in # either case the result is tainted since the list of filenames comes # from outside of the program. =begin original $bad = ($arg, 23); # $bad will be tainted $arg, `true`; # Insecure (although it isn't really) =end original $bad = ($arg, 23); # $bad �ϱ�������Ƥ��뤫�� $arg, `true`; # �����Ǥʤ� (�ºݤϤ����Ǥʤ��Ƥ�) =begin original If you try to do something insecure, you will get a fatal error saying something like "Insecure dependency" or "Insecure $ENV{PATH}". =end original �����Ǥʤ����Ȥ������Ȥ���ȡ�"Insecure dependency" �� "Insecure $ENV{PATH}" �Τ褦����̿Ū���顼�Ȥʤ�Ǥ��礦�� =begin original The exception to the principle of "one tainted value taints the whole expression" is with the ternary conditional operator C. Since code with a ternary conditional =end original The exception to the principle of "one tainted value taints the whole expression" is with the ternary conditional operator C. 3 �����Ȥä������� $result = $tainted_value ? "Untainted" : "Also untainted"; =begin original is effectively =end original �Ȥ����Τϻ��¾� if ( $tainted_value ) { $result = "Untainted"; } else { $result = "Also untainted"; } =begin original it doesn't make sense for C<$result> to be tainted. =end original �ʤΤǡ�C<$result> ���������줿�ȹͤ���Τϰ�̣������ޤ��� =head2 Laundering and Detecting Tainted Data (�������줿�ǡ����θ��Ф�����) =begin original To test whether a variable contains tainted data, and whose use would thus trigger an "Insecure dependency" message, you can use the C function of the Scalar::Util module, available in your nearby CPAN mirror, and included in Perl starting from the release 5.8.0. Or you may be able to use the following C function. =end original �����ѿ����������줿�ǡ������ݻ����Ƥ��뤫�ɤ����򸡺����뤿�ᡢ�����ơ� "Insecure dependency" ��å������ΰ�����ˤʤ��ǽ�������뤫�ɤ����� �������뤿��ˡ�CPAN �ˤ��ꡢ5.8.0 ����� Perl �˴ޤޤ�Ƥ��� Scalar::Util �⥸�塼��� C �ؿ���Ȥ��ޤ��� ���뤤�ϡ��ʲ��Τ褦�ʴؿ� C ��Ȥ����Ȥ��Ǥ��ޤ��� sub is_tainted { return ! eval { eval("#" . substr(join("", @_), 0, 0)); 1 }; } =begin original This function makes use of the fact that the presence of tainted data anywhere within an expression renders the entire expression tainted. It would be inefficient for every operator to test every argument for taintedness. Instead, the slightly more efficient and conservative approach is used that if any tainted value has been accessed within the same expression, the whole expression is considered tainted. =end original ���δؿ��Ϥ��뼰�Τɤ����ˤ���������줿�ǡ����������Τ�������Ƥ��ޤ����Ȥ� ���Ѥ��Ƥ��ޤ��� ����Ϥ��٤Ƥα黻�Ҥ��Ф��ơ����Τ��٤Ƥΰ�������������Ƥ��뤫�ɤ����� �����򤹤�ΤǸ�Ψ���ɤ��ʤ��Ǥ��礦�� ��������ˡ������μ��ˤ����Ʊ������줿�ͤ˥����������Ƽ����Τ� �������줿�Ȥߤʤ����褦�ʾ��ˤϡ���äȸ�Ψ���ɤ��� �ݼ�Ū����ˡ���Ȥ��ޤ��� =begin original But testing for taintedness gets you only so far. Sometimes you have just to clear your data's taintedness. Values may be untainted by using them as keys in a hash; otherwise the only way to bypass the tainting mechanism is by referencing subpatterns from a regular expression match. Perl presumes that if you reference a substring using $1, $2, etc., that you knew what you were doing when you wrote the pattern. That means using a bit of thought--don't just blindly untaint anything, or you defeat the entire mechanism. It's better to verify that the variable has only good characters (for certain values of "good") rather than checking whether it has any bad characters. That's because it's far too easy to miss bad characters that you never thought of. =end original �������������θ��������ݤǤ��� ���ʤ��Υǡ����α���������������Ȥ������Ȥ⤢��Ǥ��礦�� �ͤϥϥå���Υ����Ȥ��ƻȤ����ȤǾ�������ޤ�; ����ʤ���С� ��������������Х��ѥ����뤿��Τ�����Ĥ���ˡ�ϡ� �ޥå���������ɽ���Υ��֥ѥ�����򻲾Ȥ��뤳�ȤǤ��� Perl �ϡ����ʤ��� $1��$2 �ʤɤ�Ȥä���ʬʸ����򻲾Ȥ����Ȥ��ˡ� ���ʤ����ѥ�����򵭽Ҥ����Ȥ��˲���Ԥ��Τ����ΤäƤ����Ȳ��ꤷ�ޤ��� �Ĥޤꡢ��������Ƥ��ʤ���Τ�«�����ʤ������������Τ�̵���ˤ���Ȥ������ȤǤ��� ����ϡ��ѿ����ʤ�餫�ΰ���ʸ������äƤ��뤫�ɤ����� ��������Ȥ����ΤǤϤʤ����ѿ����ɤ�ʸ���Τߤ���äƤ��뤳�Ȥ� �����ˤ��Թ礬�ɤ��Ǥ��� �����(���ʤ����ͤ��⤷�ʤ��褦��)����ʸ���򸫼������Ȥ����ޤ�ˤ� ��ñ�Ǥ��뤫��Ǥ��� =begin original Here's a test to make sure that the data contains nothing but "word" characters (alphabetics, numerics, and underscores), a hyphen, an at sign, or a dot. =end original �ʲ��˼�����ϡ��ǡ����ˡȸ��(����ե��٥åȡ��������������������)�� ʸ�����ϥ��ե󡢥��åȥޡ������ɥåȰʳ��Τ�Τ����äƤ��ʤ����Ȥ� ���������ΤǤ��� if ($data =~ /^([-\@\w.]+)$/) { $data = $1; # $data now untainted } else { die "Bad data in '$data'"; # log this somewhere } =begin original This is fairly secure because C doesn't normally match shell metacharacters, nor are dot, dash, or at going to mean something special to the shell. Use of C would have been insecure in theory because it lets everything through, but Perl doesn't check for that. The lesson is that when untainting, you must be exceedingly careful with your patterns. Laundering data using regular expression is the I mechanism for untainting dirty data, unless you use the strategy detailed below to fork a child of lesser privilege. =end original ����Ϥ��ʤ�����Ǥ��� �ʤ��ʤ� C<\w+> ���̾亮����Υ᥿ʸ���ˤ� �ޥå����ޤ��󤷡��ɥåȤ���å���ʤɤΥ�����ˤȤä����̤ʰ�̣�� ���Ĥ褦�ʤ�Τˤ�ޥå����ʤ�����Ǥ��� C ��Ȥ��Τϡ�����Ϥ��٤Ƥ��̤��Ƥ��ޤ��Τ� Perl �Ϥ���� �����å����ޤ��󤫤顢����Ū�ˤϰ����ǤϤ���ޤ��� ������������Ȥ��ˤϡ���ʬ�Υѥ�����ˤĤ��ƽ���ʬ�����դ��ͤФʤ�ޤ��� ����ɽ����Ȥä��ǡ����������ϡ����������������㤤�ø��٤λҥץ������� fork ���뤿�����ά��Ȥ��ޤǤϱ��줿�ǡ����α������� B<�Τ�> �ε����Ǥ��� =begin original The example does not untaint C<$data> if C is in effect, because the characters matched by C<\w> are determined by the locale. Perl considers that locale definitions are untrustworthy because they contain data from outside the program. If you are writing a locale-aware program, and want to launder data with a regular expression containing C<\w>, put C ahead of the expression in the same block. See L for further discussion and examples. =end original �����Ǥϡ�C ��ͭ���Ǥ���Ȥ��ˤ� C<$data> �� ���������Ԥ��ޤ��� �ʤ��ʤ顢C<\w> �˥ޥå�����ʸ���ϥ�������ˤ�äƷ��ꤵ��뤫��Ǥ��� Perl �ϡ���������Ƿ�ޤ뤳�Ȥ򡢤��줬�ץ������γ������褿�ǡ������� ��������Ƥ���Ȥ�����ͳ�ˤ�äƿ��ѤǤ��ʤ���ΤȤߤʤ��ޤ��� �⤷����������θ�����ץ�������񤤤Ƥ��ơ�C<\w> ��ޤ������ɽ���� �ǡ�����������Ԥ������Ȥ����Τʤ顢�����֤��줿�Τ�Ʊ���֥��å���������ʬ�� C���֤��ޤ��� L �˾ܤ����������㤬����ޤ��� =head2 Switches On the "#!" Line ("#!" �ԤΥ����å�) =begin original When you make a script executable, in order to make it usable as a command, the system will pass switches to perl from the script's #! line. Perl checks that any command line switches given to a setuid (or setgid) script actually match the ones set on the #! line. Some Unix and Unix-like environments impose a one-switch limit on the #! line, so you may need to use something like C<-wU> instead of C<-w -U> under such systems. (This issue should arise only in Unix or Unix-like environments that support #! and setuid or setgid scripts.) =end original ��ʬ�κ�ä�������ץȤ򥳥ޥ�ɤΤ褦�˻Ȥ���褦�ˤ����Ȥ��������ƥ�� perl ���Ф��ơ�������ץȤ� #! �ιԤ��饳�ޥ�ɥ饤�󥹥��å����Ϥ��ޤ��� Perl �ϡ�setuid(���뤤�� setgid) ���줿������ץȤ�Ϳ����줿 ���ޥ�ɥ饤�󥹥��å��� #! �Ԥˤ����Τ������˰��פ��뤫�ɤ����򸡺����ޤ��� ������ UNIX �� UNIX ���δĶ��Ǥ� #! �Ԥˤϰ�ĤΥ����å������֤��ʤ��Τǡ� �������ä������ƥ�Ǥ� C<-w -U> �Ȥ��ä������ǤϤʤ� C<-wU> �Τ褦�ˤ���ɬ�פ�����Ǥ��礦(����� #! �򥵥ݡ��Ȥ��Ƥ��ơ� setuid �� setgid ������ץȤ��Ȥ��� UNIX �Ķ��� UNIX �˻����Ķ��ǤΤ� �Ԥʤ��뤳�ȤǤ�)�� =head2 Taint mode and @INC (���������⡼�ɤ� @INC) =begin original When the taint mode (C<-T>) is in effect, the "." directory is removed from C<@INC>, and the environment variables C and C are ignored by Perl. You can still adjust C<@INC> from outside the program by using the C<-I> command line option as explained in L. The two environment variables are ignored because they are obscured, and a user running a program could be unaware that they are set, whereas the C<-I> option is clearly visible and therefore permitted. =end original ���������⡼��(C<-T>) ��ͭ���ΤȤ���"." �ǥ��쥯�ȥ�� C<@INC> ���� �������졢�Ķ��ѿ� C �� C �� Perl ����̵�뤵��ޤ��� ����Ǥ⡢L ����������Ƥ��� C<-I> ���ޥ�ɥ饤�󥪥ץ����� �Ȥ����Ȥǡ��ץ������γ������� C<@INC> ��Ĵ������ޤ��� ��ĤδĶ��ѿ��������Τǡ��ץ�������¹Ԥ��Ƥ��� �桼�����Ϥ����ѿ������ꤵ��Ƥ��뤳�Ȥ˵��դ��ʤ����⤷��ʤ��Τ� ̵�뤵��ޤ��������� C<-I> ���ץ��������Τ˸�����Τǵ��Ĥ���ޤ��� =begin original Another way to modify C<@INC> without modifying the program, is to use the C pragma, e.g.: =end original �ץ������������뤳�Ȥʤ� C<@INC> ��������⤦��Ĥ���ˡ�ϡ� C �ץ饰�ޤ�Ȥ����ȤǤ����Ĥޤ�: perl -Mlib=/foo program =begin original The benefit of using C<-Mlib=/foo> over C<-I/foo>, is that the former will automagically remove any duplicated directories, while the later will not. =end original C<-I/foo> �ǤϤʤ� C<-Mlib=/foo> ��Ȥ������ϡ���Ԥ�������ưŪ�˽�ʣ���� �ǥ��쥯�ȥ��ưŪ�˽���뤳�ȤǤ��� =begin original Note that if a tainted string is added to C<@INC>, the following problem will be reported: =end original �⤷�������줿ʸ���� C<@INC> ���ɲä����ȡ��ʲ������꤬��𤵤�뤳�Ȥ� ���դ��Ƥ�������: Insecure dependency in require while running with -T switch =head2 Cleaning Up Your Path (�¹ԥѥ�����������) =begin original For "Insecure C<$ENV{PATH}>" messages, you need to set C<$ENV{'PATH'}> to a known value, and each directory in the path must be absolute and non-writable by others than its owner and group. You may be surprised to get this message even if the pathname to your executable is fully qualified. This is I generated because you didn't supply a full path to the program; instead, it's generated because you never set your PATH environment variable, or you didn't set it to something that was safe. Because Perl can't guarantee that the executable in question isn't itself going to turn around and execute some other program that is dependent on your PATH, it makes sure you set the PATH. =end original "Insecure C<$ENV{PATH}>" ��å��������н褹�뤿��ˡ�C<$ENV{'PATH'}> �� ���Τ��ͤ����ꤹ��ɬ�פ�����ޤ��� ������ path �˴ޤޤ�Ƥ���ƥǥ��쥯�ȥ�ϡ����Хѥ��ǡ� ���Υǥ��쥯�ȥ�ν�ͭ�Ԥ䥰�롼�װʳ�����ν񤭹��ߤ� �ؤ��Ƥ��ʤ���Фʤ�ޤ��� �¹Ԥ��褦�Ȥ��Ƥ���ե������ե�ѥ��� �񤤤��Ȥ��Ƥ⤳�Υ�å��������Ǥ�Τǡ��Ӥä��ꤹ�뤳�Ȥ����뤫�⤷��ޤ��� ���Υ�å������ϥץ������Υե�ѥ���񤫤ʤ��ä�������Ϥ����ǤϤʤ��� �Ķ��ѿ� PATH �����ꤷ�ʤ��ä�������Ǥʤ��ͤ� ���ꤷ���ꤷ������˽��Ϥ����ΤǤ��� Perl ���оݤȤʤäƤ���¹ԥե����뤬��ʬ���Ȥ�����ž�������ꡢ PATH �򻲾Ȥ����̤Υץ�������ư�����ꤹ�뤫�ɤ������Τ뤳�Ȥ��Ǥ��ʤ��Τǡ� �μ¤˼�ʬ�� PATH �����ꤹ��褦�ˤ��ޤ��� =begin original The PATH isn't the only environment variable which can cause problems. Because some shells may use the variables IFS, CDPATH, ENV, and BASH_ENV, Perl checks that those are either empty or untainted when starting subprocesses. You may wish to add something like this to your setid and taint-checking scripts. =end original �������������������Ķ��ѿ��� PATH �����ǤϤ���ޤ��� �����Υ�����Ǥϡ�IFS��CDPATH��ENV��BASH_ENV �Τ褦�ʴĶ��ѿ��� �ȤäƤ��ޤ����顢Perl �Ϥ������ѿ�������Ǥ��뤫���뤤�� ���֥ץ���������ư�����Ȥ��˱�������Ƥ��ʤ����ɤ��������å����ޤ��� setid ���Ƥ����ꡢ���������򤹤륹����ץȤ� �ʲ��Τ褦�ʹԤ��դ��ä������ʤ뤫����ޤ��� delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer =begin original It's also possible to get into trouble with other operations that don't care whether they use tainted values. Make judicious use of the file tests in dealing with any user-supplied filenames. When possible, do opens and such B properly dropping any special user (or group!) privileges. Perl doesn't prevent you from opening tainted filenames for reading, so be careful what you print out. The tainting mechanism is intended to prevent stupid mistakes, not to remove the need for thought. =end original ���Τۤ��Ρ��������줿�ͤ�ȤäƤ��뤫�ɤ��������դ�ʧ��ʤ��褦�� ���ˤ�äƥȥ�֥�˴����ޤ���ǽ���⤢��ޤ��� �桼�������Ȥ��褦�ʥե�����̾�򰷤��ե����븡���λ��Ѥ����ʤ�Τˤ��ޤ��� ��ǽ�Ǥ���С��ե�����򥪡��ץ󤷤� B<���θ��> Ŭ�ڤ˥��ڥ����桼���� (���롼�פ�!)���ø�����Ȥ��ޤ��� Perl �Ϥ��ʤ����ɤ߽Ф��Τ���˱������줿�ե�����̾��Ȥäƥե������ �����ץ󤹤뤳�Ȥ�˸���ޤ��󤫤顢���Ϥκݤˤ����դ��ޤ��礦�� �������������ϤФ��Ф������ߥ����б����뤿��Τ�ΤǤ��äơ� ɬ�פʤ��Ȥ��������ΤǤϤ���ޤ��� =begin original Perl does not call the shell to expand wild cards when you pass C and C explicit parameter lists instead of strings with possible shell wildcards in them. Unfortunately, the C, C, and backtick functions provide no such alternate calling convention, so more subterfuge will be required. =end original Perl �ϡ�C �� C ���Ф��ƥ�����Υ磻��ɥ����ɤ� ���뤫�⤷��ʤ��褦��ʸ����ǤϤʤ��ۤ˥ѥ�᡼���ꥹ�Ȥ��Ϥ������ˤϡ� �磻��ɥ����ɤ�Ÿ���Τ���˥������ƤӽФ����ꤷ�ޤ��� ��ǰ�ʤ��Ȥˡ�C��C���ե������ȤȤ��ä���ΤϤ������ä��̤� �ƤӽФ������󶡤��Ƥ��ʤ��Τǡ����¿���Τ��ޤ�����ɬ�פȤ���ޤ��� =begin original Perl provides a reasonably safe way to open a file or pipe from a setuid or setgid program: just create a child process with reduced privilege who does the dirty work for you. First, fork a child using the special C syntax that connects the parent and child by a pipe. Now the child resets its ID set and any other per-process attributes, like environment variables, umasks, current working directories, back to the originals or known safe values. Then the child process, which no longer has any special permissions, does the C or other system call. Finally, the child passes the data it managed to access back to the parent. Because the file or pipe was opened in the child while running under less privilege than the parent, it's not apt to be tricked into doing something it shouldn't. =end original Perl �ϡ�setuid �� setgid ���줿�ץ�����फ������˥ե������ѥ��פ� �����ץ󤹤���ˡ���󶡤��Ƥ��ޤ��� �����ñ�ˡ�����Ż��򤹤뤿������¤��줿��������ä��ҥץ������� ��������Ȥ�����ΤǤ��� �ޤ��ǽ�ˡ��ѥ��פˤ�äƿƥץ������Ȼҥץ������Ȥ�Ҥ���ʸ�� ���̤� C ��Ȥäƻҥץ������� fork ���ޤ��� ���ΤȤ����ҥץ������Ϥ��� ID ���åȤ�ꥻ�åȤ�����ˤ���¾�� �ץ��������°����ꥻ�åȤ��ơ����ꥸ�ʥ�Ρ� �⤷���ϰ����ʴ��Τ��ͤؤ��ᤷ�ޤ��� ���줫���Ϥ䲿�����̤Υѡ��ߥå�������äƤ��ʤ��ҥץ������� C �ʤɤΥ����ƥॳ�����¹Ԥ��ޤ��� �ե������ѥ��פϿƥץ����������㤤�ø��θ��Ǽ¹Ԥ���Ƥ��� �ҥץ������ǥ����ץ󤵤줿�Τǡ����٤��ǤϤʤ��褦�ʤ��Ȥ� ���ޤ����Ƥ����ʤ����ȤϤǤ��ޤ��� =begin original Here's a way to do backticks reasonably safely. Notice how the C is not called with a string that the shell could expand. This is by far the best way to call something that might be subjected to shell escapes: just never call the shell at all. =end original �ʲ��˼����Τϡ������˵ե������Ȥ�Ԥ���ˡ�Ǥ��� �ɤΤ褦�ˤ��� C �ϥ����뤬Ÿ�����뤫�⤷��ʤ�ʸ�����ȼ�ä� �ƤӽФ���ʤ��褦�ˤʤäƤ��뤫�����ܤ��Ƥ��������� ����ϥ�����򥨥������פ�����Ū�ˤϺ�������ˡ�Ȥ����櫓�ǤϤ���ޤ��� �����ñ�ˡ��������ƤӽФ��ʤ��Ȥ��������Ǥ��� use English '-no_match_vars'; die "Can't fork: $!" unless defined($pid = open(KID, "-|")); if ($pid) { # parent while () { # do something } close KID; } else { my @temp = ($EUID, $EGID); my $orig_uid = $UID; my $orig_gid = $GID; $EUID = $UID; $EGID = $GID; # Drop privileges $UID = $orig_uid; $GID = $orig_gid; # Make sure privs are really gone ($EUID, $EGID) = @temp; die "Can't drop privileges" unless $UID == $EUID && $GID eq $EGID; $ENV{PATH} = "/bin:/usr/bin"; # Minimal PATH. # Consider sanitizing the environment even more. exec 'myprog', 'arg1', 'arg2' or die "can't exec myprog: $!"; } =begin original A similar strategy would work for wildcard expansion via C, although you can use C instead. =end original C ������˻Ȥ����Ȥ��Ǥ���ˤ��Ƥ⡢Ʊ�ͤ���ά�� C �� �̤����磻��ɥ����ɤ�Ÿ���Ǥ�ͭ���Ǥ��� =begin original Taint checking is most useful when although you trust yourself not to have written a program to give away the farm, you don't necessarily trust those who end up using it not to try to trick it into doing something bad. This is the kind of security checking that's useful for set-id programs and programs launched on someone else's behalf, like CGI programs. =end original ���������ϡ�����򤯤�Ƥ�� (give away the farm) ����Υץ������� ���Ҥ��뤳�Ȥ�ʬ���Ȥ�Ǥ���ʤ��Ȥ������ȤǤϤʤ��ơ� �ǽ�Ū�ˤ����Ĥ��ä��ɤ���̤ʤˤ���Ԥ����Ȥ��Ƥ�����줫�� ���ꤹ��ɬ�פ��ʤ��Ȥ����Ȥ��˺Ǥ������ʤ�ΤǤ��� ����ϡ�set-id �ץ������䡢CGI �ץ������Τ褦��ï���� �����Ѥ�äƵ�ư�����褦�ʥץ������������ʥ������ƥ������å��Ǥ��� =begin original This is quite different, however, from not even trusting the writer of the code not to try to do something evil. That's the kind of trust needed when someone hands you a program you've never seen before and says, "Here, run this." For that kind of safety, you might want to check out the Safe module, included standard in the Perl distribution. This module allows the programmer to set up special compartments in which all system operations are trapped and namespace access is carefully controlled. Safe should not be considered bullet-proof, though: it will not prevent the foreign code to set up infinite loops, allocate gigabytes of memory, or even abusing perl bugs to make the host interpreter crash or behave in unpredictable ways. In any case it's better avoided completely if you're really concerned about security. =end original �������ʤ��顢������ɤ���̤ʤˤ���Ԥ����Ϥ��ʤ������ɤκ�Ԥ� ���Ѥ��ʤ��Ȥ������ȤȤ����餫�˰㤤�ޤ��� �����ï�������ץ������򤢤ʤ������ޤǸ������ȤΤʤ��褦�ˤ����ä� �֤ۤ顢�����¹Ԥ��ơפȸ��碌��褦�ʤȤ���ɬ�פʼ���ο��ѤǤ��� ���μ�ΰ������Τ���ˡ�Perl �����ۥѥå�������ɸ��Ǵޤޤ�Ƥ��� Safe �⥸�塼�������å������ۤ����������⤷��ޤ��� ���Υ⥸�塼��ϥץ�����ޡ������٤ƤΥ����ƥ�����ȥ�åפ��� ̾�����֤Υ������������տ������椵���褦�� ���̤ʻ��ڤ�(compartment)�򥻥åȥ��åפ��뤳�Ȥ�����ޤ��� ������ Safe �����ƤǤ���ȹͤ���٤��ǤϤ���ޤ���: ̵�¥롼�ס� �������Х��Ȥ�Υ��������ơ��ۥ��ȥ��󥿥ץ꥿�򥯥�å����ͽ¬��ǽ�� �����񤤤򤵤��뤿��� perl �ΥХ��ΰ��Ѥ򤹤볰�������ɤ����ɤ��ޤ��� �����˥������ƥ��Τ��Ȥ�ͤ���ʤ�ɤξ��ⴰ�����ɤ��������ɤ��Ǥ��� =head2 Security Bugs (�������ƥ��Х�) =begin original Beyond the obvious problems that stem from giving special privileges to systems as flexible as scripts, on many versions of Unix, set-id scripts are inherently insecure right from the start. The problem is a race condition in the kernel. Between the time the kernel opens the file to see which interpreter to run and when the (now-set-id) interpreter turns around and reopens the file to interpret it, the file in question may have changed, especially if you have symbolic links on your system. =end original ������ץȤ�Ʊ�����餤��������̤ʸ��¤򥷥��ƥ��Ϳ���� ���ޤ��������������¾�ˡ�¿���� UNIX �Ǥϡ�set-id ���줿������ץȤ� �ܼ�Ū�˰����Ǥʤ�������ǽ餫����äƤ��ޤ��� ��������Ȥϡ������ͥ�ˤ����붥����Ǥ��� ���󥿡��ץ꥿����¹Ԥ��뤿��˥����ͥ뤬�ե�����򥪡��ץ󤹤�Τȡ� (set-id ���줿)���󥿡��ץ꥿������ư���ƥե�������᤹�뤿��� ���٥����ץ󤹤뤽�δ֤ˡ�����Υե����뤬�ѹ�����뤫�⤷��ޤ��� �äˡ��ȤäƤ��륷���ƥब����ܥ�å���󥯤򥵥ݡ��Ȥ��Ƥ�����ˤϡ� =begin original Fortunately, sometimes this kernel "feature" can be disabled. Unfortunately, there are two ways to disable it. The system can simply outlaw scripts with any set-id bit set, which doesn't help much. Alternately, it can simply ignore the set-id bits on scripts. =end original �����ʤ��Ȥˡ����Υ����ͥ�Ȼ��͡ɤϻ��ѶػߤˤǤ��뤳�Ȥ⤢��ޤ��� ��ǰ�ʤ��Ȥ˶ػߤˤ���ĤΤ����������ޤ��� �����ƥ�� set-id �ӥåȤ����åȤ���Ƥ��륹����ץȤ�ñ��˶ػߤ��뤳�Ȥ� �Ǥ��ޤ��������ΤȤ��Ϥʤˤ�Ǥ��ޤ��� �⤦��ġ�������ץȤ��դ���줿 set-id �ӥåȤ�ñ��� ̵�뤷�Ƥ��ޤ����Ȥ��Ǥ��ޤ��� =begin original However, if the kernel set-id script feature isn't disabled, Perl will complain loudly that your set-id script is insecure. You'll need to either disable the kernel set-id script feature, or put a C wrapper around the script. A C wrapper is just a compiled program that does nothing except call your Perl program. Compiled programs are not subject to the kernel bug that plagues set-id scripts. Here's a simple wrapper, written in C: =end original ��������kernel set-id ������ץȵ�ǽ���ػߤ���Ƥ��ʤ���С�Perl �� ���ʤ��� set-id ������ץȤϰ����ǤϤʤ��Ȥ䤫�ޤ�����ĥ���뤳�ȤǤ��礦�� ���ΤȤ������ʤ��� kernel set-id ������ץȵ�ǽ��ػߤ��뤫�� ������ץȤ� C �Υ�åѡ������Ǥ��ޤ����Τ����줫��ɬ�פǤ��� C ��åѡ��ϡ�Perl �ץ�������ƤӽФ����Ȥ�����Ƥ� ���⤷�ʤ��ץ������Ǥ��� ����ѥ��뤵�줿�ץ������� set-id ���줿������ץȤ˴ؤ��� �����ͥ�ΥХ��ˤϱƶ�����ޤ��� ������ϡ�C �ǽ񤤤�ñ��ʥ�åѡ��Ǥ�: #define REAL_PATH "/path/to/script" main(ac, av) char **av; { execv(REAL_PATH, av); } =begin original Compile this wrapper into a binary executable and then make I rather than your script setuid or setgid. =end original ���Υ�åѡ��򥳥�ѥ��뤷�Ƽ¹ԥե�����ˤ���������ץȤǤϤʤ� I<���μ¹ԥե�����> �� setuid ������ setgid ���ޤ��� =begin original In recent years, vendors have begun to supply systems free of this inherent security bug. On such systems, when the kernel passes the name of the set-id script to open to the interpreter, rather than using a pathname subject to meddling, it instead passes I. This is a special file already opened on the script, so that there can be no race condition for evil scripts to exploit. On these systems, Perl should be compiled with C<-DSETUID_SCRIPTS_ARE_SECURE_NOW>. The F program that builds Perl tries to figure this out for itself, so you should never have to specify this yourself. Most modern releases of SysVr4 and BSD 4.4 use this approach to avoid the kernel race condition. =end original ��ǯ���٥�����Ϥ��Τ褦�ʥ������ƥ��Х����Ф��������������������ƥ�� �󶡤��Ϥ���ޤ����� ���Τ褦�ʥ����ƥ�Ǥϡ����󥿡��ץ꥿����ư���뤿��˥����ͥ�� set-id ������ץȤ��Ϥ��줿�Ȥ��ˤ��Υѥ�̾�򤽤Τޤ޻Ȥ��ΤǤϤʤ��� ����� I ���Ϥ��ޤ��� ����ϥ�����ץȤǤϡ����餫���ᥪ���ץ󤵤�Ƥ������̤ʥե�����Ǥ����顢 �ٰ��ʥ�����ץȤ򤳤�����뤿��ˤĤ������ȤϤǤ��ޤ��� �������ä������ƥ�ˤ����Ƥϡ�Perl �� C<-DSETUID_SCRIPTS_ARE_SECURE_NOW> ���ղä��ƥ���ѥ��뤹�٤��Ǥ��礦�� Perl ���ۤ��� F �ץ������ϼ�ʬ���ȤǤ���� ���Ĥ��Ф����Ȥ���Τǡ����ʤ������̤ʲ����򤷤ʤ���Фʤ�ʤ��� �Ȥ������ȤϤ��ꤢ�ޤ��� SysVr4 �κǶ�Υ�꡼���ΤۤȤ�ɤ� BSD4.4 �� ���Υ��ץ������򥫡��ͥ�ζ�������򤱤뤿��˻ȤäƤ��ޤ��� =head2 Protecting Your Programs (���ʤ��Υץ���������) =begin original There are a number of ways to hide the source to your Perl programs, with varying levels of "security". =end original �����ǵ󤲤�Τϡ����ʤ��� Perl �ץ������Υ����������ɤ򤵤ޤ��ޤ� �ȥ������ƥ��ɤΥ�٥�DZ�����ˡ�Ǥ��� =begin original First of all, however, you I take away read permission, because the source code has to be readable in order to be compiled and interpreted. (That doesn't mean that a CGI script's source is readable by people on the web, though.) So you have to leave the permissions at the socially friendly 0755 level. This lets people on your local system only see your source. =end original �������ޤ��ǽ�ˤ��äƤ����ޤ����������������ɤ��ɤ߹��߸��¤� ��Ȥ����Ȥ� B<�Ǥ��ޤ���>�� �ʤ��ʤ顢�����������ɤϡ�����ѥ���䥤�󥿡��ץ�åȤ��뤿��� �ɤ��褦�ˤʤäƤ��ʤ���Фʤ�ʤ�����Ǥ�(����ϡ�CGI ������ץȤΥ������� web �����ѼԤ��鸫�뤳�Ȥ��Ǥ��ʤ��Ȥ����ΤȤϰ㤤�ޤ�)�� ���Τ��ᡢ�ѡ��ߥå����� 0755 ��٥�ˤ��Ƥ����ʤ���Фʤ�ʤ��ΤǤ��� ����ˤ�äƤ��ʤ��Υ������륷���ƥ��Υ桼�����Ϥ��ʤ��Υ������� ���뤳�Ȥ����ˤʤ�ޤ��� =begin original Some people mistakenly regard this as a security problem. If your program does insecure things, and relies on people not knowing how to exploit those insecurities, it is not secure. It is often possible for someone to determine the insecure things and exploit them without viewing the source. Security through obscurity, the name for hiding your bugs instead of fixing them, is little security indeed. =end original �����ο�ã�Ϥ���򥻥����ƥ��������Ǥ���ȹͤ��Ƥ��ޤ��� ���ʤ��Υץ�����ब�����Ǥʤ����Ȥ�ԤäƤ��ơ� ¾�ͤ��������ä��������ƥ��η�֤򤳤���������ˡ���Τ�ʤ����Ȥ� ��äƤ���Τʤ顢����ϰ����ǤϤʤ��ΤǤ��� ����Ϥ���ͤ������Ǥʤ����Ȥ���򸫤Ĥ������� �������򸫤뤳�Ȥʤ��ˤ���򤳤������뤳�Ȥ��װ��Ȥʤ�ޤ��� ���������̤����������ƥ��ϥХ���ľ���ΤǤϤʤ��������Ȥ���٤�С� �������ƥ���ۤ�ξ��������������Ĥ��ޤ��� =begin original You can try using encryption via source filters (Filter::* from CPAN, or Filter::Util::Call and Filter::Simple since Perl 5.8). But crackers might be able to decrypt it. You can try using the byte code compiler and interpreter described below, but crackers might be able to de-compile it. You can try using the native-code compiler described below, but crackers might be able to disassemble it. These pose varying degrees of difficulty to people wanting to get at your code, but none can definitively conceal it (this is true of every language, not just Perl). =end original �������ե��륿��(CPAN �ˤ��� Filter::*, or Filter::Util::Call and Filter::Simple since Perl 5.8) ���̤��ưŹ沽���褦�� ���뤳�ȤϤǤ��ޤ���������å�������������沽���뤳�Ȥϲ�ǽ�Ǥ��礦�� ������������Х��ȥ����ɥ���ѥ��顼�ȥ��󥿡��ץ꥿����Ȥ����Ȥ� �Ǥ��ޤ���������å����Ϥ����ե���ѥ��뤹�뤳�Ȥ��Ǥ��뤫�⤷��ޤ��� �ͥ��ƥ��֥����ɥ���ѥ��顼��Ȥ����Ȥ��Ƥ⡢����å����Ϥ���� �ե�����֥�Ǥ��뤫�⤷��ޤ��� �������ä����Ȥϡ�¾�ͤ����ʤ��� �ץ�������������褦�Ȥ��뤳�Ȥ��񤷤������ꤷ�ޤ����� �ץ����������Ū�˱������Ȥ�ï�ˤ�Ǥ��ʤ��ΤǤ�(���Τ��Ȥϡ� Perl �˸¤餺���٤Ƥθ���ˤ��ƤϤޤ�ޤ�)�� =begin original If you're concerned about people profiting from your code, then the bottom line is that nothing but a restrictive license will give you legal security. License your software and pepper it with threatening statements like "This is unpublished proprietary software of XYZ Corp. Your access to it does not give you permission to use it blah blah blah." You should see a lawyer to be sure your license's wording will stand up in court. =end original ¾�ͤ����ʤ��Υץ�����फ����������פˤĤ��Ƶ��ˤ��Ƥ���ΤǤ���С� ���¤Ĥ��饤���󥹤����ʤ���ˡŪ�ʰ�����Ϳ����Ǥ��礦�� ���ʤ��Υ��եȥ������Υ饤���󥹤ˡ����ܥ��եȥ������� XYZ Corp.�ˤ�롢 ��ɽ����Ƥ��ʤ�����Ū���եȥ������Ǥ��� ���ʤ������Ѥ��뤿��� ����˥����������뤳�Ȥϵ��Ĥ���Ƥ��餺�����ɤΤ褦�ʶ���ʸ��� �դ��Ƥ����ޤ��� ���ʤ��Υ饤���󥹤�ʸ����ˡ��dzμ¤�ͭ���ʤ�ΤȤʤ�褦�ˡ� �۸�Τ����̤����ۤ����ɤ��Ǥ��礦�� =head2 Unicode =begin original Unicode is a new and complex technology and one may easily overlook certain security pitfalls. See L for an overview and L for details, and L for security implications in particular. =end original Unicode �Ͽ�������ʣ���ʵ��Ѥǡ������Υ������ƥ���櫤��ñ�� ����Ȥ��Ƥ��ޤ��ޤ��� ���פˤĤ��Ƥ� L �򡢾ܺ٤ˤĤ��Ƥ� L �� �������ä˥������ƥ������ˤĤ��Ƥ� L �򻲾Ȥ��Ƥ��������� =head2 Algorithmic Complexity Attacks (���르�ꥺ��Ūʣ��������) =begin original Certain internal algorithms used in the implementation of Perl can be attacked by choosing the input carefully to consume large amounts of either time or space or both. This can lead into the so-called I (DoS) attacks. =end original Perl �μ����ǻȤ��Ƥ��뤢�����������르�ꥺ��ϡ�¿���λ��֤� ���֤���񤹤�褦�����տ������򤵤줿���Ϥˤ�äƹ����ǽ�Ǥ��� ����ˤ�� I<�����ӥ�����(Denial of Service)> (DoS) ����ȸƤФ�Ƥ��� ��Τ�������������Ȥ��Ǥ��ޤ��� =over 4 =item * =begin original Hash Function - the algorithm used to "order" hash elements has been changed several times during the development of Perl, mainly to be reasonably fast. In Perl 5.8.1 also the security aspect was taken into account. =end original �ϥå���ؿ� - �ϥå������Ǥ���¤٤�פ���˻Ȥ��륢�르�ꥺ��� Perl �γ�ȯ���(��Ȥ��ƹ�®���Τ����)�����ѹ�����Ƥ��ޤ��� Perl 5.8.1 �Ǥϥ������ƥ���¦�̤��θ����Ƥ��ޤ��� =begin original In Perls before 5.8.1 one could rather easily generate data that as hash keys would cause Perl to consume large amounts of time because internal structure of hashes would badly degenerate. In Perl 5.8.1 the hash function is randomly perturbed by a pseudorandom seed which makes generating such naughty hash keys harder. See L for more information. =end original 5.8.1 ������ Perl �Ǥϡ��ϥå����������¤���������뤿��� Perl �� ���̤λ��֤���񤹤뤳�Ȥˤʤ�褦�ʥϥå��奭���Ȥʤ�ǡ����� ���ʤ��ñ�������Ǥ��ޤ����� Perl 5.8.1 �ǡ����Τ褦�ʤ褯�ʤ��ϥå��奭������������Τ����񤷤� ���뤿��ˡ��ϥå���ؿ��ϵ�������μ�ˤ�äƥ���������¤���ޤ��� ����ʤ����ˤĤ��Ƥ� L �򻲾Ȥ��Ƥ��������� =begin original In Perl 5.8.1 the random perturbation was done by default, but as of 5.8.2 it is only used on individual hashes if the internals detect the insertion of pathological data. If one wants for some reason emulate the old behaviour (and expose oneself to DoS attacks) one can set the environment variable PERL_HASH_SEED to zero to disable the protection (or any other integer to force a known perturbation, rather than random). One possible reason for wanting to emulate the old behaviour is that in the new behaviour consecutive runs of Perl will order hash keys differently, which may confuse some applications (like Data::Dumper: the outputs of two different runs are no longer identical). =end original Perl 5.8.1 �Ǥϥ���������¤ϥǥե���ȤǼ¹Ԥ���Ƥ��ޤ������� 5.8.2 �������������Ū�ʥǡ����������򸡽Ф����Ȥ��ˤΤ���Ω�����ϥå���� �Ȥ��ޤ��� �⤷���餫����ͳ�ǸŤ������񤤤򥨥ߥ�졼�Ȥ�����(������ DoS ����� �椬�Ȥ򻯤�����)���ϡ��ݸ��̵���ˤ��뤿��� PERL_HASH_SEED �Ķ��ѿ��� 0 (���뤤�ϥ�����ǤϤʤ����Τ����¤˶������������Ϥ���¾��Ǥ�դ� ����) ������Ǥ��ޤ��� �Ť������񤤤򥨥ߥ�졼�Ȥ�������ͳ�β�ǽ���ΰ�ĤȤ��Ƥϡ������� �����񤤤Ǥϡ�Perl �򲿲��¹Ԥ���ȥϥå��奭���ν�������ۤʤ�Τǡ� ����ˤ�äƺ��𤹤륢�ץꥱ������󤬤��뤫��Ǥ� (�㤨�� Data::Dumper: 2 ��¹Ԥ�����̤Ϥ�Ϥ�Ʊ��ˤʤ�ޤ���)�� =begin original B, and the ordering has already changed several times during the lifetime of Perl 5. Also, the ordering of hash keys has always been, and continues to be, affected by the insertion order. =end original B ����Perl 5 �� �֤Ǥ���˲��٤��ѹ�����Ƥ��ޤ��� �ޤ����ϥå��奭���ν���ϡ����ޤǤ⤳�줫��⡢������˱ƶ�������ޤ��� =begin original Also note that while the order of the hash elements might be randomised, this "pseudoordering" should B be used for applications like shuffling a list randomly (use List::Util::shuffle() for that, see L, a standard core module since Perl 5.8.0; or the CPAN module Algorithm::Numerical::Shuffle), or for generating permutations (use e.g. the CPAN modules Algorithm::Permute or Algorithm::FastPermute), or for any cryptographic applications. =end original �ޤ����ϥå������Ǥν���ϥ����ಽ����ޤ��������Ρֵ�������פ� �ʲ��Τ��Ȥ� B<�Ȥ��٤��ǤϤ���ޤ���>: �ꥹ�Ȥ������� ����åե뤹��褦�ʥ��ץꥱ������� (Perl 5.8.0 ����ɸ��⥸�塼��ȤʤäƤ��� L �� List::Util::shuffle() �䡢CPAN �⥸�塼��Ǥ��� Algorithm::Numerical::Shuffle ��ȤäƤ�������)�� ��������� (CPAN �⥸�塼��Ǥ��� Algorithm::Permute �� Algorithm::FastPermute �� �ȤäƤ�������)��������Ź楢�ץꥱ������� =item * =begin original Regular expressions - Perl's regular expression engine is so called NFA (Non-deterministic Finite Automaton), which among other things means that it can rather easily consume large amounts of both time and space if the regular expression may match in several ways. Careful crafting of the regular expressions can help but quite often there really isn't much one can do (the book "Mastering Regular Expressions" is required reading, see L). Running out of space manifests itself by Perl running out of memory. =end original ����ɽ�� - Perl ������ɽ�����󥸥�� NFA (Non-deterministic Finite Automaton: �������ͭ�¥����ȥޥȥ�)�ȸƤФ졢�����¾�Τ�Τ���٤ơ��⤷����ɽ���� ʣ������ˡ�ǥޥå��󥰤����硢���ʤ��ñ�����̤λ��֤ȶ��֤� ���񤹤뤳�Ȥ��̣���ޤ��� ����ɽ�������տ������ۤ��뤳�ȤϽ����ˤʤ�ޤ��������ʤ�ξ�礳��� �Խ�ʬ�Ǥ� ("Mastering Regular Expressions" �Ȥ����ܤ��ɤ�ɬ�פ�����ޤ�; L �򻲾Ȥ��Ƥ�������)�� ���֤���­�� Perl ��������­�ˤʤ뤳�Ȥ����餫�ˤʤ�ޤ��� =item * =begin original Sorting - the quicksort algorithm used in Perls before 5.8.0 to implement the sort() function is very easy to trick into misbehaving so that it consumes a lot of time. Starting from Perl 5.8.0 a different sorting algorithm, mergesort, is used by default. Mergesort cannot misbehave on any input. =end original ������ - 5.8.0 ������ Perl �� sort() �ؿ���������뤿��˻Ȥ��Ƥ��� �����å������ȥ��르�ꥺ��ϡ����̤λ��֤���񤹤�褦�ʺ�ά���ȤƤ� ��ñ�Ǥ��� Perl 5.8.0 ���顢�ۤʤä������ȥ��르�ꥺ��Ǥ���ޡ��������Ȥ� �ǥե���ȤǻȤ��Ƥ��ޤ��� �ޡ��������Ȥ����ϥǡ����ˤ�äƱƶ�������ޤ��� =back =begin original See L for more information, and any computer science textbook on algorithmic complexity. =end original ����ʤ����ˤĤ��Ƥ� L ����ӡ� ���르�ꥺ��Ūʣ�����˴ؤ�����󹩳ؤζ��ʽ�򻲾Ȥ��Ƥ��������� =head1 SEE ALSO =begin original L for its description of cleaning up environment variables. =end original L �ˤϴĶ��ѿ�������������ˡ�����Ҥ���Ƥ��ޤ��� =begin meta Translate: KIMURA Koichi (5.005_03) Update: SHIRAKATA Kentaro (5.6.1-) Status: completed =end meta