MobileHackingLab Notekeeper
Last updated
Last updated
The NoteKeeper app presents an interesting buffer overflow vulnerability challenge from Mobile Hacking Lab. This note-taking application contains a critical vulnerability that allows for remote code execution. In this writeup, I'll document my approach to analyzing and exploiting this vulnerability.
The app appears straightforward - a simple note-taking application where users can add titles and descriptions for their notes.
I used jadx-gui to decompile the APK. Examining the MainActivity revealed an interesting native method:
And the library loading code in the static initializer:
A native library means potential memory corruption vulnerabilities.
I extracted the libnotekeeper.so
file from the APK and opened it in Ghidra. After analyzing the binary, I located the corresponding JNI function:
The function's decompiled code revealed several concerning elements:
The local_2a4
buffer is fixed at 100 bytes
The copy loop uses local_4c
(the input string length) without any bounds checking
A system()
call executes a command stored in acStack_240
If I provide a string longer than 100 characters, I can overflow local_2a4
and potentially overwrite acStack_240
, which is used in the system()
call.
The vulnerability occurs because:
The title string is passed to the native parse()
function
The function copies characters from the input to a fixed-size buffer without length validation
The buffer overflow can overwrite adjacent memory, including the command string passed to system()
The stack layout suggests that acStack_240
is positioned after local_2a4
in memory, which means a sufficiently long input will overwrite the command executed by system()
.
To exploit this vulnerability, I need to: 4. Provide a title long enough to overflow the 100-byte buffer 5. Add a command injection payload that will overwrite the original command. This should execute the whoami
command and save the output to a file in the app's data directory.
To reliably inject my payload, I used Frida to hook the parse()
method:
I started Frida and attached to the NoteKeeper app:
This vulnerability exists because:
User input (the note title) is directly processed by unsafe native code
The native code performs unbounded string copying into a fixed-size buffer
The command string for system()
is located in a memory area that can be overwritten by the buffer overflow
The NoteKeeper challenge demonstrates a classic buffer overflow vulnerability in a modern Android application. By analyzing the native code and understanding the memory layout, I was able to craft an exploit that achieved remote code execution.
This reinforces the importance of secure coding practices, especially when dealing with native code in Android applications. Even in 2025, memory corruption vulnerabilities continue to be a significant security risk, particularly in applications that combine managed Java/Kotlin code with native libraries.