In fact, in the network path there is no verification of additional permissions for kernel versions prior to v3.1-18-gfd77846 .
Initially, it would be nice to replace cap_raised completely, so here I preferred to add a similar check as such to cap_capable . Other possible cap are CAP_SYS_ADMIN , CAP_AUDIT_CONTROL and CAP_AUDIT_WRITE , but they are not network related. Note that since commit is the above, it ultimately ends up calling cap_capable (via capable ).
Patch:
diff --git a/security/commoncap.cb/security/commoncap.c index 8bfbd13..485245a 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -63,6 +63,10 @@ int cap_netlink_send(struct sock *sk, struct sk_buff *skb) int cap_netlink_recv(struct sk_buff *skb, int cap) { +#ifdef CONFIG_ANDROID_PARANOID_NETWORK + if (cap == CAP_NET_ADMIN && in_egroup_p(AID_NET_ADMIN)) + return 0; +#endif if (!cap_raised(current_cap(), cap)) return -EPERM; return 0;
For those looking at CAP_NET_RAW , for this you need to be in the net_raw group. Either add this group to the existing android.permission.NET_ADMIN permission, or apply the following frame patch:
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 1e7dcf7..07f5d94 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -927,6 +927,12 @@ android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="signature" /> + <!-- Allows access to raw sockets, allowing full network access and spoofing. + @hide --> + <permission android:name="android.permission.NET_RAW" + android:permissionGroup="android.permission-group.SYSTEM_TOOLS" + android:protectionLevel="signature" /> + <!-- Allows registration for remote audio playback. @hide --> <permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK" android:permissionGroup="android.permission-group.SYSTEM_TOOLS" diff --git a/data/etc/platform.xml b/data/etc/platform.xml index 47cb7ab..9c209c3 100644 --- a/data/etc/platform.xml +++ b/data/etc/platform.xml @@ -82,6 +82,10 @@ <group gid="net_admin" /> </permission> + <permission name="android.permission.NET_RAW" > + <group gid="net_raw" /> + </permission> + <!-- The group that /cache belongs to, linked to the permission set on the applications that can access /cache --> <permission name="android.permission.ACCESS_CACHE_FILESYSTEM" >
source share