CI 묻고 답하기

제목 HP 보안테스트에서 나온 영구 쿠키에 관한 문의입니다.
글쓴이 온더탑 작성시각 2014/07/14 16:04:21
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 16107   RSS
이전에 작업했던 사이트를 업체에서 HP 보안테스트를 돌려서 나온 결과인데요.
본문은 아래와 같습니다.

영구쿠키 사용을 하지 말란 말같은데 제가 영구 쿠키를 사용 하지를 않았습니다.
세션을 사용했어서 세션쿠키에 관련된 부분이 잘못되었나 싶어서 그 부분도 딱히 문제가 안될듯 싶은데요.

config.php  설정은 아래와 같습니다.

HP에서 말하는 쿠키가 어떤 걸까요 ㅠ_ㅠ

$config['sess_cookie_name']        = 'ci_session';
$config['sess_expiration']        = 7200;
$config['sess_expire_on_close']    = FALSE;
$config['sess_encrypt_cookie']    = TRUE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = TRUE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']    = 300;
---------------------------------------------------------------------------------------
 
Cookie Security: Persistent Cookie Medium
CWE-539,CWE-613
OWASP Top 10: None
PCI 3.0: None
 
Summary
Cookies are small bits of data that are sent by the web application but stored locally in the browser. This lets the application use the cookie to pass information between pages and store variable information. The web application controls what information is stored in a cookie and how it is used. Typical types of information stored in cookies are session Identifiers, personalization and customization information, and in rare cases even usernames to enable automated logins. There are two different types of cookies: session cookies and persistent cookies. Session cookies only live in the browser's memory, and are not stored anywhere. Persistent cookies, however, are stored on the browser's hard drive. This can cause security and privacy issues depending on the information stored in the cookie and how it is accessed.
 
Explanation

Persistent cookies are stored on the browsing clients hard drive even when that client is no longer browsing the Web site that set the client. Depending on what information is stored in the cookie, this could lead to security and privacy violations. The Office of Management and Budget has decreed that no federal websites shall use persistent cookies except in very specific situations.
 
Execution

All cookies are set by the server via the Set-Cookie HTTP Header. A browser knows to store that cookie as a persistent cookie when it finds the keyword 'Expires=' followed by a date in the future. If there is no 'Expires=' tag, or if the specified date has already passed, then the browser will keep the cookie in memory only as a session cookie.

To view the persistent cookie set on this page, view the HTTP response and examine the Set-Cookie header. You should see the 'Expires=' tag with a future date specified.
 
Recommendation

All cookies are set by the server via the Set-Cookie HTTP Header. A browser knows to store that cookie as a persistent cookie when it finds the keyword 'Expires=' followed by a date in the future. If there is no 'Expires=' tag, or if the specified date has already passed, then the browser will keep the cookie in memory only as a session cookie.

To view the persistent cookie set on this page, view the HTTP response and examine the Set-Cookie header. You should see the 'Expires=' tag with a future date specified.
 
References
 다음글 안녕하세요. 폴더구조관련해서 질문드립니다. (2)
 이전글 서버 운영 측면에서 CI 디렉토리 구조에 대한 질문 하... (3)

댓글

letsgolee / 2014/07/14 17:10:34 / 추천 0
$config['sess_expire_on_close']    = TRUE;
온더탑 / 2014/07/14 19:00:05 / 추천 0
letsgolee 님 답변 감사드립니다.

이 옵션은 브라우저 창을 닫았을때 세션을 없애라는 옵션 아닌지요.

영구 쿠키를 설정하는 부분이 따로 없는거 같은데 왜 저렇게 오류로 리포팅 되었는지 모르겠네요 ㅠ_ㅠ
$config['sess_expire_on_close']    = FALSE;
letsgolee / 2014/07/14 21:56:49 / 추천 0
에구... 영어만 읽어도 답이 나옵니다. 다는 번역하기 귀챦으니 Execution 부분만 번역할께요.

"모든 쿠키는 서버에서 http header에 의해 set cookie 명령으로 설정됩니다. 브라우져는 그 쿠키에서 'Expires=' 라는 키워드와 함께 미래의 날짜가 주어진 것을 찾게되면 지속하는 쿠키로 저장해야 함을 압니다. 만일 'Expires=' 태그가 주어지지 않았거나 혹은 그 뒤에 나온 특정한 날짜가 이미 지난 날짜이면 브라우져는 그 쿠키를 세션 쿠키로 여기고 단지 메모리에 저장할 것입니다."

즉 지속성 쿠키는 브라우져를 닫아도 주어진 날짜까지 남아있는 쿠키를 말합니다. 흔히 expires=다음에 날짜를 지정하여 정합니다. 그런데 이 키워드가 없거나 혹은 브라우져를 닫으면 세션이 지워지도록 정하게 되면 그 쿠키는 메모리에만 남아있는 세션 쿠키가 됩니다. 따라서 지속성 쿠키는 이미 하드 디스크에 저장되어 있기 때문에 보안에 취약할 수 있다는 이야깁니다. 그래서 $config['sess_expire_on_close'] 값을 TRUE로 놓아야 브라우져를 닫을 때 그 페이지의 쿠키가 메모리에서 삭제되고 하드 디스크에 저장되지 않게 된다는 겁니다.