Anti-AIClone

Log date · Sun

Can JNI hide native code? Lessons from radare2 6.2.2

JNI alone does not hide an interface. We compare two bindings and inspect exports, signatures and registration strings.

Does moving logic to JNI hide it?

A JNI boundary alone does not establish that logic is hidden. We connected the same Java declaration to two native libraries we wrote; both calculated 171. The name-bound library exported Java_Bridge_quote. The dynamically registered library exported JNI_OnLoad instead, but still contained the three strings Bridge, quote and (I)I.

The radare2 6.2.2 notes list typed JNI table-call resolution and a new JNI analysis plugin. [1] Radare2 was unavailable here, so we use javap, clang, nm and strings to illustrate the underlying issue; this is not a test of that release, Swift or CIL.

Results for the two bindings
QuestionFinding
RuntimeBoth returned quote(3)=171.
Native exportsJava_Bridge_quote for name binding; JNI_OnLoad for registration.
Readable strings in registered libraryBridge, quote and (I)I.
Java declarationjavap shows the native method and (I)I descriptor.

What the release notes describe

Released at 17:32 UTC on 2026-09-06, 6.2.2 was codenamed infandmore; its notes cite 388 commits from 22 contributors. [1] Besides JNI, they list CIL token resolution, a generic Swift metadata class loader and recovery of Swift struct field offsets from type metadata. These address different platforms, but suggest a common review question: what clues do language boundaries and runtime structures expose?

The notes also list argument recovery, DEX exception handling, Mach-O dSYM matching and parser memory-safety fixes. They do not give recovery accuracy, so they cannot establish how much a particular transformed artifact will reveal. Treat tool output as a lead and cross-check it against source, build settings and functional tests.

One interface, two bindings

The Java side declares static native int quote(int); our sample computes 120 + 17 times its argument. The name-bound variant uses the JNI naming convention. The registered variant associates a method name, descriptor and function pointer with RegisterNatives in JNI_OnLoad. The JNI specification describes both name resolution and explicit registration. [2] We built macOS x86_64 samples with javac 17.0.19 and Apple clang 21.0.0, then ran and inspected each library.

Verbatim output; addresses belong to this build.
== named: run ==
quote(3)=171
== named: exports ==
00000000000002f0 T _Java_Bridge_quote
== named: selected strings ==
== registered: run ==
quote(3)=171
== registered: exports ==
0000000000000480 T _JNI_OnLoad
== registered: selected strings ==
Bridge
quote
(I)I

The absence of Java_Bridge_quote from the registered library’s exports does not mean that its interface information disappeared. Our registration code uses three literal strings, which strings displays. Compiler options, registration design and platform affect what remains visible. This comparison covers these two builds and cannot estimate analysis time.

Excerpt from javap: I denotes the int argument and return value.
  static native int quote(int);
    descriptor: (I)I

How to interpret the interface

The javap -s option prints internal type signatures and -private includes all members. [3] In this sample, (I)I describes one int argument and an int result; it does not itself explain the pricing rule. An export name, class name and descriptor are clues, not the same evidence as a complete algorithm.

JNI interface functions are called through a table whose entries have specified offsets. [2] This explains why recovering types for table calls can help an analysis, but our toolchain did not measure radare2’s ability to identify them. Swift metadata and CIL need separate inspection; the JNI result cannot simply be transferred to them.

Recommendations by situation

These are engineering recommendations, not protection benefits measured by the experiment. Identify what is valuable and what must ship with the client before choosing tradeoffs.

Recommendations by review goal
QuestionFinding
JNI exports reveal business meaningInventory names and signatures; check binding compatibility.
Dynamic registrationInspect registration data and release artifacts; a shorter export list is not proof of secrecy.
Swift or .NET componentReview metadata and type information in each actual build.
Debug filesCheck package contents and symbol-service access; retain internal symbols by build.
Privileged credentialKeep it on a controlled server; use scoped client credentials.

Renaming an interface can affect linking, reflection or diagnostics, so a static listing is not enough. Record a release baseline, change one setting at a time, and test loading, critical flows and crash diagnosis. Match debug files such as dSYM and PDB to their builds and restrict distribution according to team policy.

Check your own release build

For a Java native component you are authorized to inspect, inventory the class and library from the release build. The example below uses macOS tools; substitute your own paths and class name, and use the appropriate symbol tool on other platforms. javap examines class files, not Android DEX.

Replace paths and class with your own release artifacts.
javap -classpath path/to/classes -s -private com.example.Bridge
nm -gU path/to/libbridge.dylib
strings path/to/libbridge.dylib

Map Java declarations to native exports and registration sites, then review unnecessary business names and credentials. Record tool versions, build identifier and findings. After changes, repeat under the same build conditions and exercise actual device flows to verify binding. Keep output that may contain sensitive material out of public logs.

Your checklist

  • Inventory JNI methods, signatures and bindings in release libraries.
  • Review business names in exports and registration data.
  • Inspect Swift metadata and .NET type information separately.
  • Retain matching symbol files with restricted access.
  • Retest loading, critical flows and crash diagnosis after changes.

Primary sources

All sources and reproduction status ↗