Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,6 @@ export function readConfigAdmissionSnapshot(): ConfigAdmissionSnapshot {

const CONFIG_MUTATION_DB_FILENAME = "config-mutation.sqlite";
const CONFIG_MUTATION_DB_SIDECARS = ["-journal", "-wal", "-shm"] as const;
let warnedConfigMutationDirectoryAcl = false;

export class ConfigMutationLockError extends Error {
readonly code = "CONFIG_MUTATION_LOCK_UNAVAILABLE";
Expand All @@ -1971,20 +1970,11 @@ function configMutationDatabasePath(): string {
try { chmodSync(dir, 0o700); } catch { /* best-effort on existing dir */ }
}
if (windowsSecretAclApplies()) {
try {
// Distinct timeout memo from management-token directory harden: a required
// management-dir timeout must not poison config mutation on the same home
// (windows-latest server-management-auth cases).
hardenSecretDir(dir, { required: true, timeoutMemoKey: `${dir}::config-mutation` });
} catch (error) {
if (!warnedConfigMutationDirectoryAcl) {
warnedConfigMutationDirectoryAcl = true;
const diagnostics = error instanceof Error ? error.message : "ACL hardening failed";
console.warn(
`[opencodex] Config mutation coordination directory ACL hardening did not complete; continuing without it. ${diagnostics}`,
);
}
}
// Distinct timeout memo from management-token directory harden: a required
// management-dir timeout must not poison config mutation on the same home
// (windows-latest server-management-auth cases). This must fail closed because
// the directory also contains secret-bearing configuration and credential files.
hardenSecretDir(dir, { required: true, timeoutMemoKey: `${dir}::config-mutation` });
}
const path = join(dir, CONFIG_MUTATION_DB_FILENAME);
recordOwnedConfigPath(dir, path);
Expand Down
6 changes: 3 additions & 3 deletions tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1903,16 +1903,16 @@ describe("config.ts – Windows ACL hardening integration", () => {
}
});

test("saveConfig degrades when config-mutation directory hardening fails on win32", () => {
test("saveConfig fails closed when config directory hardening fails on win32", () => {
const origPlatform = process.platform;
Object.defineProperty(process, "platform", { value: "win32", configurable: true });
try {
const spy = spyOn(windowsAcl, "hardenSecretDir").mockImplementation((_path, opts) => {
if (opts?.required) throw new Error("ACL hardening failed: access denied");
return { ok: true };
});
expect(() => saveConfig(getDefaultConfig())).not.toThrow();
expect(existsSync(getConfigPath())).toBe(true);
expect(() => saveConfig(getDefaultConfig())).toThrow("ACL hardening failed: access denied");
expect(existsSync(getConfigPath())).toBe(false);
spy.mockRestore();
} finally {
Object.defineProperty(process, "platform", { value: origPlatform, configurable: true });
Expand Down
Loading