fix(webui): sanitize WorkspaceSecurityError messages in API responses (AUDIT-L2)#277
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: xlabtg#276
Error responses from workspace routes were returning the raw WorkspaceSecurityError message, which included the user-supplied inputPath and could leak absolute server paths (e.g. /home/<user>/...). - Return generic "Workspace path is not allowed" to the client for all WorkspaceSecurityError cases (403) - Log attempted path and original message server-side via warn - Update workspace-raw test to expect the generic message - Add workspace-security-leak test suite covering /raw, /read, /write endpoints and asserting no /home/, /tmp/, or C:\ substrings leak Closes xlabtg#276
Solution summaryThe fix is complete. Here's a summary of what was done: Root cause: Fix (
Tests:
PR: #277 This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $1.070874📊 Context and tokens usage:
Total: (56.9K + 2.2M cached) input tokens, 13.2K output tokens, $1.070874 cost 🤖 Models used:
📎 Log file uploaded as Gist (1318KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart triggered (iteration 1)Reason: Merge conflicts detected Starting new session to address the issues. Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable. |
Resolves merge conflict in .gitkeep (timestamp-only conflict). Brings in upstream changes: autonomous mode admin_ids fix (AUDIT-H6), config schema version sync, and related test/doc updates.
🔄 Auto-restart-until-mergeable Log (iteration 1)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $0.180168📊 Context and tokens usage:
Total: (12.4K + 320.0K cached) input tokens, 2.5K output tokens, $0.180168 cost 🤖 Models used:
📎 Log file uploaded as Gist (1707KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
Summary
Fixes [AUDIT-L2] from issue #276: workspace API error responses were returning the raw
WorkspaceSecurityErrormessage, which could include user-supplied paths such as/home/<user>/..., leaking server filesystem information to the client.Changes
src/webui/routes/workspace.ts: UpdatederrorResponse()to return a generic"Workspace path is not allowed"message for allWorkspaceSecurityErrorcases (HTTP 403), and log the actualattemptedPathand message server-side atwarnlevel.src/webui/__tests__/workspace-raw.test.ts: Updated the path traversal test to expect the new generic message.src/webui/__tests__/workspace-security-leak.test.ts: New test suite verifying that/raw,/read, and/writeendpoints never include/home/,/tmp/, orC:\in 403 responses, and that the internal error message is not exposed.How to reproduce the issue
After fix
Server logs:
WARN workspace-routes { attemptedPath: '/home/alice/../../etc/passwd', message: '...' } workspace path rejectedTest plan
workspace-security-leak.test.ts: 5 tests covering path leak prevention across endpoints/home/,/tmp/, orC:\substrings for security errorsFixes #276