[Error] Corona SDK - Google traversal vulnerability in a ContentProvider [Real Case]

2017. 10. 13. 23:26Programing/Debugging

[Error Case]


 

[How to fix?]

1. Download APKTool

  https://ibotpeaches.github.io/Apktool/


2. Install APKTool

  https://ibotpeaches.github.io/Apktool/install/

3. Preparing your APK on specific folder


4. Open CMD (Win+R > cmd > OK)


5. Move the path to specific folder you had created


6. Decompile APK

   # apktool d "APK Name"


7. Fix the vulnerability

 Open file "AndroidManifest.xml" with your favorite programmers text editor (for example Sublime Text, Xcode or Atom). This is the step where we actually fixing the issue as suggested by Google Play email.
Change android:exported="true" to android:exported="false"
So the line looks like:

[Before]
<provider android:authorities="com.coronalabs.vlad.Licensing3.files" android:exported="true" android:name="com.ansca.corona.storage.FileContentProvider"/>

[After]
<provider android:authorities="com.coronalabs.vlad.Licensing3.files" android:exported="false" android:name="com.ansca.corona.storage.FileContentProvider"/>


8. Increment version code

In order to submit a new version to Play Store, you must increase build number. You can do it by editing LicensingOld/apktool.yml and changing versionCode to larger version:
> versionCode: '3'
became
> versionCode: '4'
Also, I had to edit AndroidManifest.xml by adding attribute android:versionCode="5" to manifest tag in 1st line:
[Before]
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.coronalabs.vlad.Licensing3" platformBuildVersionCode="25" platformBuildVersionName="7.1.1" >
became
[After]
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.coronalabs.vlad.Licensing3" platformBuildVersionCode="25" platformBuildVersionName="7.1.1" android:versionCode="4">
This seem to be a bug in apktool, but here's work around


8-1. Change the app name

If you hope to change the app name, you need to modify [android:label="App Name"].


9. Rebuild APK

Rebuild the APK by running this command

# apktool b <Created Folder name> -o NewAPK.apk

You should check the file size. If the file size of NewAPK.apk is too small than original, you need to rebuild.


10. Download apk-signer tool

https://shatter-box.com/knowledgebase/android-apk-signing-tool-apk-signer/


11. Sign APK

- Execute Apk-signer tool

- Set JDK path - you can refer to the apk-signer tool site.

- Select "Signer" Tab

- Select Key > Input PW > Select Alias > Input Alias PW > Select "NewAPK.apk" > Sign!

"NewAPK.apk" name will be changed to "NewAPK_SIGNED_UNALIGNED.apk"


12. Align APK

- Select "APK Alignment" tab on apk-signer tool

- Load "NewAPK_SIGNED_UNALIGNED.apk" > Align

- Load "NewAPK_SIGNED_ALIGNED.apk" > Verify

If you can see the "Verification succesful", it's done.

Complete file name is "NewAPK_SIGNED_ALIGNED.apk".


13. Upload new APK on Google Development Consol

- Select Application > Release management > App release

- Manage Production

- Create Release

- Upload "NewAPK_SIGNED_ALIGNED.apk"

- Save > Review

- Start Rollout To Production

- Confirm

- If you wait around 1 day, the warning message will be removed.