웹마스터 팁

미리 몇가지 URL 을 첨부한다.

http://kr.php.net/configuration.changes
http://www.php.net/register_globals
http://www.php.net/apache

PHP register globals 옵션에 대한 개별적용

그동안 get 과 post 방식으로 변수를 받을때의 보안문제로 인하여 register_globals
옵션을 off 로 하는것이 정설이었다.
post 방식으로 받아야하는 변수를 get 으로도 받게 되었을때 변수조작이 가능하기 때문이다.
post 방식은 <input> 을 이용하여 form 값을 넘겨받는 방식이며 get 방식은
URL 뒤에 값을 첨부하는 방식이다.

몇가지 문서 및 php.net 을 뒤져본결과 register_globals (전역등록) 에 관한 몇가지
옵션 및 Tip 을 찾을수 있었다.
이미 php.net 의 register_globals 에 대해서 많은 comment 가 달려있었다.

그중 내가 관심을 가지는 부분은 php 옵션에 대한 개별 적용이다.
나는 register_globals 를 on 하고싶은데 서버관리자의 정책은 그렇지 않을경우
변수를 extract 해야하는 수고를 겪을수도 있다.
물론 이 상황은 보안에 민감하지 않은 프로그램을 운용시 해당한다.

.htaccess 파일을 이용하여 php 옵션을 개별적으로 적용할수 있었다.
또한 php script 의 선택적 구동 (어떤사용자는 php 를 parsing 가능하게하고 그렇지 못하게하는경우)
도 가능했다.

---------------------어떤 사람의 코멘트----------------------------------------------------
If you are on a vhost with register_globals=on (like me):
You can include in your .htaccess
  php_flag register_globals off
(just like Arjan proposed with "on") to increase your local security.
--------------------------------------------------------------------------------------------

즉 자기 계졍의 httpd Root 에(ex.public_html) .htaccess 파일을 생성하고
그 안의 내용을 상기와 같게 하면 된다는 것이다.

php_flag register_globals [off|on]

단 이에는 다음과 같은 조건이 따른다.

---------------------어떤 사람의 코멘트----------------------------------------------------
On the note about putting "php_flag register_globals on" in your .htaccess to allow a transition period:

You must have something like this in your httpd.conf file for that to work.

<Directory /whatever/>
    AllowOverride Options
</Directory>

(AllowOverride All will also work.)

Took me a while to dig that out of the manual, so I thought I'd post it.

--RJ
--------------------------------------------------------------------------------------------

httpd.conf 에서 allowoverride 옵션을 넣어줘야한다는것.

또는 가상호스팅에 적용하기위해 다음의 경우를 생각할수도 있다.

---------------------어떤 사람의 코멘트----------------------------------------------------
It's possible to set register_globals to "off" on a site-by-site basis via Apache, thus overriding the "global" setting of register_globals in php.ini:

In httpd.conf:

<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot /var/www/html/mysite
php_value register_globals 0 (or 1 for "on")
</VirtualHost>
That way, sites with old code can have register globals turned on, but for all new developments it will be disabled.
--------------------------------------------------------------------------------------------


---------------------어떤 사람의 코멘트----------------------------------------------------
If you're using global variables to cope with access levels within your interactive website or application,
the safe way is to store the username and password used in the cookies and verify it on every page by having
the same auth code included.

That way the only hacking that can be done is packet interception to grab passwords
(SSL if you're worried about that) or somebody hacking someone else's cookies in IE or something by getting
to their computer. (IE settings might have a fix for this although if IE is using SSL to get a cookie one
would hope it encrypts the stored data but you never know...)

I think reg_global_vars is like any other tool, its only a security risk if you use it unaware of the possibilities.
For non-security related variables its a quick and convenient tool, and for security related ones its something to
be worked around or avoided.
--------------------------------------------------------------------------------------------

보안을 염려하는 사람의 글도 볼수 있었다.

---------------------어떤 사람의 코멘트----------------------------------------------------
Not using the registers, I would assume that this example would also prevent a hacker from
changing the username via POST or GET, since I am setting the username cookie and hash cookie
for the entire session. The cookies are only set once and the hash key is known only to me.

Example:

// Do all this before the html header - php post self
// User gave his/her username and pressed submit.
$hidden_hash_var = 'this_is_your_secret_hash_key';
if ($username) { // valid login - set cookie now for session
    $id_hash= md5($username.$hidden_hash_var);
        $secure = 1; // 1 for https - use 0 for http
        $site = $HTTP_HOST; // your site
  setcookie("username","$username",0,"/","$site",$secure);
  setcookie("id_hash","$id_hash",0,"/","$site",$secure);
     }

// check to see if the user is logged in (cookie set and hash matches)
$LOG_IN = 0;
if ($username && $id_hash) { // Checks each post
    $hash=md5($username.$hidden_hash_var);
    if ($hash == $id_hash) {
        $LOG_IN = 1; // they'd have to guess this var
          }
      }
// end - if i'm mistaken let me know. 12/2002
--------------------------------------------------------------------------------------------

자신의 tip 을 소개하였다.
제목 글쓴이 날짜
레드햇, 새 리눅스SW 출시 ATpple.com 2003.10.28
호스팅 업체에서 제공하는 에러메세지 표시를 개성적으로 바꾸자! [12] file 이주성 2003.10.25
익스체인지 서버 취약점으로 인한 임의 코드 실행 문제 ATpple.com 2003.10.24
개인서버를만들어보자!(1편 유저생성)(동영상강좌) [8] 타키 2003.10.22
한글이름 그림을 위한 Apache 설정 [2] 김영일 2003.10.23
외부에서 리눅스 텔넷 연결 [4] 화니 2003.10.21
Buffer Overrun in Messenger Service 취약점 [1] ATpple.com 2003.10.20
안전한 FTP, vsftpd 설치와 운영 (한글로그 패치 포함) [1] 좋은진호 2003.10.15
유동아이피로 고정아이피 만들수있는 유틸 [27] 론건맨 2003.10.10
OpenSSL(SSL/TLS)의 ASN.1 라이브러리 다중 취약점 ATpple.com 2003.10.07
IIS6 + Mysql 안돌아 가신다거나 PHP 빨간불 들어오시는님들 읽어주셔요^^* [7] 남정웅 2003.09.26
apache-1.3.28 release [5] 아치™ 2003.09.19
Register_globals 옵션의 개별적용 및 그에관한 tip Dopesoul 2003.09.13
Apache 에서 DoS 공격 막기 (1.3.x, 2.x) 좋은진호 2003.09.08
[강력추천!!] 윈도우에서 아파치,MySql,PHP 돌리기! - apmsetup.com [10] 별빛부셔 2003.09.05
블래스터 웜 바이러스 서버에서 차단하기 [3] 장지현 2003.08.31
[동영상] iis 5.1 + PHP 4.3.2 + MySQL 4.0.13 + 제로보드 4.1 pl4 설치 [48] 비행소년™ 2003.08.25
Windows 2000의 NAT를 이용한 인터넷 공유 서버 구축 [2] 굿스피드 2003.08.20
/home에 있는 계정을 계정별로 따로 백업하는 스크립트 [2] 뽀뽀팅이 2003.08.15
Windows2000 Ad Server 계열쓰시는분들의 보안. [7] 씨파개 2003.08.12