-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protect API key in App #1738
Comments
➤ Sam commented: James Chien, I was going through my old tasks and Get proposed solution from Ionic ( https://app.asana.com/0/0/1202516018160176 ) is one of them. How our API key got exposed form the capture app? As my understanding capture app is bundled and run from App/Play Stores there is no way to use chrome dev tools to inspect API keys. So how our API key got exposed? Bofu Chen asked "best practice to protect API keys in APP" and Ionic team suggested backend first solution is better Comment by @BoFu Chen on Get proposed solution from Ionic ( https://app.asana.com/0/0/1202516018160176/1202516139729392/f ). But if I can get more information on this task i can ask GPT and see whats possible in our case. |
➤ James Chien commented: There are mainly 2 approaches, and I just test them, the API key is truly vulnerable from reverse-enginerring and attacks. Method #1: Uncompress apk and find the key in source code Step 1: Get APK Although you can't directly choose to download an apk from Play store, there are services like Download Capture latest 0.77.2 Android APK (apkpure.com) ( https://apkpure.com/capture-only-true-photos/io.numbersprotocol.capturelite/download ) that enables any user to download App as apk. Step 2: Uncompress Use unzip or other tools to uncompress apk. Step 3: reverse-engineer and get API key Js code can only be uglified, not compiled into binary, so this part won't be too difficult. I found the API key in assets/public/main.8b9b91d1eaed5e25.js, in the uncompressed file. Method #2: Use proxy monitoring tool to read request headers Step 1: Install Proxy tool
Step 2: Install Charles root certificate on iOS
Step 3: Prepare environment
Step 4: Monitor requests and try different actions
The attached screenshot is what I got in the Charles Proxy tool. I censored the whole API key, but you can see from the prefix this is the API key used for Capture production app. |
➤ James Chien commented: For method #1 attack, this is probably what we need Ionic's advice for. We need a secured way to bundle the API key in the app, not directly accessible in the uglified JavaScript if user uncompresses the apk. For method #2 attack, we might need to consider certificate pinning or public key pinning, but this part might need more survey. |
➤ Sam commented: James Chien, thank you for your feedback. I learned a lot from your examples. I think it's not simple task. Tammy Yang, (cc: Bofu Chen) should we ask ionic team (aka renew subscription)? |
➤ Bofu Chen commented: What's the suggestion from ChatGPT or Bard? Compared to the delivered value, the Ionic enterprise service is relatively expensive. We will not renew the contract with them. |
➤ Tammy Yang commented: Let's survive without Ionic team 🙂. We create our own values. |
┆Issue is synchronized with this Asana task by Unito
┆Created By: James Chien
The text was updated successfully, but these errors were encountered: