Cookie HttpOnly flag 설정방법 혹시 아시는 분 계시나요? ㅠ; 정보
Cookie HttpOnly flag 설정방법 혹시 아시는 분 계시나요? ㅠ;본문
웹취약성보완 작업을 진행중인데요. ㅠ 이작업을 처음해본거라 거진 구글링하면서 진행중인데.
쿠키설정에서 하이재킹?? 변조 할 가능성이 있다고 해서 HttpOnly flag 설정을 해주라고 하네요..
구글에 뒤져보니깐 대부분 설정방법이 setCookie 부터 나와있어서 제꺼 코드와 어떻게 맞는지 모르겠어요. ㅠ
그 웹취약성점검하는 툴로 웹사이트 돌려보고 나온 결과물인데, 하단의 코드에서 HttpOnly flag 설정을 해주라고 하는군요 . 고수분들의 조언 부탁드립니다. ㅠㅠ
function getCookie(name)
{
var nameOfCookie = name + "=";
var x = 0;
while ( x <= document.cookie.length )
{
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie )
{
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )endOfCookie = document.cookie.length;
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 )break;
}
return "";
}
쿠키설정에서 하이재킹?? 변조 할 가능성이 있다고 해서 HttpOnly flag 설정을 해주라고 하네요..
구글에 뒤져보니깐 대부분 설정방법이 setCookie 부터 나와있어서 제꺼 코드와 어떻게 맞는지 모르겠어요. ㅠ
그 웹취약성점검하는 툴로 웹사이트 돌려보고 나온 결과물인데, 하단의 코드에서 HttpOnly flag 설정을 해주라고 하는군요 . 고수분들의 조언 부탁드립니다. ㅠㅠ
function getCookie(name)
{
var nameOfCookie = name + "=";
var x = 0;
while ( x <= document.cookie.length )
{
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie )
{
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )endOfCookie = document.cookie.length;
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 )break;
}
return "";
}
댓글 전체
HttpOnly Cookie 는 클라이언트쪽 위조 방지를 위해 클라언트 측에서 생성할 수 없구요 서버측에서만 생성할 수 있는 걸로 알고 있는데요 PHP라면 session.cookie_httponly = True 또는 php.ini에서 설정가능합니다