rethink-app icon indicating copy to clipboard operation
rethink-app copied to clipboard

v055x: Inconsisent application of overlapping IP CIDR rules

Open raxelbyte opened this issue 4 months ago • 12 comments

Add an IP CIDR as Trusted yet the IP from that CIDR stays blocked. it's only accepting IP address which is trusted or blocked but CIDR whitelisting fails and automatically puts the IP address as blocked in the log. Inside Per app settings same IP address appears as NO rule applied category but it's actually blocked as it's not resolving. For Example, Trusted/whitelist a CIDR 20.235.0.0/16:0 but the IP address from that CIDR like 20.235.5.3 , 20.235.100.200 or any random 20.235.x.x etc stays blocked by ignoring the trusted CIDR Range which technically should automatically get trusted as the IP address falls in that CIDR Range.

raxelbyte avatar Jul 04 '26 10:07 raxelbyte

Inside Per app settings same IP address appears as NO rule applied category but it's actually blocked as it's not resolving.

Have you put the app in "Isolate"? Or, turned ON Configure -> Firewall -> Universal firewall rules -> Block all except bypassed apps and IPs?

For Example, Trusted/whitelist a CIDR 20.235.0.0/16:0 but the IP address from that CIDR like 20.235.5.3 , 20.235.100.200 or any random 20.235.x.x etc stays blocked by ignoring the trusted CIDR Range which technically should automatically get trusted as the IP address falls in that CIDR Range.

Make sure you're not looking at blocked entries in Configure -> Logs -> Network / Configure -> Logs -> DNS before the rule to trust / whitelist the CIDR was added?

ignoramous avatar Jul 04 '26 18:07 ignoramous

Inside Per app settings same IP address appears as NO rule applied category but it's actually blocked as it's not resolving.

Have you put the app in "Isolate"? Or, turned ON Configure -> Firewall -> Universal firewall rules -> Block all except bypassed apps and IPs?

For Example, Trusted/whitelist a CIDR 20.235.0.0/16:0 but the IP address from that CIDR like 20.235.5.3 , 20.235.100.200 or any random 20.235.x.x etc stays blocked by ignoring the trusted CIDR Range which technically should automatically get trusted as the IP address falls in that CIDR Range.

Make sure you're not looking at blocked entries in Configure -> Logs -> Network / Configure -> Logs -> DNS before the rule to trust / whitelist the CIDR was added?

I haven't enabled "Block all except bypassed apps and IPs" and I haven't even put the app in "Isolate"

I have already wasted more than an hour to try to get the working with multiple apps and games to actually confirm if it's some app/game issue or it it's Rethink App issue, but it turned out to be Rethink App's issue, something is broken in it which is not allowing a particular IP to get whitelisted/Trusted irrespective of the Whitelisted/Trusted CIDR Range family. I have tried with multiple apps like telegram, browser , Whatsapp etc and with games like PUBG, CODM , Battle Prime etc if I whitelist an IP , then those apps/games work fine. if I whitelist a CIDR Range but block other traffic say with 0.0.0.0/8:0 which is I believe everything blocked apart from what's Whitelisted/Trusted . But it seems the Rethink App isn't processing it correctly as it might be of ignoring all other rules except block all under per-app-rules. Either the App should respect all the rules placed in some priority or preference/sequence they're made to avoid this issue IF it's ignoring it , otherwise there's something broken which is preventing Trusted CIDR IPs to still fall under blocked category.

P.S. - I checked the latest logs , cleared old logs, even toggle the firewall, cleared logs, switched to app/game, checked logs again and nothing changes, IPs appear as blocked and app/game doesn't load/work as it's expected to be.

raxelbyte avatar Jul 04 '26 19:07 raxelbyte

. if I whitelist a CIDR Range but block other traffic say with 0.0.0.0/8:0 which is I believe everything blocked apart from what's Whitelisted/Trusted . But it seems the Rethink App isn't processing it correctly as it might be of ignoring all other rules except block all under per-app-rules.

Yes, please see: #2857

I have already wasted more than an hour to try to get the working with multiple apps and games to actually confirm if it's some app/game issue or it it's Rethink App issue, but it turned out to be Rethink App's issue, something is broken in it which is not allowing a particular IP to get whitelisted/Trusted irrespective of the Whitelisted/Trusted CIDR Range family.

Yikes. Apologies. We've also discovered another issue when new CIDR rules are added alongside an existing but less specific or more specific related CIDR rule: For example, trust rule for 1.0.0.0/8 exists and a new block rule for 1.1.0.0/16 is added anew. But this might not be the issue you might have seen).

ignoramous avatar Jul 04 '26 21:07 ignoramous

. if I whitelist a CIDR Range but block other traffic say with 0.0.0.0/8:0 which is I believe everything blocked apart from what's Whitelisted/Trusted . But it seems the Rethink App isn't processing it correctly as it might be of ignoring all other rules except block all under per-app-rules.

Yes, please see: #2857

I have already wasted more than an hour to try to get the working with multiple apps and games to actually confirm if it's some app/game issue or it it's Rethink App issue, but it turned out to be Rethink App's issue, something is broken in it which is not allowing a particular IP to get whitelisted/Trusted irrespective of the Whitelisted/Trusted CIDR Range family.

Yikes. Apologies. We've also discovered another issue when new CIDR rules are added alongside an existing but less specific or more specific related CIDR rule: For example, trust rule for 1.0.0.0/8 exists and a new block rule for 1.1.0.0/16 is added anew. But this might not be the issue you might have seen).

I checked the https://github.com/celzero/rethink-app/issues/2857 issue, but it's different from what I'm experiencing, I have kept the DNS off if it's what's you're referring to. I mean what I'm saying is even I we use block all rule in per-app setting with .:* (0.0.0.0/8:0) which I believe means block all the traffic on all the ports , should allow/exclude traffic on whitelisted/trusted ports when set vaguely with CIDR or Wildcard support because it's accepting it ONLY when we set a particular IP address as Trusted/whitelisted

For example, I set a per-app-rule say under PUBG game, I blocked all it's traffic first with .:* which is 0.0.0.0/8:0 , then I want to whitelist/trust a few particular IPs which I know are necessary for the game to actually run, say 20.153.16.253 , 20.24.23.121 , 20.233.82.42 and so on , There are 100s of such IPs which needs to be whitelisted from 20.x.x.x CIDR in order for the game to work, so it's tiresome and too much work to whitelist all IPs accurately and one by one because ONLY then it works FINE with block all rule set earlier. BUT to shorten the process and ease , when I whitelist the CIDR Range of 20.x.x.x then it DOESN'T work as it simply ignores it which it SHOULDN'T as user specified ANOTHER rule in game's rule. so the Rethink App should translate it like "okay user blocked all traffic, but leave the traffic of 20.x.x.x/x:x intact. Block all except that CIDR" but it's not behaving that way. HOWEVER It's able to translate when IP is trusted/whitelisted.

I have tried to avoid block all rule, but then even after only setting Trusted/Whitelist rule the game is able contacting addresses which I don't want it to, shows in logs/most contacted IPs/Domains under app details. And there are hundreds & thousands of IPs and domains which needs to be blocked and it's unknown , that's why .:* rule comes handy but it's not working correctly

It may sound confusing but for reference there used to be an app called NoRoot Firewall by greyshirt apps, it used to have the functionality what I'm referring to although it lacked CIDR Range feature but it supported wildcard setting which was equivalent to CIDR. It used to respect rules from top to bottom , whichever rule comes first, will be used , so allow all the IP/, CIDR and then at the end put . which blocks rest all ports and IPs. Apologize for log explanation but I hope you're getting what I'm actually trying to explain . 😅

raxelbyte avatar Jul 05 '26 07:07 raxelbyte

Apologize for log explanation but I hope you're getting what I'm actually trying to explain.

Thanks. Please don't apologise. In fact, I appreciate the detailed report (:

The issue you describe[^0][^1] is similar to the one I wrote above?

Yikes. Apologies. We've also discovered another issue when new CIDR rules are added alongside an existing but less specific or more specific related CIDR rule: For example, trust rule for 1.0.0.0/8 exists and a new block rule for 1.1.0.0/16 is added anew. But this might not be the issue you might have seen).

If so, we've now fixed this for the upcoming version, v055y.

BUT to shorten the process and ease , when I whitelist the CIDR Range of 20.x.x.x then it DOESN'T work as it simply ignores it which it SHOULDN'T as user specified ANOTHER rule in game's rule.

To shorten the ruleset, you can also consider put the app in "Isolate", from Configure -> Apps -> (that specific app). "Isolate" blocks all traffic except the one explicitly allowed. Domain rules (provided you are not using Android's Private DNS) are easier to manage than IP rules. Anyway, just the single CIDR to allowlist 20.x.y.z should then work (assuming you're using Rethink in DNS and Firewall mode).

[^0]: For example, I set a per-app-rule say under PUBG game, I blocked all it's traffic first with .:* which is 0.0.0.0/8:0 , then I want to whitelist/trust a few particular IPs which I know are necessary for the game to actually run, say 20.153.16.253 , 20.24.23.121 , 20.233.82.42 and so on , There are 100s of such IPs which needs to be whitelisted from 20.x.x.x CIDR in order for the game to work, so it's tiresome and too much work to whitelist all IPs accurately and one by one because ONLY then it works FINE with block all rule set earlier.

[^1]: It used to respect rules from top to bottom , whichever rule comes first, will be used , so allow all the IP/, CIDR and then at the end put . which blocks rest all ports and IPs.

ignoramous avatar Jul 05 '26 10:07 ignoramous

Apologize for log explanation but I hope you're getting what I'm actually trying to explain.

Thanks. Please don't apologise. In fact, I appreciate the detailed report (:

The issue you describe12 is similar to the one I wrote above?

Yikes. Apologies. We've also discovered another issue when new CIDR rules are added alongside an existing but less specific or more specific related CIDR rule: For example, trust rule for 1.0.0.0/8 exists and a new block rule for 1.1.0.0/16 is added anew. But this might not be the issue you might have seen).

If so, we've now fixed this for the upcoming version, v055y.

BUT to shorten the process and ease , when I whitelist the CIDR Range of 20.x.x.x then it DOESN'T work as it simply ignores it which it SHOULDN'T as user specified ANOTHER rule in game's rule.

To shorten the ruleset, you can also consider put the app in "Isolate", from Configure -> Apps -> (that specific app). "Isolate" blocks all traffic except the one explicitly allowed. Domain rules (provided you are not using Android's Private DNS) are easier to manage than IP rules. Anyway, just the single CIDR to allowlist 20.x.y.z should then work (assuming you're using Rethink in DNS and Firewall mode).

Footnotes

  1. For example, I set a per-app-rule say under PUBG game, I blocked all it's traffic first with .:* which is 0.0.0.0/8:0 , then I want to whitelist/trust a few particular IPs which I know are necessary for the game to actually run, say 20.153.16.253 , 20.24.23.121 , 20.233.82.42 and so on , There are 100s of such IPs which needs to be whitelisted from 20.x.x.x CIDR in order for the game to work, so it's tiresome and too much work to whitelist all IPs accurately and one by one because ONLY then it works FINE with block all rule set earlier. ↩
  2. It used to respect rules from top to bottom , whichever rule comes first, will be used , so allow all the IP/, CIDR and then at the end put . which blocks rest all ports and IPs. ↩

Thanks for taking it nicely, I will try with app isolation if it fixes the issue because I'm not using any DNS and relying only on Rethink App's DNS + firewall mode for blocking the traffic in apps, if isolation automatically blocks all traffic and allows only whitelisting without behaving the same as it's doing in normal mode i.e. unable to translate whitelist CIDR Range if block all rule is applied in per-app-rules. I hope isolation automatically blocks all traffic and allows only the whitelist CIDR because the whitelist IPs are in lesser number than blacklist IPs. If it works, all good, else I will wait for next build as you mentioned it's addressing the issue already. Thanks 😊

raxelbyte avatar Jul 05 '26 13:07 raxelbyte

I hope isolation automatically blocks all traffic and allows only the whitelist CIDR because the whitelist IPs are in lesser number than blacklist IPs.

Yes, that's what "Isolate" is for. And, I think, the per-app allowlist/trust 20.0.0.0/8 (without port numbers, as that's #2857) CIDR rules will work fine in v055x.

ignoramous avatar Jul 05 '26 18:07 ignoramous

I hope isolation automatically blocks all traffic and allows only the whitelist CIDR because the whitelist IPs are in lesser number than blacklist IPs.

Yes, that's what "Isolate" is for. And, I think, the per-app allowlist/trust 20.0.0.0/8 (without port numbers, as that's #2857) CIDR rules will work fine in v055x.

Tried the isolation mode, and It seems to be working fine so far. I didn't try whitelisting/trusted without port because game randomly assigns port so whitelisting all ports is necessary too in that case. but currently isolation is working fine , so I will continue using it instead. Thanks once again 😊

raxelbyte avatar Jul 06 '26 07:07 raxelbyte

Must be fixed in v055y. Please test & let me know if that's not the case. If so, I'll reopen this bug.

ignoramous avatar Jul 07 '26 03:07 ignoramous

Must be fixed in v055y. Please test & let me know if that's not the case. If so, I'll reopen this bug.

Yeah the issue is fixed in latest build as it's respecting whitelist IP/CIDR even with 0.0.0.0/0:0 blocked rule . Thanks for fixing it quickly. Although I noticed that Blocked Domain Names are getting resolved on IPv6. I'm using the DNS + Firewall of Rethink App. Just wanted to bring this to your notice. For reference please check the screenshots. You may close this thread as CIDR issue solved. 😊

screenshot Image Image

raxelbyte avatar Jul 07 '26 16:07 raxelbyte

Thanks for the confirmation. We were only able to fix it quickly because of detailed bug description you shared!

Although I noticed that Blocked Domain Names are getting resolved on IPv6.

From the screenshots, you've seem to setup block rule for a particular 3p app, but the domain name was resolved for "ANDROID" (which is a system component probably used by your OS to send DNS queries on behalf of all apps). Are you on Android 11 & below? If so, this is expected.

If you want to try and map domain requests to apps on Android 11 and below, you'd have to turn on Configure -> DNS -> Split DNS which requires turning on Configure -> DNS -> Advanced DNS filtering too. Both these settings are experimental, currently; so use with optimistic caution.

ignoramous avatar Jul 07 '26 18:07 ignoramous

Thanks for the confirmation. We were only able to fix it quickly because of detailed bug description you shared!

Although I noticed that Blocked Domain Names are getting resolved on IPv6.

From the screenshots, you've seem to setup block rule for a particular 3p app, but the domain name was resolved for "ANDROID" (which is a system component probably used by your OS to send DNS queries on behalf of all apps). Are you on Android 11 & below? If so, this is expected.

If you want to try and map domain requests to apps on Android 11 and below, you'd have to turn on Configure -> DNS -> Split DNS which requires turning on Configure -> DNS -> Advanced DNS filtering too. Both these settings are experimental, currently; so use with optimistic caution.

Yeah i got two devices, it's same in both of them probably because one is android 8.1 and other one is android 11 In previous version it wasn't resolving DNS on IPv6, probably because I had blocked internet access for all apps except the testing apps, will try by blocking internet access in rethink app for Android etc if it solves the issue, else I will try with what you suggested. Thanks once again 😅

raxelbyte avatar Jul 07 '26 21:07 raxelbyte