Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix: spawn Apple /bin/chmod by absolute path when hardening credentials

Arthur Bogaart2a47bdb8e74e
diff --git a/server/standalone/key-setup-hardening.mjs b/server/standalone/key-setup-hardening.mjs
index 002ccabdc..e2d11182c 100644
--- a/server/standalone/key-setup-hardening.mjs
+++ b/server/standalone/key-setup-hardening.mjs
@@ -123,7 +123,11 @@ export function hardenCredentialFile(
if (platform !== 'win32') {
try {
if (platform === 'darwin') {
- const aclRemoval = spawn('chmod', ['-N', filepath], {
+ // `-N` (strip the ACL) is Apple-only. Spawn /bin/chmod by absolute
+ // path, never by name: a Nix/Homebrew coreutils profile puts GNU chmod
+ // first on PATH, and GNU chmod rejects `-N` — which read as a
+ // hardening failure and refused every save on such machines.
+ const aclRemoval = spawn('/bin/chmod', ['-N', filepath], {
stdio: 'ignore',
});
if (!commandCompletedSuccessfully(aclRemoval)) return false;
diff --git a/src/keySetupHardening.test.mjs b/src/keySetupHardening.test.mjs
index 2578be37d..c519576e3 100644
--- a/src/keySetupHardening.test.mjs
+++ b/src/keySetupHardening.test.mjs
@@ -55,6 +55,21 @@ test('macOS ACL removal failure stops before chmod and fails closed', () => {
assert.deepEqual(fileSystem.calls, [], 'mode bits must not disguise an ACL-removal failure');
});
+test('macOS ACL removal spawns Apple /bin/chmod by absolute path, not via PATH', () => {
+ const spawned = [];
+ hardenCredentialFile(FILE, {
+ platform: 'darwin',
+ fileSystem: fileSystemWithMode(0o100600),
+ spawn(command, args) {
+ spawned.push([command, args]);
+ return { status: 0, signal: null };
+ },
+ });
+ // A coreutils-first PATH (Nix home-manager, Homebrew) resolves bare `chmod`
+ // to GNU chmod, which has no `-N` and would fail every save.
+ assert.deepEqual(spawned, [['/bin/chmod', ['-N', FILE]]]);
+});
+
test('POSIX hardening verifies the resulting 0600 mode', () => {
const goodFs = fileSystemWithMode(0o100600);
assert.equal(hardenCredentialFile(FILE, {