Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_v2_round"
android:theme="@style/Theme.Material3.DayNight.NoActionBar"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="false"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity"
android:enableOnBackInvokedCallback="true"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">127.0.0.1</domain>
</domain-config>
</network-security-config>
Comment on lines +2 to +6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The Network Security Configuration has two issues that prevent it from fully achieving the pull request's security goals and may break local functionality:

  1. IP Address in Domain: The <domain> element does not support IP addresses (e.g., 127.0.0.1). It only supports hostnames. If the application accesses the local dashboard via http://127.0.0.1, it will be blocked because this rule will not match. You should use localhost instead and ensure the application refers to the local service via http://localhost.
  2. Missing Base Config: On Android 7.0 to 8.1 (API 24-27), the presence of a network security configuration file overrides the android:usesCleartextTraffic="false" flag in the manifest. Since no <base-config> is defined here, cleartext traffic will be permitted by default on those versions. Adding an explicit <base-config cleartextTrafficPermitted="false" /> is necessary to enforce the policy globally across all supported Android versions.

Reference: Android Network Security Configuration

Suggested change
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">127.0.0.1</domain>
</domain-config>
</network-security-config>
<network-security-config>
<base-config cleartextTrafficPermitted="false" />
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">localhost</domain>
</domain-config>
</network-security-config>

Loading