Skip to content

[WRONG BRANCH] fix(config): fail closed on Windows ACL hardening - #53

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-windows-acl-timeout-vulnerability
Draft

[WRONG BRANCH] fix(config): fail closed on Windows ACL hardening#53
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-windows-acl-timeout-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A prior change silently continued after Windows ACL hardening timeouts for required paths, allowing sensitive config or credential files to be published with unverified/inherited ACLs; this reestablishes the original fail-closed contract for write-path hardening.

Description

  • Remove the soft-fail/catch around hardenSecretDir(dir, { required: true, ... }) in configMutationDatabasePath so required directory ACL hardening now propagates failures instead of continuing.
  • Remove the now-unused warnedConfigMutationDirectoryAcl path and add a clarifying comment that required hardening remains fail-closed.
  • Update the focused regression test in tests/config.test.ts to assert that saveConfig throws on required ACL harden failure and that the config file is not created.
  • Changes touch src/config.ts and tests/config.test.ts and preserve the existing atomic writer and secret hardening semantics elsewhere.

Testing

  • Ran git diff --check to verify no whitespace or trivial diff issues; it passed.
  • Ran the focused tests bun test tests/config.test.ts tests/windows-secret-acl.test.ts which passed (269 tests, 0 failed).
  • Ran bun run typecheck which completed successfully.
  • Ran bun run privacy:scan which reported Privacy scan passed.
  • Ran the full bun run test suite; most tests ran and many passed, but the broad suite encountered a pre-existing unrelated 30s timeout in one test during that run (test harness timeout), not caused by this change.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Configuration saves now fail safely when required directory security hardening cannot be applied.
    • Prevents configuration files from being created if security protections cannot be established.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Windows config-directory ACL hardening now fails closed. Hardening errors propagate from saveConfig, and the Windows integration test verifies that the config file remains absent after failure.

Changes

Config hardening

Layer / File(s) Summary
Required ACL enforcement
src/config.ts, tests/config.test.ts
saveConfig no longer catches and ignores Windows config-directory ACL errors. The test now expects an ACL error and confirms that no config file is created.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: lidge-jun, wibias, ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: required Windows ACL hardening now fails closed in configuration handling.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-windows-acl-timeout-vulnerability

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the title fix(config): fail closed on Windows ACL hardening [WRONG BRANCH] fix(config): fail closed on Windows ACL hardening Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 7, 2026 12:19
@github-actions github-actions Bot added the bug Something isn't working label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/config.test.ts`:
- Around line 1906-1915: Update the saveConfig regression test’s hardenSecretDir
spy assertion to verify that the timeout memo key argument ends with
“::config-mutation,” while preserving the existing required-error and
absent-config assertions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a39f4df3-0c1c-4997-a1ff-5e9052288d59

📥 Commits

Reviewing files that changed from the base of the PR and between 2468502 and 20cff4c.

📒 Files selected for processing (2)
  • src/config.ts
  • tests/config.test.ts

Comment thread tests/config.test.ts
Comment on lines +1906 to +1915
test("saveConfig fails closed when config-mutation 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/);
expect(existsSync(getConfigPath())).toBe(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover the isolated timeout memo in the regression test.

The test verifies required: true and the absent config file. It does not verify the timeoutMemoKey passed by src/config.ts Line 1978. If that key regresses to the directory path, a required management-token timeout can poison config mutations while this test still passes. Assert that the spy receives a key ending in ::config-mutation.

Suggested assertion
       expect(existsSync(getConfigPath())).toBe(false);
+      expect(spy).toHaveBeenCalledWith(
+        expect.any(String),
+        expect.objectContaining({
+          required: true,
+          timeoutMemoKey: expect.stringMatching(/::config-mutation$/),
+        }),
+      );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test("saveConfig fails closed when config-mutation 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/);
expect(existsSync(getConfigPath())).toBe(false);
test("saveConfig fails closed when config-mutation 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())).toThrow(/ACL hardening failed/);
expect(existsSync(getConfigPath())).toBe(false);
expect(spy).toHaveBeenCalledWith(
expect.any(String),
expect.objectContaining({
required: true,
timeoutMemoKey: expect.stringMatching(/::config-mutation$/),
}),
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/config.test.ts` around lines 1906 - 1915, Update the saveConfig
regression test’s hardenSecretDir spy assertion to verify that the timeout memo
key argument ends with “::config-mutation,” while preserving the existing
required-error and absent-config assertions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant