Skip to content

Drop DNS lookups from apps block-all has no name for - #86

Open
javier20dev25 wants to merge 2 commits into
ValentinTorassa:mainfrom
javier20dev25:security/dns-block-all
Open

javier20dev25 wants to merge 2 commits into
ValentinTorassa:mainfrom
javier20dev25:security/dns-block-all

Conversation

@javier20dev25

Copy link
Copy Markdown

What

Apple's resolver stays reachable on port 53 in every mode, and in block-all the filter read and passed every app's lookups. An app that no rule and no Apple service names cannot connect anywhere, so an answer cannot serve it: its queries, whose names it writes, were a way out on their own, a plain DNS tunnel. I reproduced it with a small program that resolves names it puts data into; the flow was read and passed before this change.

Change

FilterPolicy.decide now reads a delegated lookup only when the app has a rule or the Apple services table covers it. Otherwise it drops the flow with dns_no_rule before the app can use an answer.

Two identities keep passing:

  • the resolver's own lookups, as before;
  • the extension's own lookups. Its address checks resolve hosts through the same resolver, under its identity and with no rule of its own; without this, block-all would drop its own checks. The identity comes from CodeIdentity.current() and is compared whole (signing id and team), so another Developer ID cannot claim it.

Ask mode is untouched, since an unknown app has to resolve before it can be asked about. Accept-all is untouched.

Tests

blockAllDropsLookupsFromAnAppWithNoRule covers:

  • a signed app the config does not name, and an ad-hoc one: dropped as dns_no_rule;
  • an app a rule names: read as before;
  • the resolver's own lookup: read;
  • the extension with filterIdentity: read; without it: dns_no_rule;
  • ask mode: read;
  • accept-all: allowed.

Notes

  • I could not build this here: this machine has no macOS or Swift toolchain. The macOS CI run (cd macos && swift test) is the first real check of it.
  • An app a rule names can still put data in query names to any authoritative server; this only takes away the no-rule path. Tying answers to the rule's names needs the NEDNSProxyProvider the plan already lists.
  • A rule that only names addresses counts as a rule, so such an app's lookups still pass.
  • The resolver splits a CNAME chain into separate queries for the names along it, so a gate on the queried name would break those chains. That is why this gate is by app and not by name.
  • docs/plan.md updates the DNS-in-block-all row with the new behaviour and what remains.

In block-all, mDNSResponder's lookups for an app went through whatever the
app: the resolver is reachable on port 53 in every mode, and the filter read
and passed the flow. An app that no rule and no Apple service names has no
connection an answer could serve, so its queries, whose names it writes, were
a way out on their own.

decide now reads a delegated lookup only when the app has a rule or the Apple
services table covers it, and drops it as dns_no_rule otherwise. The resolver's
own lookups still pass, and so do the extension's: its address checks resolve
hosts through the same resolver, under its own identity and with no rule. That
identity is CodeIdentity.current() and is compared whole, signing id and team,
so another Developer ID cannot claim it.

Ask mode is unchanged: an unknown app has to resolve before it can be asked
about. An app a rule names can still put data in query names to any
authoritative server; tying answers to the rule's names is the
NEDNSProxyProvider work the plan already lists.

blockAllDropsLookupsFromAnAppWithNoRule covers a probe and an ad-hoc app with
no rule, an app a rule names, the resolver, the extension with and without its
identity, ask mode and accept-all.
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@javier20dev25 is attempting to deploy a commit to the VT's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ValentinTorassa

Copy link
Copy Markdown
Owner

Thanks for this, and for writing it the way the repo is written.

I applied the commit on top of current main (it is based on a2b5b89, from before 1.0.8). It builds with warnings as errors and the 663 tests pass, yours included.

Before it can go in:

  1. docs/plan.md says "decided on 16 November 2026". The rows there record decisions I have made, so please drop the date or word it as proposed. I will date it if merged.
  2. Nothing here is said to work without a run on a Mac recorded in evidence/. That needs a signed build, so it is on me: block-all with an app no rule names, apps with rules and their helpers, the extension's own address checks, and the Apple services table. I will do it once the points below are in.
  3. If CodeIdentity.current() returns nil in the extension, block-all drops the extension's own lookups and every rule that needs an address check stops matching, with nothing in the log. Please make that visible.
  4. dns_no_rule needs its words in FlowReport.reasonWords, and the change needs a changelog entry.
  5. The plan row should say more plainly what stays open: any process can start a tool that has a rule (curl), and the resolver's own lookups always pass. Do you know what makes mDNSResponder ask under its own identity?

One question: how did you run the reproduction? On a build signed with your own Developer ID, or against FilterPolicy.decide alone?

@javier20dev25

Copy link
Copy Markdown
Author

Pushed 01e815a on security/dns-block-all with the review points addressed:

  • docs/plan.md now says the DNS-in-block-all row was proposed on 16 November 2026, not decided.
  • dns_no_rule is in FlowReport.reasonWords, with its wording covered by a test.
  • The changelog has an Unreleased entry for the gate and for what remains open.
  • When CodeIdentity.current() is nil, startup now logs filter_identity_unavailable, and a blocked lookup reports that reason instead of being silent. Apps that a rule names still resolve in that state.
  • The plan row now says plainly that any process can start a tool a rule names (curl), and that the resolver's own lookups always pass.

On mDNSResponder: the repo records that lookups it makes for an app arrive under that app's audit token in sourceProcessAuditToken (docs/plan.md:94-95). The lookups that arrive under its own identity are therefore the ones without a delegated source app token. I did not identify which internal macOS subsystem originates them, so I would not claim more than that.

On the reproduction question: I did not run it on a build signed with my Developer ID. This machine has no macOS or Swift toolchain; the reasoning and tests were against FilterPolicy.decide and the Swift test sources only. The signed-build run in evidence/ remains yours, as you said, and I am not claiming the Mac-side behaviour is verified here.

@javier20dev25

Copy link
Copy Markdown
Author

Checklist against your review, with evidence:

  1. Date: docs/plan.md now reads "proposed on 16 November 2026", not "decided".
  2. Mac evidence: not supplied by me. The signed build and the evidence/ run remain with you, as you stated. I did not run Swift or macOS here.
  3. Nil identity: FilterDataProvider.startFilter logs filter_identity_unavailable at start; FilterPolicy.decide reports that reason for a blocked DNS lookup when context.filterIdentity is nil. Tests were updated to expect it, but I could not run them here. Apps that a rule names still resolve in that state.
  4. dns_no_rule: now in FlowReport.reasonWords as "no rule names this app", covered by FlowReportTests, with an Unreleased changelog entry.
  5. Plan row: now says plainly that any process can start a tool a rule names (curl) and that the resolver's own lookups always pass. On mDNSResponder: app-delegated lookups carry the app's audit token in sourceProcessAuditToken; lookups under its own identity are the ones without a delegated source app token. I did not identify which macOS subsystem originates them, so I am not claiming more.

On your question: the reproduction was reasoned against FilterPolicy.decide and the Swift test sources only. It was not run on a build signed with my Developer ID.

Evidence hashes:

  • Patch a2b5b89..01e815a SHA256: f93ac6eaf05f5373749fc38911512373183111f6e505795c19fa2b2a56cbd2c6
  • Sentinel pr-audit contentHash: f9d91c79f61ec218f1b6fd337d14954b9e4a02e090e4e50d3de247de168d1d78
  • Sentinel verdict after the push: SUSPICIOUS / REVIEW; 3 LOW NETWORK_ACTIVITY, all in docs or test sources and benign.

I am not claiming the Mac-side behaviour is verified here.

@ValentinTorassa

Copy link
Copy Markdown
Owner

Thanks for the second commit. Points 1, 4 and 5 are in as asked, and the startup log for 3 is right.

I applied both commits on top of current main (they conflict in CHANGELOG.md and FlowReportTests.swift; the Unreleased entry goes above 1.1.1). It builds with warnings as errors, and 661 of the 663 tests pass. The two that fail are yours, in blockAllDropsLookupsFromAnAppWithNoRule, lines 120 and 122: matching has no filterIdentity, so probe and adHoc come back as filter_identity_unavailable instead of dns_no_rule. The test is right about what I want. With the identity missing, every app no rule names would be reported as an identity problem and dns_no_rule would never show up. Please keep dns_no_rule as the reason and add the missing identity as its detail, dns_no_rule;no_filter_identity, the way address_mismatch;lookup_failed does.

Two more things: please rebase on main, and I'll run the tests again here. And the description says "I reproduced it with a small program that resolves names it puts data into", while your reply says the reproduction was reasoned from FilterPolicy.decide and the tests only. Please edit the description to say that.

After that I'll do the signed-build run in evidence/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants