Skip to content

Fix Softnet SUID setup commands - #1273

Open
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/softnet-suid-setup
Open

Fix Softnet SUID setup commands#1273
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/softnet-suid-setup

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jun 22, 2026

Copy link
Copy Markdown

Summary

  • probe the exact resolved Softnet executable when checking passwordless sudo
  • pass chown and chmod arguments directly instead of interpolating the executable path into sh -c
  • restore Tart as the terminal foreground process group after each interactive sudo invocation

Validation

  • swift build
  • swift test

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81cba367a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/tart/Network/Softnet.swift
@fallintoplace
fallintoplace force-pushed the fix/softnet-suid-setup branch from 81cba36 to 8142831 Compare June 22, 2026 21:40
@fkorotkov-oai
fkorotkov-oai requested a review from edi-oai July 17, 2026 12:59
fkorotkov-oai
fkorotkov-oai previously approved these changes Jul 17, 2026

@edi-oai edi-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Minh 👋

Could you clarify the threat model this is intended to address?

The implementation appears to treat PATH as untrusted while treating paths under the Homebrew Cellar as trusted. On a typical installation, however, the Homebrew prefix is user-owned, so an actor with same-user filesystem access could potentially construct or replace a path that satisfies these checks.

The validation also prevents using a locally built softnet through PATH.

Would you be open to narrowing the PR to the useful correctness improvements that do not introduce this new trust policy?

In particular, probing the exact resolved softnet avoids checking a different binary:

-process.arguments = ["--non-interactive", "softnet", "--help"]
+process.arguments = ["--non-interactive", softnetExecutablePath, "--help"]

The removal of sh -c in favor of passing arguments directly through runInteractiveSudo also seems worth keeping.

@fallintoplace
fallintoplace force-pushed the fix/softnet-suid-setup branch from 8142831 to 62b9f9d Compare July 22, 2026 09:10
@fallintoplace fallintoplace changed the title Harden Softnet SUID setup Fix Softnet SUID setup commands Jul 22, 2026
@fallintoplace

Copy link
Copy Markdown
Author

I removed the Homebrew/path validation and narrowed the PR to using the resolved Softnet path for the sudo check and running chown/chmod directly instead of through sh -c.
I also fixed the terminal process group handling so each sudo call restores Tart as the foreground process group before returning.
I rebased onto the latest main, and the build and tests pass. Could you take another look when you have time?

@fallintoplace fallintoplace changed the title Fix Softnet SUID setup commands Harden Softnet SUID setup against PATH hijacking Jul 22, 2026
@fallintoplace fallintoplace changed the title Harden Softnet SUID setup against PATH hijacking Fix PATH hijacking in Softnet SUID setup Jul 22, 2026
@edi-oai

edi-oai commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@fallintoplace thanks for the updates, I still think this PR could be simplified quite a bit.

Could you please address the original question in #1273 (review)?

@fallintoplace
fallintoplace force-pushed the fix/softnet-suid-setup branch from 64aa1dd to 62b9f9d Compare July 23, 2026 11:44
@fallintoplace fallintoplace changed the title Fix PATH hijacking in Softnet SUID setup Fix Softnet SUID setup commands Jul 23, 2026
@fallintoplace

fallintoplace commented Jul 23, 2026

Copy link
Copy Markdown
Author

The threat I had in mind was a manipulated PATH causing Tart to resolve an unexpected Softnet binary, which could then be configured during the sudo setup if the user approved the prompt.

I think that scenario is possible, but treating the user-owned Homebrew prefix as trusted does not address it correctly. I removed that validation and narrowed the PR to using the same resolved Softnet path consistently and avoiding sh -c when running chown and chmod.

Let me know if further adjustments are needed.

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.

3 participants