Skip to content

[Bug]: macOS drops executable paths before matching full-path process rules #288

Closed

Description

@geniucker-dev

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

In AppProxyProvider.swift:

let fullPath = String(cString: pathBuffer)
let processName = (fullPath as NSString).lastPathComponent
// The cache also stores processName.
return processName

FlowProcess 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:

  1. Set executable to /opt/example-app-a/bin/worker and basename to its lastPathComponent.
  2. Construct ProxyRule.FlowProcess(bundleId: "-", processName: basename), matching the provider's current behavior for a standalone executable.
  3. Compare an absolute-path process rule with a filename rule, using hosts and ports * and protocol BOTH.
  4. 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

No one assigned

    Labels

    Fixed ReleasedMacOSbug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions