Manuscript Offprint

arXiv:2610.30218

JANUS: Agentic Cross-Language Fuzzing Harness Generation for Android Native Libraries

Xiangyu Zhang, Yucheng Su, Lingling Fan, Yinan Li, Sen Chen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Xiangyu Zhang §†^{\S\dagger}, Yucheng Su ‡^{\ddagger}, Lingling Fan ∗†§^{*†§}, Yinan Li §^{\S}, Sen Chen §^{\S}

§^{\S}DISSec, NDST, College of Cryptology and Cyber Science, Nankai University, China

†^{\dagger}Zhongguancun Academy, China

‡^{\ddagger}Intelligence and Offensive Defense Lab, Xiaohongshu Inc., China

Abstract—Modern Android apps extensively rely on native libraries, bridging Java/Kotlin and C/C++ through the Java Native Interface (JNI). This cross-language interoperation, however, exposes the memory-safe Android Runtime to the unsafe C/C++ world, creating an attack surface that has been repeatedly exploited for full device compromise. While fuzzing is a proven technique for vetting native libraries, state-of-the-art harness generation tools struggle to faithfully capture closed-source cross-language API usage: (i) precise program analysis across the JNI boundary does not scale, whereas lightweight approximations miss critical invocation patterns; and (ii) none tackles the construction of complex composite objects consumed by JNI methods.

In this paper, we propose JANUS, the first agentic approach to synthesizing cross-language JNI-aware fuzzing harnesses for Android native libraries. JANUS iteratively resolves both explicit and implicit cross-language call dependencies to recover app-specific runtime context, and recursively assembles cross-language argument objects in a bottom-up manner. JANUS leverages an autonomous agentic workflow to reduce reliance on hand-crafted heuristics, capturing the vast landscape of hidden API usage knowledge embedded in closed-source native libraries. Evaluation on 44 popular real-world apps (such as Google and YouTube Music, covering 21,386 JNI methods total) shows that JANUS produces over 5.9×5.9\times more valid harnesses (6,094) than state-of-the-art automatic harnessing tools. On pre-installed apps from five mainstream Android vendors (e.g., Xiaomi, Vivo, Samsung), JANUS further uncovers 6 previously unknown vulnerabilities in closed-source native libraries.

Index Terms—Harness Generation, Android Native Libraries, LLM Agent

I. INTRODUCTION

Native libraries are pervasive in modern Android apps, invoked from Java/Kotlin through the Java Native Interface (JNI) for performance gains or to reuse battle-tested legacy code. This convenience, however, comes at a steep security cost: the JNI bridge re-stitches the memory-safe Android Runtime (ART) onto the unsafe C/C++ world; once loaded, a native library shares the hosting process's address space and executes under the same user ID (UID) and granted permissions, yet its memory accesses are not protected by ART's managed-memory safety guarantees [1]. Memory-corruption defects in native libraries thus reintroduce a cross-language attack surface into otherwise sandboxed processes, and have repeatedly served as launchpads for full device compromise. Most recently, this attack surface has been notably weaponized by the advanced spyware LANDFALL [2] and by the 0-click chain that Google Project Zero used to break Pixel 10 [3]. Thus, given how deeply native code is woven into today's Android ecosystem, the need for scalable approaches to vetting this fast-growing cross-language attack surface has never been more urgent.

Android native libraries have been shown by prior work [4], [5] to be effectively auditable through fuzzing. Central to this process is harness generation, i.e., synthesizing a wrapper program that performs the necessary initialization and argument construction before feeding fuzzer-generated data to the target API [6]. However, harnessing closed-source Android native libraries presents two inherent issues that have not been adequately addressed. (i) Recovering cross-language API usage knowledge related to harness synthesis is non-trivial, as it demands knowledge scattered across two languages. Two complementary aspects should be acquired for valid harnesses: call dependencies (i.e., the invocation sequence among JNIs) and argument construction (i.e., how arguments are built and passed) [4], [7], [8]. (ii) Native libraries are predominantly closed-source and privately bound to their host apps. Consequently, JNI usage patterns can be obtained neither from official documentation nor from portable examples across apps. Each app effectively defines its own private API usage conventions, making such knowledge largely non-transferable and requiring it to be recovered anew for each app [5].

In light of this, recent studies [4], [5] attempt to learn JNI usage knowledge and synthesize JNI-aware harnesses automatically. Atlas [4] performs cross-language symbolic execution and taint propagation in pursuit of precise Java↔Native data-dependency recovery, but the inherent path explosion prevents it from scaling to contemporary commercial Android apps (only 51% directly usable in its 17-vendor-app dataset). Another state-of-the-art tool, POIROT [5], takes the opposite stance, dropping native-side analysis in favor of lightweight Java-side data- and control-flow analysis to mimic each app's behavior; however, the Java-only strategy, while more scalable, sacrifices substantial precision (only 49.5% valid across ~4K apps). Both state-of-the-art artifacts share two limitations: (i) they struggle to capture cross-language API usage knowledge, facing an inherent precision-scalability trade-off in static analysis across the JNI boundary: precise cross-language analysis is notoriously hard to scale [4], while lightweight approximations tend to miss critical invocation patterns [5]; and (ii) neither addresses how

to acquire argument-construction knowledge for the complex composite objects routinely consumed by JNI methods.

Root Challenges. At the root of the predicament (prior artifacts are trapped in) lie two fundamental challenges unique to harnessing Android native libraries. c1◯\textcircled{c1} Faithfully reconstructing cross-language invocation sequences requires intricate, app-specific runtime context (e.g., Java-side argument-object instantiation and field assignment, and native-side global state and runtime handles). This process often involves missing or misordered explicit and implicit dependencies, which can readily lead to silent failures or trivially shallow execution. c2◯\textcircled{c2} Cross-language argument construction exposes a non-trivial semantic gap. JNI methods in real-world applications commonly accept complex objects (e.g., nested, user-defined composite types) whose construction logic cannot be inferred from JNI type signatures alone. Since the harness executes on the native side, these Java objects require assembly from scratch through reflection-style JNI functions [9], making it inherently challenging to reconstruct objects and capture the semantic relationship that conform to native-side expectations.

Our Approach. To overcome the inherent challenges above, we propose JANUS, an agentic approach that synthesizes far-reaching and meaningful cross-language JNI-aware harnesses. JANUS's key insights lie in two algorithms interacting with dedicated agentic workflows: To tackle C1, JANUS handles cross-language invocation sequences by treating unmet dependencies as the driving force, iteratively resolving both explicit and implicit cross-language invocation context, which spans Java-side object instantiation and native-side runtime state. To address C2, JANUS recursively decomposes complex composite objects into synthesizable primitive objects, then reassembles them bottom-up to construct the objects expected by the native side. JANUS implements core algorithms within an agentic workflow powered by Large Language Models (LLMs), capturing the JNI usage knowledge and semantic relationships between parameters, reducing reliance on brittle hand-crafted heuristics, thereby empirically mitigating the precision-scalability trade-off faced by prior work.

Agentic Design. JANUS builds an agentic workflow tailored for JNI-aware harness synthesis, in which the underlying LLMs act as autonomous agents that perform code reasoning, planning, tool invocation, and self-reflection throughout harness synthesis, rather than serving as auxiliary components in a conventional fuzzing pipeline [10], [11]. This agentic design, however, surfaces three specific challenges: (i) aimless explosion from sprawling cross-language code fragments; (ii) app-specific runtime context inconsistency over long-horizon reasoning; and (iii) hallucinations in JNI-aware harness generation. To sidestep the trap of overwhelming the LLM with sprawling cross-language code fragments and asking it to single out the critical pieces, JANUS equips the agent with a tool-augmented, structure-aware code retriever that forestalls aimless exploration. To tame context drift and hallucinations, JANUS persists verified intermediate artifacts across cross-language methods in a dedicated memory layer and closes the generation loop with a validation-guided iterative refinement that attributes failures to the responsible synthesis stage for targeted refinement.

Results. We evaluate JANUS on 21,386 JNI methods of 44 real-world Android apps against two state-of-the-art harnessing tools for Android native libraries, Atlas++ [12] and POIROT [5]. JANUS produces 7.4×/5.9×7.4 \times /5.9 \times more valid harnesses, and achieves 5.8×/6.5×5.8 \times /6.5 \times the bitmap coverage compared with Atlas++ and POIROT, respectively. These results suggest that JANUS can exercise more and deeper native code functionalities, exposing more potential security vulnerabilities and defects. JANUS further uncovers 6 previously unknown memory-corruption vulnerabilities in closed-source native libraries shipped by mainstream Android vendors (e.g., Xiaomi, Vivo, Samsung).

This paper makes the following three contributions:

• We propose JANUS, the first agentic harness-synthesis approach toward JNI-aware fuzzing of Android native libraries, paving the way for broader auto-harnessing techniques across the Java-native boundary.

• We present algorithms to guide agentic workflows for automated harness generation that resolve explicit and implicit call dependencies and recursively construct composite arguments, backed by structure-aware retrieval, validation-guided refinement, and harness memory.

• JANUS outperforms the state of the art in harness synthesis, execution validity, and code coverage, and further uncovers 6 previously unknown vulnerabilities in closed-source native libraries shipped with mainstream Android vendor apps. For future research, we have released our prototype and artifacts on GitHub [13].

References (44)