Java has a feature named Java Native Interface (JNI), which allows to call native machine code function from inside the Java's bytecode. This feature allows effectively running machine native code from a native shared library, which -in the case of Android apk apps- the app developer provides inside the apk package.
My doubt is if this JNI should this be a security concern? I.e. that code outside of Dalvik virtual machine, direct native code could be imho a higher risk to attack the system, as it the java bytecode through Dalvik?
Is native code a bigger security concern than code in a virtual machine?
JNI is not the only way to run native code, albeit a conveniend one because one does not have to do lots of copying/embedding of a binary to run (i.e. from the apks assets to a executable location) Anyway also this is possible:
Now I am aware that, nothing is yet ultimately lost, only because native code is executed, e.g. the security model of many desktop boxes also works with native applications running. Indeed one is at least lucky that Android stuffs apps into their own user id UID, so one might at first hand say, that even natively one is safer on Android, than running firefox and chromium with the same
me@mybox user on some desktop boxes.
The curcial point, which also motivates the question if it constitutes a security concern, is that native code appear to me much more flexible to attack the system via systemcalls and buffer overruns etc, than possible for an attack occuring from within the apk/apps Java codebase. After all even for legitimate stuff Dalvik/Java gets much in the way and is disabled because of its portability goal.
Assuming there is a risk associated with JNI and the exec call, am I mistaking or does Android lack a permission setting for that. So in attition to evaluation the question, there should be "extra upvotes" for confirming or refuting that Android does not have as-per-app permission settings for JNI. My poc app at least installs with the message:
Do you want to install this application? It does not require any special access?
which seems to indicate to me that it would not require any permission at all. Yet I know it can run native code and JNI native code.