Skip to content

fix(security): harden file permissions, remove info leaks (#3363, #3365, #3360)#3375

Merged
aegis-gh-agent[bot] merged 2 commits into
developfrom
fix/security-hardening-3363-3365-3360
May 14, 2026
Merged

fix(security): harden file permissions, remove info leaks (#3363, #3365, #3360)#3375
aegis-gh-agent[bot] merged 2 commits into
developfrom
fix/security-hardening-3363-3365-3360

Conversation

@OneStepAt4time

Copy link
Copy Markdown
Owner

Summary

Three security hardening fixes from the dogfooding audit:

#3363 β€” File permissions (P2)

All state files now created with mode: 0o600 (owner-only):

  • state.json (JsonFileStore β€” save + backup)
  • pipelines.json (JsonFileStore β€” save)
  • analytics-cache.json (MetricsCache)
  • acp-local-storage.json (ACP localStorage)

Previously these were world-readable (644), exposing session metadata, tenant IDs, and owner key IDs to any local user.

#3365 β€” workDir info leak (P2)

Removed allowed directories list from INVALID_WORKDIR error messages. The error still says 'not in allowed list' but no longer reveals which directories exist on the host filesystem.

#3360 β€” Tenant existence leak (P2)

Changed cross-tenant session access from 403 ('session belongs to another tenant') β†’ 404 ('Session not found'). Consistent with how write endpoints already behave. Prevents session ID enumeration across tenants.

Test plan

  • Build passes (npm run build)
  • Gate passes (npm run gate)
  • File permissions: start Aegis, verify ls -la ~/.aegis/state.json shows -rw-------
  • workDir leak: POST with invalid workDir, verify error does NOT contain allowed dirs
  • Tenant leak: cross-tenant GET returns 404 with 'Session not found' (not 403)

Security review

  • All changes are defensive β€” no new attack surface introduced
  • No behavior change for legitimate use cases

@aegis-gh-agent aegis-gh-agent Bot 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.

Review: Request Changes

CI failing β€” 2 test failures from the #3360 fix (403 to 404 for cross-tenant sessions). The behavior change is correct but two existing tests still assert 403:

  1. dashboard-session-auth.test.ts:203 β€” expects 403, now returns 404
  2. multitenancy-1944.test.ts:403 β€” expects 403, now returns 404

Update both test assertions to expect 404 and I will approve immediately.

Everything else looks good β€” file permissions 0o600 correct, workDir leak removal correct, 403 to 404 correct security practice.

@aegis-gh-agent aegis-gh-agent Bot 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.

Review: Still Requesting Changes

CI still failing β€” same 2 tests as before. The test assertion fixes (403 β†’ 404) are not in this PR.

Failing tests (same as previous review):

  1. src/tests/dashboard-session-auth.test.ts:203

    expect(otherTenant.statusCode).toBe(403)  // needs .toBe(404)
    
  2. src/tests/multitenancy-1944.test.ts:403

    expect(reply.status).toHaveBeenCalledWith(403)  // needs .toHaveBeenCalledWith(404)
    

These two files need to be modified and included in the PR. The #3360 fix correctly changes the behavior from 403 to 404 for cross-tenant session access, but the existing tests still assert 403.

Once these two test files are updated, CI will pass and I will approve immediately.

aegis-gh-agent[bot]
aegis-gh-agent Bot previously approved these changes May 14, 2026

@aegis-gh-agent aegis-gh-agent Bot 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.

βœ… Approved.

Test assertions fixed β€” both now expect 404 for cross-tenant session access:

  1. dashboard-session-auth.test.ts β†’ .toBe(404)
  2. multitenancy-1944.test.ts β†’ .toHaveBeenCalledWith(404)

Security fixes confirmed correct:

  • #3363: File permissions 0o600 on all state files βœ…
  • #3365: workDir error no longer leaks allowed directories βœ…
  • #3360: Cross-tenant session GET returns 404 (not 403) βœ…

CI green. All 9 merge gates pass. Merging.

…, #3360)

- #3363: Set mode 0o600 on all state file writes (state.json,
  pipelines.json, analytics-cache.json, acp-local-storage.json).
  Previously created world-readable (644), exposing session metadata.

- #3365: Remove allowed directories list from workDir validation
  error messages. The error still says 'not in allowed list' but
  no longer reveals which directories are allowed on the host.

- #3360: Return 404 (not 403) on cross-tenant session access
  attempts. Previously the error said 'session belongs to another
  tenant', confirming the session's existence. Now returns the
  same 'Session not found' as write endpoints for consistency.

Refs: #3363, #3365, #3360
#3360 changed cross-tenant session access from 403 to 404 to avoid
tenant enumeration. Two tests still asserted 403.

@aegis-gh-agent aegis-gh-agent Bot 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.

βœ… Re-approved. Review was dismissed after new commit but diff is identical to previous approved state.

All 9 merge gates pass:

  1. βœ… Full diff reviewed β€” file permissions 0o600, workDir leak removal, 403β†’404 tenant leak fix
  2. βœ… No conflicts β€” MERGEABLE
  3. βœ… CI green β€” all checks passing
  4. βœ… No regressions β€” tests updated for new behavior
  5. βœ… Unit tests β€” assertions updated (403β†’404) for both test files
  6. βœ… E2E β€” dashboard-e2e passing
  7. βœ… Documented β€” PR body covers all 3 fixes with test plan
  8. βœ… Security clean β€” Gitleaks, Trivy, CodeQL, GitGuardian all pass. Defensive-only changes.
  9. βœ… Targets develop

Security fixes confirmed:

  • #3363: File permissions 0o600 on all state files (JsonFileStore, MetricsCache, ACP localStorage)
  • #3365: workDir error no longer leaks allowed directory paths
  • #3360: Cross-tenant session access returns 404 (not 403), preventing session ID enumeration

@aegis-gh-agent aegis-gh-agent Bot merged commit 4d22cc2 into develop May 14, 2026
17 checks passed
@aegis-gh-agent aegis-gh-agent Bot deleted the fix/security-hardening-3363-3365-3360 branch May 14, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant