Config Editor
Last updated
Last updated
install the app and open it i found that app has an input field to write on it and the save it as yaml file
,, the sec feature is load file from the storage
Let’s Exam the Androidmanifest.xml
:
here we have a MainActivity : it’s an exported activity : with an intent filter with a View action
and have 3 schemas : file , http , https
& with a category : Browsable
& allowing users to load and save YAML
files.
after some analysis of Main Activity i found an interested Functions :
loadYaml()
: it used to open the file with the given URI and then Read the file as an input stream , then parse the YAML content file into an object
saveYaml()
: take the input we put and then Convert to Bytes: It converts the text content into a byte and writes it to a YAML file at the specified URI.
intent Handling()
: handle Intent processes intents that contain a URI to load a file, which it passes to load Yaml if valid.
after i have search about SnakeYAML library , it has a CVE-2022-1471
its a deserialization vulnerability, with versions before 2.0 allowing remote code execution when used to parse untrusted input
SnakeYAML allows the instantiation of arbitrary Java classes from untrusted YAML sources. This "insecure by default”
We have a class name called LegacyCommandUtil
this class provides a way to run arbitrary shell commands from within an Android app or Java program
we can exploit this vulnerability to pass a malicious argument to LegacyCommandUtil
and achieve RCE
Exploitation Strategy :
Craft a Malicious YAML File: that, when opened by this app, could trigger remote code execution (RCE). create an exploit.yml
file that contain this payload
RCE by kero: !!com.mobilehackinglab.configeditor.LegacyCommandUtil ["touch /data/data/com.mobilehackinglab.configeditor/kero.txt"]
push this yaml file to the external storage
then used the below adb
command to load the yml
file from the external storage (/sdcard/Download)
adb shell am start -n com.mobilehackinglab.configeditor/.MainActivity -a android.intent.action.VIEW -d "file:///sdcard/Download/exploit.yml"
and here we done