fix(security): harden file permissions, remove info leaks (#3363, #3365, #3360)#3375
Conversation
There was a problem hiding this comment.
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:
- dashboard-session-auth.test.ts:203 β expects 403, now returns 404
- 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.
There was a problem hiding this comment.
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):
-
src/tests/dashboard-session-auth.test.ts:203
expect(otherTenant.statusCode).toBe(403) // needs .toBe(404) -
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.
There was a problem hiding this comment.
β Approved.
Test assertions fixed β both now expect 404 for cross-tenant session access:
dashboard-session-auth.test.tsβ.toBe(404)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.
aab7e71 to
6b501a0
Compare
There was a problem hiding this comment.
β Re-approved. Review was dismissed after new commit but diff is identical to previous approved state.
All 9 merge gates pass:
- β Full diff reviewed β file permissions 0o600, workDir leak removal, 403β404 tenant leak fix
- β No conflicts β MERGEABLE
- β CI green β all checks passing
- β No regressions β tests updated for new behavior
- β Unit tests β assertions updated (403β404) for both test files
- β E2E β dashboard-e2e passing
- β Documented β PR body covers all 3 fixes with test plan
- β Security clean β Gitleaks, Trivy, CodeQL, GitGuardian all pass. Defensive-only changes.
- β Targets develop
Security fixes confirmed:
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_WORKDIRerror 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
npm run build)npm run gate)ls -la ~/.aegis/state.jsonshows-rw-------Security review