Skip to content

fix(cli): honor Windows ACLs for saved credentials (0.14.3) - #37

Merged
farhan-helmy merged 3 commits into
boxcompute:mainfrom
kyzer1023:fix/windows-credential-acls
Nov 30, 2026
Merged

farhan-helmy merged 3 commits into
boxcompute:mainfrom
kyzer1023:fix/windows-credential-acls

Conversation

@kyzer1023

@kyzer1023 kyzer1023 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Native Windows reports POSIX-style mode 0666 even for a private credential file. The CLI rejected that file before commands such as bxc whoami could authenticate.

Check Windows ACLs on the open credential and configuration files. Login writes new files with private ACLs. The POSIX mode checks still apply on other platforms, and CI runs the credential tests on Windows.

How it was tested

  • Native Windows whoami and workspaces, plus credential reads and writes on Node 20, 22, and 24.
  • Windows typecheck, lint, build, and 37 focused tests passed. The full Bun and Go test suites and packed CLI smoke tests on Node 20, 22, and 24 passed on Linux.
  • Bumped the package and changelog to 0.14.3.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@farhan-helmy farhan-helmy 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.

Thanks for taking this on. Native Windows can't use a saved credential at all today, and checking the ACL on the open handle is a nice way to avoid a race. POSIX behavior is unchanged, and the Linux job and the Node 20/22/24 smoke tests pass.

The new Windows job fails all four tests, though (run 46220114139). Each test stops at the first directory check with Could not enforce the Windows ACL for …. stderr is discarded, so the log doesn't say why.

My best guess is PSModulePath. Actions runs bun test from PowerShell 7. A Windows PowerShell 5.1 started from a child of pwsh inherits pwsh's module paths, then loads pwsh's copy of Microsoft.PowerShell.Security (where Get-Acl lives) and fails (PowerShell/PowerShell#18530). Add-Type (Microsoft.PowerShell.Utility) is likely hit the same way. If that's the cause, anyone running bxc from a pwsh terminal gets the same error, not just CI. Native runs from cmd or Windows PowerShell 5.1 wouldn't show it.

Before merge:

  1. Get the Windows job passing. The smallest fix is to drop PSModulePath from the child's environment. Better is to use only .NET APIs, so no module has to load at all (inline).
  2. Add a bounded slice of PowerShell's stderr to the generic error, so the next failure can be diagnosed from a log or a user report.

The smaller notes are inline. I'll approve CI again once you push.

Comment thread src/windows-acl.ts Resolved
Comment thread src/windows-acl.ts Resolved
Comment thread src/windows-acl.ts Resolved
Comment thread src/windows-acl.ts Resolved
Comment thread src/windows-acl.ts Resolved
Comment thread src/config.ts Resolved
Comment thread CHANGELOG.md Resolved

@farhan-helmy farhan-helmy 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.

Thanks, this covers everything. The helper now uses only .NET calls, so it works from PowerShell 7 (the CI shell), and helper errors include PowerShell's message. All five Windows tests pass, along with the Linux validation and the Node 20, 22 and 24 package tests.

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