carlos / platform Public

devbox on macOS (#488) review fix P1: refuse an env file with a macOS ACL

On macOS an ACL is evaluated before the mode bits, so a 0600 env file
could still grant another account read or write. The loader now asks
internal/fileacl about the open descriptor after the owner and mode
checks: an extended ACL with one or more entries is refused with
DBX-C93, and a failure to read the ACL is refused with DBX-C61 and the
system's words. fileacl reports none on Linux, so Linux is unchanged (a
POSIX ACL's mask is the mode's group bits, which the 0600 check bounds).

TestDevboxServeEnvFileRefusesACL (darwin): a 0600 file given an
'everyone allow read,write' entry is refused and sets nothing; after
chmod -N it loads.

Copy: DBX-C93 approved by Paul unedited; the deck inventory is now
DBX-C1 to DBX-C93 and C93 is in devboxCopyBuilt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 5ca6096ce95bb7e7390574e42f97abb2eb06677d parent 6faa42f
5 files changed, +61 −6
  • approved_devbox_copy_test.go +5 −5
  • devbox_cli.go +3 −0
  • devbox_envfile.go +12 −1
  • devbox_envfile_darwin_test.go +40 −0
  • docs/superpowers/plans/2026-10-30-devbox-mode-copy.md +1 −0

CI failed — run details

Intent

Human

<task-notification> <task-id>adb6e89c9529fd992</task-id> <tool-use-id>toolu_01CLNMbwkrMhZeq5D7FMYXqX</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9b370a04-693c-4bda-b2eb-9a4b08f7626d/tasks/adb6e89c9529fd992.output</output-file> <status>completed</status> <summary>Agent "Build devbox macOS support (#488)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>NEEDS_CONTEXT: the ACL fix needs a new copy row before I can wire it in. Both P2 fixes are done. - **Commit:** `6faa42f0`, on top of `d40e0bea`. Not pushed. - **P2, values:** values are now kept exactly as written after the first `=`. Only the `\r` of a CRLF line ending is removed. Blank and `#` comment lines are judged by their first character that isn't a space or tab. - **P2, FIFO:** the file now opens with O_NONBLOCK, so a FIFO, or a symlink to one, is refused at once by the regular-file check. I left O_NOFOLLOW off on purpose: a symlinked env file is a legitimate setup, and every check runs on the file the open reached. - **P1, groundwork:** new package `internal/fileacl`. `Extended(f)` reads the open descriptor through libSystem's `acl_get_fd`, `acl_get_entry` and `acl_free`, with the same trampoline setup as `internal/launchd` and no cgo. On Linux it reports none, which keeps current behaviour. It is not wired into the loader yet. - **Tests:** the RED run failed as expected: trimmed values, and a FIFO open that hung for the full 5 s. Now all 9 `TestDevboxServeEnvFile*` tests pass, and so do `TestDevbox` in the root package and the `internal/fileacl` and `internal/launchd` tests. Darwin vet and test compile pass on arm64 and amd64 for `.`, `internal/devbox`, `internal/launchd` and `internal/fileacl`. The windows build passes. - **Proposed row DBX-C93** (`devbox_cli.go`): "the environment file &lt;env file&gt; has an access control list, which can let other accounts read or change it. remove it with: chmod -N &lt;env file&gt;". DBX-C62 doesn't fit, because `chmod 600` does not remove an ACL. If `acl_get_fd` fails for any other reason, I'll refuse with DBX-C61 plus the system's error, which needs no new copy. - **After approval:** I'll add the row, move the gate inventory to C93, refuse ACL files in the loader on darwin, add a darwin test (a 0600 file with an ACL entry, refused), rerun the gates and commit. - **Concern:** the darwin tests, including the new `TestExtendedDarwin`, still have to be run on the Mac. Report (fix-round section appended): /home/paulca/.cache/tmp/devbox-macos-report.md</result> <usage><subagent_tokens>211347</subagent_tokens><tool_uses>10</tool_uses><duration_ms>236277</duration_ms></usage> </task-notification>

Human

approved

Human

<task-notification> <task-id>b14tbx97g</task-id> <tool-use-id>toolu_014aUWM2ej5M6sr7RKBR3Wnt</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9b370a04-693c-4bda-b2eb-9a4b08f7626d/tasks/b14tbx97g.output</output-file> <status>completed</status> <summary>Background command "Wait for the DBX-C93 copy result" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 20.3 g CO₂e (2,613,999 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on devbox-macos, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/approved_devbox_copy_test.go b/approved_devbox_copy_test.go
index 60ec5a594..37bb82f55 100644
--- a/approved_devbox_copy_test.go
+++ b/approved_devbox_copy_test.go
@@ -13,7 +13,7 @@ import (
// checked with its helpers, so "applied" means the same thing in every gate:
//
// - TestDevboxCopyRecordIsComplete: the deck names exactly DBX-C1 to
-// DBX-C92;
+// DBX-C93;
// - TestDevboxBuiltCopyIsApproved: an id in devboxCopyBuilt is an approved
// row (a string reaches code only after Paul has approved it);
// - TestDevboxBuiltCopyIsApplied: a built row's text is in the file it
@@ -23,10 +23,10 @@ const devboxCopyRecordPath = "docs/superpowers/plans/2026-10-30-devbox-mode-copy
var devboxCopyIDPattern = regexp.MustCompile(`^DBX-C[1-9][0-9]*$`)
-// devboxCopyIDs is the deck's inventory: DBX-C1 to DBX-C92, pinned.
+// devboxCopyIDs is the deck's inventory: DBX-C1 to DBX-C93, pinned.
var devboxCopyIDs = func() []string {
- ids := make([]string, 0, 92)
- for i := 1; i <= 92; i++ {
+ ids := make([]string, 0, 93)
+ for i := 1; i <= 93; i++ {
ids = append(ids, "DBX-C"+strconv.Itoa(i))
}
return ids
@@ -37,7 +37,7 @@ var devboxCopyIDs = func() []string {
var devboxCopyBuilt = []string{
"DBX-C1", "DBX-C2", "DBX-C3", "DBX-C4", "DBX-C5", "DBX-C6", "DBX-C7", "DBX-C8", "DBX-C9", "DBX-C10", "DBX-C11", "DBX-C12", "DBX-C13", "DBX-C14", "DBX-C15", "DBX-C16", "DBX-C17", "DBX-C18", "DBX-C19", "DBX-C20", "DBX-C21", "DBX-C22", "DBX-C23", "DBX-C24", "DBX-C25", "DBX-C26", "DBX-C27", "DBX-C28", "DBX-C29", "DBX-C30", "DBX-C31", "DBX-C32", "DBX-C33", "DBX-C34", "DBX-C35", "DBX-C36", "DBX-C37", "DBX-C38", "DBX-C39", "DBX-C40", "DBX-C41", "DBX-C42", "DBX-C43", "DBX-C44", "DBX-C45", "DBX-C46", "DBX-C47", "DBX-C48", "DBX-C49", "DBX-C50", "DBX-C51", "DBX-C52", "DBX-C53", "DBX-C54", "DBX-C55", "DBX-C56", "DBX-C57",
// macOS (#488)
- "DBX-C58", "DBX-C59", "DBX-C60", "DBX-C61", "DBX-C62", "DBX-C63", "DBX-C64", "DBX-C65", "DBX-C66", "DBX-C67", "DBX-C68", "DBX-C69", "DBX-C70", "DBX-C71", "DBX-C72", "DBX-C73", "DBX-C74", "DBX-C75", "DBX-C76", "DBX-C77", "DBX-C78", "DBX-C79", "DBX-C80", "DBX-C81", "DBX-C82", "DBX-C83", "DBX-C84", "DBX-C85", "DBX-C86", "DBX-C87", "DBX-C88", "DBX-C89", "DBX-C90", "DBX-C91", "DBX-C92",
+ "DBX-C58", "DBX-C59", "DBX-C60", "DBX-C61", "DBX-C62", "DBX-C63", "DBX-C64", "DBX-C65", "DBX-C66", "DBX-C67", "DBX-C68", "DBX-C69", "DBX-C70", "DBX-C71", "DBX-C72", "DBX-C73", "DBX-C74", "DBX-C75", "DBX-C76", "DBX-C77", "DBX-C78", "DBX-C79", "DBX-C80", "DBX-C81", "DBX-C82", "DBX-C83", "DBX-C84", "DBX-C85", "DBX-C86", "DBX-C87", "DBX-C88", "DBX-C89", "DBX-C90", "DBX-C91", "DBX-C92", "DBX-C93",
}
func mustParseDevboxRecord(t *testing.T) []copyRow {
diff --git a/devbox_cli.go b/devbox_cli.go
index f8b1971cc..529796fa4 100644
--- a/devbox_cli.go
+++ b/devbox_cli.go
@@ -81,6 +81,9 @@ func devboxEnvOpen(file string) string {
func devboxEnvOwner(file string) string {
return fmt.Sprintf("the environment file %s belongs to another account. it must belong to the account the service runs as", file) // DBX-C63
}
+func devboxEnvACL(file string) string {
+ return fmt.Sprintf("the environment file %s has an access control list, which can let other accounts read or change it. remove it with: chmod -N %s", file, file) // DBX-C93
+}
func devboxEnvBadLine(line int, file string) string {
return fmt.Sprintf("line %d of %s is not KEY=VALUE, where KEY is letters, digits and underscores and does not start with a digit. each line must be a setting, a comment starting with #, or blank", line, file) // DBX-C64
}
diff --git a/devbox_envfile.go b/devbox_envfile.go
index 0105da086..4ff672e84 100644
--- a/devbox_envfile.go
+++ b/devbox_envfile.go
@@ -7,7 +7,7 @@ package main
// EnvironmentFile and does not need this, but it works there too.
//
// The rules: the file belongs to the user the service runs as, and no other
-// account may read or change it; every line is KEY=VALUE, a # comment or
+// account may read or change it, by its mode or (on macOS) by an ACL; every line is KEY=VALUE, a # comment or
// blank (judged by its first byte that is not a space or tab); a key
// appears once; a value is everything after the first '=' exactly as
// written, less a CRLF file's \r; and a setting in the file replaces one
@@ -20,6 +20,8 @@ import (
"io"
"os"
"strings"
+
+ "github.com/carlosframework/platform/internal/fileacl"
)
// devboxEnvFileMax bounds the read: an environment file is a few lines.
@@ -48,6 +50,15 @@ func loadDevboxEnvFile(path string, euid int) error {
if fi.Mode().Perm()&0o077 != 0 {
return errors.New(devboxEnvOpen(path))
}
+ // On macOS an ACL can grant another account access that the mode
+ // does not show, so a file with one is refused (fileacl reports none
+ // on Linux, where the mode check already bounds a POSIX ACL). A
+ // failure to read the ACL refuses too.
+ if acl, err := fileacl.Extended(f); err != nil {
+ return errors.Join(errors.New(devboxEnvUnreadable(path)), err)
+ } else if acl {
+ return errors.New(devboxEnvACL(path))
+ }
raw, err := io.ReadAll(io.LimitReader(f, devboxEnvFileMax+1))
if err != nil {
return errors.Join(errors.New(devboxEnvUnreadable(path)), err)
diff --git a/devbox_envfile_darwin_test.go b/devbox_envfile_darwin_test.go
new file mode 100644
index 000000000..2cd3c1891
--- /dev/null
+++ b/devbox_envfile_darwin_test.go
@@ -0,0 +1,40 @@
+//go:build darwin
+
+package main
+
+import (
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+)
+
+// A 0600 file with an ACL entry granting another account access is
+// refused, and sets nothing; once chmod -N removes the ACL it loads.
+func TestDevboxServeEnvFileRefusesACL(t *testing.T) {
+ p := filepath.Join(t.TempDir(), "env")
+ if err := os.WriteFile(p, []byte("DBX_TEST_A=one\n"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Chmod(p, 0o600); err != nil {
+ t.Fatal(err)
+ }
+ if out, err := exec.Command("/bin/chmod", "+a", "everyone allow read,write", p).CombinedOutput(); err != nil {
+ t.Fatalf("chmod +a: %v: %s", err, out)
+ }
+ t.Setenv("DBX_TEST_A", "")
+ err := loadDevboxEnvFile(p, os.Geteuid())
+ want := "the environment file " + p + " has an access control list, which can let other accounts read or change it. remove it with: chmod -N " + p
+ if err == nil || err.Error() != want {
+ t.Fatalf("load = %v, want %q", err, want)
+ }
+ if os.Getenv("DBX_TEST_A") != "" {
+ t.Fatal("a refused file set its variables")
+ }
+ if out, err := exec.Command("/bin/chmod", "-N", p).CombinedOutput(); err != nil {
+ t.Fatalf("chmod -N: %v: %s", err, out)
+ }
+ if err := loadDevboxEnvFile(p, os.Geteuid()); err != nil || os.Getenv("DBX_TEST_A") != "one" {
+ t.Fatalf("load without the ACL = %v (DBX_TEST_A %q)", err, os.Getenv("DBX_TEST_A"))
+ }
+}
diff --git a/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md b/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md
index 0ea1292c9..4b15cb952 100644
--- a/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md
+++ b/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md
@@ -174,3 +174,4 @@ plist's `Sockets` entry, such as `Listeners`; `<count>` a number;
| DBX-C90 | infra/devbox/README.md | Once the tailnet is up, start the service again. | approved |
| DBX-C91 | infra/devbox/README.md | Then add the DNS record and run the checks below. | approved |
| DBX-C92 | infra/devbox/README.md | On a Mac, use lsof instead of ss to see what is listening, and read the log file instead of journalctl. | approved |
+| DBX-C93 | devbox_cli.go | the environment file <env file> has an access control list, which can let other accounts read or change it. remove it with: chmod -N <env file> | approved |