Cross-Site Scripting Prevention with Dynamic Data Tainting

Download Report

Transcript Cross-Site Scripting Prevention with Dynamic Data Tainting

Cross-Site Scripting Prevention with Dynamic Data Tainting and Static Analysis

신대용 [email protected]

논문 요약

• taint 방식 – 보호되어야할 중요한 정보들을 체크해 놓고 그 정보들이 다른 제3의 위치로 보내지지 않 도록 한다.

– – 또한 이것을 속이는 행위들에 대하여 안전해 야한다.

firefox를 수정하여 구현한다.

논문 요약

• • • • Dynamic, Static 두 가지 방식으로 tainting 을 한다.

중요한 자료가 다른 위치로 전송되는 것을 막기 위해 전송에 관련된 객체들을 관리 파이어 폭스를 개량하여 구현 자동, 수동적인 방법으로 테스트한다.

agenda

• • • • • • • • Introduce Related work Dynamic Data Tainting Static Data Tainting Data Transmission Implementaion Evaluation Conclusions

Abstract

• In the browser, this scripting code is executed and used to

transfer sensitive data to a third party

• 목적 :if not.

sensitive information

is about to be transferred to a third party, the user can decide if this should be permitted or

1.Introduction

• • Nowadays, many web sites make extensive use of client side scripts (mostly written in JavaScript) to enhance user experience. Unfortunately, this trend has also increased the popularity and frequency of cross-site scripting (XSS) attacks.

1.Introduction

• same-origin policy – mju.ac.kr에서 수행된 스크립트는 ants.mju.ac.kr 에 영향을 미칠수 없다.

• • www.mju.ac.kr

에서 만든 쿠키를 www.naver.com

에서 읽을수 없다.

XSS공격은 이러한 same-domain 정책을 우회함으로써 행해진다.

1.Introduce

• Stored XSS – 공격 코드가 DB나 기타 영구적인 장치에 삽 입된다.

• Reflected XSS – – – 정상적인 루틴에 특정 코드를 추가 함으로써 공격 URL공격 이메일에 공격 첨부

1.Introduction

• • The optimal approach to prevent XSS attacks would be to eliminate the vulnerabilities in the affected web applications.

그렇지만 시간, 금전, 너무나 다양한 공격 패턴의 존재로 인하여 막기가 어렵다.

1.Introduction

• The

goal

is to ensure that a JavaScript program can send sensitive information only to the site from which it was loaded.

2.Related Work

• • Server-side protection – perl’s taint mode – – – taint-tracking scheme anomaly-based intrusion detection Client-side protection – proxy방식 Mozilla web browser - monitor • 본 논문은 Client-side 방식이지만 더욱 깊고 정확한 분석을 한다.

3.Dynamic Data Tainting

• 중요한 데이터가 제3의 곳으로 전송되는 것 을 막기 위해서 웹 브라우저에서 데이터의 사용을 기록한다.

• 처음에 제일 중요한 데이터들을 marking하고 이 데이터를 사용하는 데이터들도 marking 해 나간다.

• 세탁 작업들에 대한 고려를 하여 우회하는 것 을 막는다.

3.Dynamic Data Tainting

• cookie 값의 세탁작업

3.1 Sensitive data sources

• 기본적으로 보호되어야 할 값들

3.2

Taint Propagation

• • • • assignments; arithmetic and logic operations (+, -, &, etc.); control structures and loops (if, while, switch, for in); function calls and eval.

3.2

Taint Propagation

• taint작업

3.2.1 Assignments

• In some cases, the variable that is assigned a tainted value is not the only object that must be tainted. • For example,if an element of an array is tainted, then the whole array object needs to be tainted as well.

3.2.2 Arithmetic and Logic Operations

The result is tainted if one of the used operands is tainted.

3.2.3 Control Structures and Loops

If the condition of a control structure tests a tainted value, a tainted scope is generated that covers the whole control structure.

• 바로 taint하지 않고 값이 수정되면 한다.

3.2.4 Function Calls and eval

• When called with tainted actual parameters, the corresponding formal parameters of the function are tainted.

3.2.5 Document Object Model (DOM) Tree

Java engine에서 벗어나는 것을 방지 하기 위해서 모든 dom node중에서 안에 taint 된 요소가 있을 경우 해당 노드도 taint되 어야 합니다.

4. Static Data Tainting

• • Dynamic한 방법에는 한계가 있다.

따라서 모든 값을 검사하는 Static data tainting을 한다.

4.1 Linear Static Taint Analyis

• • • 모든 변수를 일일이 검사하는 것은 브라우 저에있어서 큰 성능 하락을 가져 온다.

linear static analysis는 tainted된 스코프에 대해서는 통과한다.

함수 콜이나 eval에 대해서는 conservative 모드가 동작하여 tainted스코프로 간주한 다.

4.2 Stack Analysis

• • • 엔진의 스택을 모델하는 추상의 스택을 하 나 더 생성 가상의 스택은 일반 변수에 대해서는 생성 여부만 저장 객체와 배열에 대해서는 assign문의 대상 객체를 저장하기 위해서 엔진의 스택보다 더욱 많은 자료를 저장한다.

5. Data Transmission

• • • • Changing the location of the current web page by setting

document.location

Changing the source of an image in the web page.

Automatically submitting a form in the web page.

Using special objects, such as the

XMLHttpRequest

object.

6. 구현

• • • 파이어 폭스를 수정하여 구현한다.

자바스크립튼 엔지과 DOM을 수정 중요한 자료가 전송되어 질 때 사용자는 그것을 허용할지 거부할지 선택한다.

7. 평가

• • • 단순한 XSS 공격을 시도한다.

실제의 exploit에 대해 유효한지 검토 하기 위해서 실제 프로그램을 설치 하고 해당 프로그램에 대한 공격 툴을 이용한다.

– phpBB, myBB, WebCal을 설치, 수동 방법으로 수정된 브라우저로 일상적 인 웹 서핑을 한다.

7.평가

• 비록 경고가 뜨는 것이 XSS 공격이 아니더 라도 사이트 통계나 사용자의 기록을 빼가 기 위한 작업들이기 때문에 경계해야한다.

• 수동적인 방법은 우리의 제품이 효율적이 고 효과적이라는것을 보여주었지만 좀더 더욱 가치있는 자료를 위하여 파이어 폭스 에 Crawler를 붙였다.

7.평가

7.평가

• • • 전체 1,033,000개의 페이지 검색 한 도메인당 100개의 페이지 검색 88,589(8.58%)개의 페이지에서 XSS 발견 • • • 대부분 소수의 사이트들에서 나온 것 으로 발견 상위 30도메인이 유발하는 오탐만 제거해도 1.35%제거 덜 중요한 최종 수정일 들을 제외하면 더욱 오탐 을 줄 일수 있다.

7.평가

• 5289개의 쿠키값 전송의 경우도 대부분 잘 알려지지 않은 광고나 tracking 사이트 였고 cnn.com과cnn.net등의 통신인 경우 였다.

8.결론

• • XSS는 오늘날 가장 빈번한 취약점임에도 불구하고 많은 서비스 provider들은 그들 의 사용자들을 보호하려고 하지 않는다.

본 논문에서는 파이어 폭스를 수정함으로 써 클라이언트 사이드에서 이를 해결 하는 것을 제안한다..