How to SECURE my FLUTTER Mobile Application? (Flutter App Penetration Testing Result) : <p><strong>Where can I get Flutter App security documentation or best practice?</strong> I am nearly ready to publish my app. 
I use online (free version) <a href="https://www.ostorlab.co/report/" rel="noreferrer">https://www.ostorlab.co/report/</a> and check the security of my app.</p>

<p>I have a main question above and some more question in below. </p>

<ul>
<li>How to disable debug mode? </li>
<li>How to disable backup mode? </li>
<li>How to prevent my google map api key in AndroidManifest or similar?</li>
</ul>

<p>These are the security issue that I am facing. 
—————————————————————————————————</p>

<p><strong>High Debug mode enabled
Description</strong></p>

<p>The application is compiled with debug mode allowing attackers to attach a debugger to access sensitive data or perform malicious actions.Attacker can debug the application without access to source code and leverage it to perform malicious actions on behalf ot the user, modify the application behavior or access sensitive data like credentials and session cookies.</p>

<p><strong>Recommendation</strong></p>

<p>Disable debug mode by setting the attribute android:debuggeable to false in the application tag.
    </p>

<p>References
    •   DRD10-J Do not relase apps that are debuggable (CERT Secure Coding)</p>

<p><strong>Ex: AndroidManifest:</strong> </p>

<pre><code>&lt;activity android:name="com.apptreesoftware.mapview.MapActivity" android:theme="@7F0C0102"&gt; &lt;/activity&gt;
&lt;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value=“****************************”&gt;&lt;/meta-data&gt;
&lt;meta-data android:name="com.google.android.gms.version" android:value="@7F080004"&gt;&lt;/meta-data&gt;
</code></pre>

<p>————————————————————————————</p>

<p><strong>Potentially Backup mode enabled
Description</strong></p>

<p>Android performs by default a full backup of applications including the private files stored on /data partition. The Backup Manager service uploads those data to the user's Google Drive account.</p>

<p><strong>Recommendation</strong></p>

<p>if the application contains sensitive data that you don't want to be restored, you can disable backup mode by setting the attribute android:allowBackup to false in the application tag.</p>

<p>References
    •   Random Musings on the M Developer Preview: the Ugly (Part Two)
    •   DRD22. Do not cache sensitive information</p>

<p>————————————————————————————</p>

<p><strong>Potentially Services declared without permissions
Description</strong></p>

<p>service is an application component that can take care of actions to be done in the background, without user interaction. service can also be used to expose functionalities to other applications. This corresponds to calls to Context.bindService() to establish a connection to the service and interact with it.
Unprotected services can be invoked by other applications and potentially access sensitive information or perform privileged actions</p>

<p><strong>Recommendation</strong></p>

<p>service can expose several methods to external componenets. It is possible to define arbitrary permissions for each method using the method checkPermission.
It is also possible to seperate services and restrict access by enforcing permissions in the manifest's  tag.</p>

<pre><code>&lt;permission android:name="co.ostorlab.custom_permission" android:label="custom_permission" android:protectionLevel="dangerous"&gt;&lt;/permission&gt;
&lt;service android:name="co.ostorlab.custom_service" android:permission="co.ostorlab.custom_permission"&gt;
    &lt;intent-filter&gt;
        &lt;action android:name="co.ostorlab.ACTION" /&gt;
    &lt;/intent-filter&gt;
&lt;/service&gt;
</code></pre>

<p>The service can enforce permissions on individual IPC calls by calling the method checkCallingPermissionbefore executing the implementation of that call.</p>

<p>References
    •   CWE-280: Improper Handling of Insufficient Permissions or Privileges
    •   Security Decisions Via Untrusted Inputs (OWASP Mobile Top 10)
    •   Service (Android Developper Documentation)</p>

<p><strong>Technical details
False Positive
Services definition in AndroidManifest.xml:</strong></p>

<pre><code>&lt;service android:name="com.mobile.niyazibank.MyFirebaseMessagingService"&gt;
&lt;intent-filter&gt;
&lt;action android:name="com.google.firebase.MESSAGING_EVENT"&gt;
&lt;/action&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;service android:name="com.mobile.niyazibank.MyFirebaseInstanceIDService"&gt;
&lt;intent-filter&gt;
&lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT"&gt;
&lt;/action&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;service android:name="io.flutter.plugins.firebasemessaging.FlutterFirebaseInstanceIDService"&gt;
&lt;intent-filter&gt;
&lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT"&gt;
&lt;/action&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;service android:name="io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService"&gt;
&lt;intent-filter&gt;
&lt;action android:name="com.google.firebase.MESSAGING_EVENT"&gt;
&lt;/action&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;service android:exported="true" android:name="com.google.firebase.messaging.FirebaseMessagingService"&gt;
&lt;intent-filter android:priority="-500"&gt;
&lt;action android:name="com.google.firebase.MESSAGING_EVENT"&gt;
&lt;/action&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;service android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdService"&gt;
&lt;intent-filter android:priority="-500"&gt;
&lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT"&gt;
&lt;/action&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
</code></pre>

<p>————————————————————</p>

<p><strong>Important Exported activites, services and broadcast receivers list
Description</strong></p>

<p>List of all exported components in the application. Exported component are accessible to external applications and present an entry point to the application.</p>

<p><strong>Recommendation</strong></p>

<p>This entry is informative, no recommendations applicable.</p>

<p>References
    •   Content Provider (Android Developper Documentation)
    •   Activity (Android Developper Documentation)
    •   Broadcast Receiver (Android Developper Documentation)
    •   Service (Android Developper Documentation)</p>
