Repository navigation
Description
Platform
macOS
Affected source revisions
master: cb897b017a88a142ec803c3af138b0ad75c2ae12
dev: a2855e26b222cff35ef56a5ad40542dcd5902244
Describe the bug
On macOS, getProcessName(from:) obtains the executable's full path through proc_pidpath(), then keeps only lastPathComponent. The matcher receives a bundle identifier and a filename, even when the rule contains an absolute path.
This prevents path rules from distinguishing executables with the same filename in different directories. For example, consider these hypothetical paths, unrelated to any installed application:
/opt/example-app-a/bin/worker
/opt/example-app-b/bin/worker
A rule for /opt/example-app-a/bin/worker should match only the first executable. A filename rule for worker should match both.
Source
let fullPath = String(cString: pathBuffer)
let processName = (fullPath as NSString).lastPathComponent
// The cache also stores processName.
return processNameFlowProcess and Matcher already distinguish path patterns from filename patterns. A pattern containing / is compared with cand.path, but the provider has already discarded the directory.
Reproduction at the matcher level
Using the existing ProxyRule and ProxyRule.Matcher definitions from the linked dev revision:
- Set
executableto/opt/example-app-a/bin/workerandbasenameto itslastPathComponent. - Construct
ProxyRule.FlowProcess(bundleId: "-", processName: basename), matching the provider's current behavior for a standalone executable. - Compare an absolute-path process rule with a filename rule, using hosts and ports
*and protocol BOTH. - Repeat with
processName: executable.
The directory is unavailable to the matcher in the first case. Preserving the path allows the existing matcher to select either the full path or the filename according to the rule.
This report concerns the source and matcher behavior. It does not claim a test of a patched, signed Network Extension.
Other platforms and possible fix
Windows selects the full path when the pattern contains a path separator. Linux tries both the filename and the full executable path. These comparisons are from source inspection.
Could macOS retain the full path in its process candidate and PID/version cache? The existing matcher can derive the filename from that path, which should preserve filename and bundle-ID matching.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(macos): rules can match a program by its full path (#288)
test(macos): tests for rules that match a program by its full path (#288