I have a great idea for a biometric security app and some secure transactions, but i have no idea how to use a biometric api, if it exists. Anyone knows anything about any biometric api? Any ideas how to develop one?
I would appreciate any kind of help or information. Thanks a lot.
What kind of biometrics? OpenCV can help you do this using the camera...
http://opencv.org/android
OpenCV is a good tool to make facial recognition. You can use it to communicate with embedded cameras, detect faces, and compare two faces. But if you need a better SDK you can use Neurotechnology or a free webservice supplied by SkyBiometrics
My advice is if you don`t have much time to work with OpenCV and improve it algorithms / study it to use correctly, you can use SkyBiometrics that have a free usage and could work fine with your application if you have internet access.
I personally don't have experience working with a biometric API for Android. From what I've read and heard from developers, OpenCV seems like something you should opt for, especially since you don't have experience of it either.
This information might be of help if you want to use the fingerprint ID feature of the phone:
Android fingerprint API launched with Android 6.0 will offer a bevy of useful features to integrate new authentication technology for app developers with the apps. To implement this API in your new Android app you need to get the Android SDK first. The SDK Manager then will allow you to download the SDK platform for Android 6.0 and introduce necessary steps. As part of the launching process, Android has also come up with new sample to demonstrate and guide the developers in integrating the API with the fingerprint readers in various devices.
Beating the so called security concerns over the use of fingerprint technology in mobile transaction Android has revealed how the new API offers protective measures for maintaining privacy. The new API as revealed will protect the critical fingerprint features by keeping them in the secure device hardware.
Android also expressed future plans to come with measures that can help identifying fingerprint of users just before allowing access to critical resources and data. These identification measures would help protecting against all malicious intrusions and tampered applications by ensuring cryptographic level security for all types of transactions and access to offline data and online interactions. This hardware level protection of critical data offers full proof protection against all malicious actions and security threats making it safe for the users to use their fingerprints.
Source:
Android Fingerprint API for App Developers
Related
Is it possible for other apps to read my app's signature toString() format? Because I'm using my app's signature as the first core security of my app. Is it possible to crack? What else can i use as a password of my app that can't be seen even when decompiled? That my app will get void when that thing has changed or my app gets decompiled?
Your Mobile App APK is Public: You Don't Control It Any-more
Is it possible for other apps to read my app's signature toString() format?
From the moment you ship your mobile app to the public you loose the control of it and anything on it it's not a secret any more because a lot of open source tools exist to help reverse engineer it easily, for example MobSF - Mobile Security Framework:
Mobile Security Framework is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing framework capable of performing static analysis, dynamic analysis, malware analysis and web API testing.
Instrumentations frameworks are also often used by attackers to perform dynamic analysis at runtime, for example Frida:
Inject your own scripts into black box processes. Hook any function, spy on crypto APIs or trace private application code, no source code needed. Edit, hit save, and instantly see the results. All without compilation steps or program restarts.
If your mobile app relies only on its own signature to prevent modifications to it at runtime then it will fail to be effective to defend against attackers, but may prevent abuse from script kids. All an attacker needs to do is to statically reverse engineer your mobile app, find and remove the protections you put in place, repackage it and sign the app with it's own key.
Repackaging mobile apps and offer them in the official Google Play store or other alternative stores is more common then lots of developers may think, and a well known one that made the news was Pokémon Go:
Remember Pokémon Go, the location-based augmented reality mobile game from Niantic Labs that became an overnight global sensation when it launched in 2016? Well, the game has had a record 2019 having surpassed its launch year in revenues, announced a live AR multiplayer feature, and, on a slightly dissonant note, sued an “association of hackers” for creating and distributing unauthorized derivative versions of the company’s mobile apps.
The staggered release of Pokémon Go meant that obsessive fans in as-yet unserved regions gravitated to repackaged apps. The relatively innocuous of these apps merely contained modifications to by-pass in-app controls. However, the sheer demand for these apps also meant that unscrupulous actors were now able to get players to download versions that had either been injected with Trojans and adware or, worse still, completely repackaged malicious apps with no Pokémon code whatsoever. These repackaged apps, however, do not automatically spawn any Pokémon in regions where the official app is yet to be launched. To get around this, players had to hack API communications to spoof locations. At scale, the proliferation of repackaged apps and API abuse opens up a new vector for sophisticated DDoS attacks.
As you can see the use of in app controls can be bypassed and repackaged apps are offered and users end-up to install and use them without knowing or knowing that is not indeed the original app, but they don't mind once it's bypassing some controls that benefits the user.
So, am I saying that you shouldn't use in app controls? In my opinion you should use as many layers of defence as you can and afford in order to make the life of attackers as hard as possible, but bear in mind that if you don't combine this in-app defences with a mechanism that lets the API backend for your mobile app to know when request are from the genuine and untampered version of your mobile app, then you will end-up to fail on your efforts to thwart the attacks of the most de-terminated attackers.
Reverse Engineering Techniques
Because I'm using my app's signature as the first core security of my app. Is it possible to crack?
Yes, it can be done using static analyses via decompilation of the mobile app and/or with dynamic analyses.
An attacker may first decompile your mobile app in order to inspect the code and understand how it works and if necessary also use an instrumentation framework to to see at runtime how it behaves and how it could be bypassed in real-time.
You can learn how to use MobSF for static reverse engineering in this article I wrote:
The range of open source tools available for reverse engineering is huge, and we really can't scratch the surface of this topic in this article, but instead we will focus in using the Mobile Security Framework(MobSF) to demonstrate how to reverse engineer the APK of our mobile app. MobSF is a collection of open source tools that present their results in an attractive dashboard, but the same tools used under the hood within MobSF and elsewhere can be used individually to achieve the same results.
During this article we will use the Android Hide Secrets research repository that is a dummy mobile app with API keys hidden using several different techniques.
For an example on how to use an instrumentation framework at runtime you can see the article I wrote about How to Bypass Certificate Pinning with Frida on an Android App to learn how to use it:
Today I will show how to use the Frida instrumentation framework to hook into the mobile app at runtime and instrument the code in order to perform a successful MitM attack even when the mobile app has implemented certificate pinning.
Bypassing certificate pinning is not too hard, just a little laborious, and allows an attacker to understand in detail how a mobile app communicates with its API, and then use that same knowledge to automate attacks or build other services around it.
Possible Solutions
What else can i use as a password of my app that can't be seen even when decompiled? That my app will get void when that thing has changed or my app gets decompiled?
You can make it more difficult but you cannot make it impossible for being decompiled and reverse engineered. For example, you can use the built-in Proguard or R8 compiler on Android Studio:
When enabling shrinking, you also benefit from obfuscation, which shortens the names of your app’s classes and members, and optimization, which applies more aggressive strategies to further reduce the size of your app.
Obfuscation: shortens the name of classes and members, which results in reduced DEX file sizes. To learn more, go to the section about how to obfuscate your code.
A possible better solution is to shift the decision to the API backend of the mobile app, provided it works with one. The API backend will be the one deciding when to provide or not the necessary data for the app to work, but for that the backend needs to know if the requests are from what it expects, a genuine and untampered version of your mobile app.
So, if your mobile app works with an API backend then I recommend you to read this answer I gave to the question How to secure an API REST for mobile app?, especially the sections Hardening and Shielding the Mobile App, Securing the API Server and A Possible Better Solution where you will learn that the use of a Mobile App Attestation solution allows for the API backend to know when the request is indeed from your genuine and untampered mobile app, thus being able to deny the ones that come from tampered or repackaged versions of your mobile app, therefore rendering them useless due to the lack of data to work with.
Do You Want To Go The Extra Mile?
In any response to a security question I always like to reference the excellent work from the OWASP foundation.
For Mobile Apps
OWASP Mobile Security Project - Top 10 risks
The OWASP Mobile Security Project is a centralized resource intended to give developers and security teams the resources they need to build and maintain secure mobile applications. Through the project, our goal is to classify mobile security risks and provide developmental controls to reduce their impact or likelihood of exploitation.
OWASP - Mobile Security Testing Guide:
The Mobile Security Testing Guide (MSTG) is a comprehensive manual for mobile app security development, testing and reverse engineering.
For APIS
OWASP API Security Top 10
The OWASP API Security Project seeks to provide value to software developers and security assessors by underscoring the potential risks in insecure APIs, and illustrating how these risks may be mitigated. In order to facilitate this goal, the OWASP API Security Project will create and maintain a Top 10 API Security Risks document, as well as a documentation portal for best practices when creating or assessing APIs.
I am developing Android Translation App. The app uses Azure cognitive service text translation API key.
The API key is inside the App source code in Java file, and if I publish the app, people can crack the app apk file and use my API key, which will be quite expensive. Is there away how to protect my API key from being stolen? There is no login in the app, no sign in and anyone can download it from play store.
How can I protect the API key from being stolen?
You can use android Keystore which is there for a scenario like yours official docs
or can refer to a sample code here
Reverse Engineering
The API key is inside the App source code in Java file, and if I publish the app, people can crack the app apk file and use my API key
Yes, and its not hard to do when a lot of different open-sources exist to make this task easy to achieve, even by non technical people, like I demo with the Mobile Security Framework in my article
How to Extract an API key from a Mobile App with Static Binary Analysis:
The range of open source tools available for reverse engineering is huge, and we really can't scratch the surface of this topic in this article, but instead we will focus in using the Mobile Security Framework(MobSF) to demonstrate how to reverse engineer the APK of our mobile app. MobSF is a collection of open source tools that present their results in an attractive dashboard, but the same tools used under the hood within MobSF and elsewhere can be used individually to achieve the same results.
Also, you can use the grep command in the upload directory of MobSF to find other secrets that MobSF is not able to find:
grep -irl '_key"' --include 'strings.xml' --include "AndroidManifest.xml"
and
grep -irn '_key' --include '*.java' --include "*.smali" ./java_source/tld/domain ./smali_source/tld/domain
Replace _key with whatever other pattern you may want to look for.
Replace tld/domain with the one used by the mobile app being reverse engineered, e.g: com/example.
Secret Hidden in Native C Code
Secrets can be hidden in native C code as in the demo on the above linked article:
During this article we will use the Android Hide Secrets research repository that is a dummy mobile app with API keys hidden using several different techniques.
But then if you cannot find it with static analysis then you do a MitM attack, as I demo on this other article Steal that Api Key with a Man in the Middle Attack:
In order to help to demonstrate how to steal an API key, I have built and released in Github the Currency Converter Demo app for Android, which uses the same JNI/NDK technique we used in the earlier Android Hide Secrets app to hide the API key.
So, in this article you will learn how to setup and run a MitM attack to intercept https traffic in a mobile device under your control, so that you can steal the API key. Finally, you will see at a high level how MitM attacks can be mitigated.
Secrets in Hardware Keystores or Vaults
An alternative to the MitM attack is to use an instrumentation framework to hook at runtime to the code that retrieves the secret, be it from the Android Hardware baked Keystore or from any other vault provided by your cloud provider of choice:
Frida:
Inject your own scripts into black box processes. Hook any function, spy on crypto APIs or trace private application code, no source code needed. Edit, hit save, and instantly see the results. All without compilation steps or program restarts.
Third Party Services
The API key is inside the App source code in Java file, and if I publish the app, people can crack the app apk file and use my API key, which will be quite expensive.
Yes, it can be very expensive and you only discover it when the bill is already huge, despite you can set billing alerts, they don't work as you may think they do.
Reverse Proxy to the Rescue
Is there away how to protect my API key from being stolen?
Best practices don't recommend to use third party services directly from within a mobile app, instead they should be delegated to the API backend for the mobile app or to a Reverse Proxy, as I wrote in this my other article Using a Reverse Proxy to Protect Third Party APIs:
In this article you will start by learning what Third Party APIs are, and why you shouldn’t access them directly from within your mobile app. Next you will learn what a Reverse Proxy is, followed by when and why you should use it to protect the access to the Third Party APIs used in your mobile app.
So, by now you may think that you are just shifting from protecting the secret for accessing the translation API for the one to access the Reverse Proxy or API backend, and you are right, but with a huge difference, that makes all the difference, you are in control of the Reverse Proxy and/or API backend, therefore you can closely monitor the traffic, throtle/shutdown it and apply as many security defenses as necessary to keep things under control.
Open APIs
There is no login in the app, no sign in and anyone can download it from play store.
So, you have created a friction-less user experience but you have also created a security nightmare for yourself to solve.
Before I delve in more details it's important to first clarify some misconception around the difference between who vs what is accessing the backend.
The Difference Between WHO and WHAT is Accessing the API Server
I wrote a series of articles around API and Mobile security, and in the article Why Does Your Mobile App Need An Api Key? you can read in detail the difference between who and what is accessing your API server, but I will extract here the main takes from it:
The what is the thing making the request to the API server. Is it really a genuine instance of your mobile app, or is it a bot, an automated script or an attacker manually poking around your API server with a tool like Postman?
The who is the user of the mobile app that we can authenticate, authorize and identify in several ways, like using OpenID Connect or OAUTH2 flows.
You can think about the who as the user your API backend or Reverse Proxy could be able to Authenticate and Authorize access to the data(if you were using it), and think about the what as the software making that request in behalf of the user.
In an open API you are not able to identify the who in the request, but even if you were able it would not be enough to lock-down the mobile app with the API backend or Reverse Proxy.
So, what you need to strength the delegation of the third party service to your own backend or reverse proxy is to find a way of locking them down with the mobile app.
A Possible Additional Solution
Is there away how to protect my API key from being stolen?
The mobile app and the API backend and/or Reverse Proxy can be tight together by locking them down in a way that they only accept requests comming from a genuine and untampered version of your mobile app by introducing the Mobile App Attestation concept, and I recommend you to read this answer I gave to the question How to secure an API REST for mobile app?, especially the sections Hardening and Shielding the Mobile App, Securing the API Server and A Possible Better Solution to learn some more defense techniques and to learn about Mobile App Attestation.
In a nutshell the Mobile App Attestation solution will allow for any backend to assert with a very high degree of confidence that the request comes indeed from what you expect, a genuine and untampered version of your mobile app, aka not from a bot, script, cURL or any other tool.
Do You Want To Go The Extra Mile?
In any response to a security question I always like to reference the excellent work from the OWASP foundation.
For APIS
OWASP API Security Top 10
The OWASP API Security Project seeks to provide value to software developers and security assessors by underscoring the potential risks in insecure APIs, and illustrating how these risks may be mitigated. In order to facilitate this goal, the OWASP API Security Project will create and maintain a Top 10 API Security Risks document, as well as a documentation portal for best practices when creating or assessing APIs.
For Mobile Apps
OWASP Mobile Security Project - Top 10 risks
The OWASP Mobile Security Project is a centralized resource intended to give developers and security teams the resources they need to build and maintain secure mobile applications. Through the project, our goal is to classify mobile security risks and provide developmental controls to reduce their impact or likelihood of exploitation.
OWASP - Mobile Security Testing Guide:
The Mobile Security Testing Guide (MSTG) is a comprehensive manual for mobile app security development, testing and reverse engineering.
Another way to make your keys hard to reverse engineer is to save them in the NDK as native code.
One more solution is to create you own service proxy, which is your REST service that takes user requests, gets translation responses from AWS, and sends back responses to mobile devices.
The beauty is the secret key won't be stored on the mobile device while the downside is that your REST service becomes the single point of failure therefore you may need to provision redundant servers.
However, as your service is light-weighted, it shall scale well.
I have an Android application on Play Store and I want to detect if a user is using the original version of the app downloaded from play store or a mod apk from other sources.
Your Question
I have an Android application on Play Store and I want to detect if a user is using the original version of the app downloaded from play store or a mod apk from other sources.
A very simple question that embraces so many things to be fully answered, but from an high level view you can tackle this from within you mobile app or doing it from the outside.
Detecting from Within the Mobile app
Doing it from inside is known as RASP:
Runtime application self-protection (RASP) is a security technology that uses runtime instrumentation to detect and block computer attacks by taking advantage of information from inside the running software.
RASP technology is said to improve the security of software by monitoring its inputs, and blocking those that could allow attacks, while protecting the runtime environment from unwanted changes and tampering.
One thing that I observe often is that many developers are not aware that any protection they may add to the mobile app code to try to secure it can can be bypassed during runtime with an instrumentation framework, even when the code itself is strongly obfuscated. A well known instrumentation framework used to manipulate code at runtime is Frida:
Inject your own scripts into black box processes. Hook any function, spy on crypto APIs or trace private application code, no source code needed. Edit, hit save, and instantly see the results. All without compilation steps or program restarts.
In the case a developer adds a function to their code to detect if the app is the original one, the attacker will eventually find it through static analysis of the binary or through dynamic analysis at runtime, and then use Frida to hook on it to change the outcome, like returning always a result that says it's the original one. Another alternative for the attacker is to recompile the binary without said function, thus removing the protection.
So, Am I saying for you to not use self protecting code or RASP solutions on your mobile app?
No, I recommend you to use all the mechanisms you can afford in order to stop the bad actors, but you also need to be aware that they can bypass them, and try to make as hard as possible to overcome your defences, to the point that it will be time consuming for them and they will just prefer to go elsewhere to look for easier targets.
Detecting from outside the Mobile App
A better alternative is to delegate to outside the app the detection when it's running or not an original version of the binary, and if it doing in a device that is not rooted or jail-broken, and this can be done by using the Mobile App attestation concept, that I explain on this answer I gave to the question How to secure an API REST for mobile app? in the section about A Possible Better Solution.
In a nutshell the Mobile App Attestion is a solution that when full implemented attests if your mobile app is the genuine and untampered version you have uploaded to the play store, and that is running in a trusted device, not jail-broken or rooted.
The Mobile App Attestation solution differs from RASP solutions in the fact that the decisions are made outside the mobile device, therefore cannot be manipulated by instrumentation frameworks, and they also issue a JWT token that allows the backend for the mobile app to know when it can trust in requests is receiving from it.
Summary
RASP solutions fall short, because usually they don't let the mobile api backend know if the request is from a genuine version of the mobile that is running in a trusted environment, aka a device not rooted or jail-broken, but even if they do that, once the logic for doing so is running inside the mobile app, it can be manipulated by the attacker with Frida or similar tools.
On the other hand a Mobile App Attestation solution will make decisions outside the mobile device and allow the mobile api backend to be aware when it can trust or not in the incoming requests.
Do You Want To Go The Extra Mile?
In any response to a security question I always like to reference the excellent work from the OWASP foundation.
For APIS
OWASP API Security Top 10
The OWASP API Security Project seeks to provide value to software developers and security assessors by underscoring the potential risks in insecure APIs, and illustrating how these risks may be mitigated. In order to facilitate this goal, the OWASP API Security Project will create and maintain a Top 10 API Security Risks document, as well as a documentation portal for best practices when creating or assessing APIs.
For Mobile Apps
OWASP Mobile Security Project - Top 10 risks
The OWASP Mobile Security Project is a centralized resource intended to give developers and security teams the resources they need to build and maintain secure mobile applications. Through the project, our goal is to classify mobile security risks and provide developmental controls to reduce their impact or likelihood of exploitation.
OWASP - Mobile Security Testing Guide:
The Mobile Security Testing Guide (MSTG) is a comprehensive manual for mobile app security development, testing and reverse engineering.
This is possible if your app is using an external server under your control providing some important functionalities to make the app useful. This might be some cloud database or an enrollment feature. For offline or device only apps the following approach will not work.
When using the SafetyNet API the SafetyNet is returning as part of the response to the server under your control a apkCertificateDigestSha256 from the app executing the call. This can be checked if it is matching your app.
Note, that the evaluationType from the response is also important. Newer devices and versions of SafetyNet are supporting here HARDWARE_BACKED making shielding frameworks like MagiskHide useless.
I am trying to create a Mobile Application which can give me access to Calendar, Schedules, Email and other features of a Exchange Account.
Can this be done using Active Sync? Can anyone please provide me some links of tutorials/examples sort on the same?
This is to be implemented on both Android and IPhone platform.
I have searched across, but i haven't gotten a clear answer.
Also i have a limitation that i cannot make changes to the exchange server configuration, since it will be a very high level business decision.
Let me know.
Thanks
In Android, Google has provided support for enterprise application through Device Policy management. Support for exchange email was introduced in early versions of Android (1.6) and support for calendar and event integration was added later in subsequent releases. Please visit this document for more information:
http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en//events/io/2011/static/presofiles/taking_android_to_work.pdf
This is regarding google apps Device Management policy third party application which I got from android market in 2.2 .
I registered an account in Google Apps domain in order to use this account for enabling device management policies. I need to know the process in which remote wipe out feature can be achieved using this application in an enterprise manner. I need to login as an administrator in this application and need to wipe out the user secured data in his device on his request.
Is there a way in which I can achieve this using this 3rd party application?
I will be waiting for reply with the process in which this application can be used in Enterprise scenario.
Thanks in Advance.
If you are looking for device management in an enterprise scenario, you might want to take a look at Oracle Database Lite Mobile Server.
It provides enterprise device management features, including the ability to remotely wipe data on the client. However it does much more than that. It also includes a configurable two-way data sync engine and a management console for provisioning and monitoring devices. You can read more about it, and even try it out here:
http://bit.ly/eJOzhN
Maybe overkill for what you’re trying to do, but if you also need to provision applications and sync data between your devices and a backend database, this could be an ideal solution for you.
Good luck, hope you find a solution that meets your needs.
-- Eric
Your question is not programming related.
Please use:
https://android.stackexchange.com/
for Android superuser type questions.