Skip to content

fix(webui): sanitize WorkspaceSecurityError messages in API responses (AUDIT-L2)#277

Merged
xlabtg merged 3 commits intoxlabtg:mainfrom
konard:issue-276-44dce33dda72
Apr 22, 2026
Merged

fix(webui): sanitize WorkspaceSecurityError messages in API responses (AUDIT-L2)#277
xlabtg merged 3 commits intoxlabtg:mainfrom
konard:issue-276-44dce33dda72

Conversation

@konard
Copy link
Copy Markdown

@konard konard commented Apr 22, 2026

Summary

Fixes [AUDIT-L2] from issue #276: workspace API error responses were returning the raw WorkspaceSecurityError message, which could include user-supplied paths such as /home/<user>/..., leaking server filesystem information to the client.

Changes

  • src/webui/routes/workspace.ts: Updated errorResponse() to return a generic "Workspace path is not allowed" message for all WorkspaceSecurityError cases (HTTP 403), and log the actual attemptedPath and message server-side at warn level.
  • 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 /write endpoints never include /home/, /tmp/, or C:\ in 403 responses, and that the internal error message is not exposed.

How to reproduce the issue

GET /api/workspace/read?path=/home/alice/../../etc/passwd
→ {"success":false,"error":"Access denied: Path '/home/alice/../../etc/passwd' is outside the workspace..."}

After fix

GET /api/workspace/read?path=/home/alice/../../etc/passwd
→ {"success":false,"error":"Workspace path is not allowed"}

Server logs: WARN workspace-routes { attemptedPath: '/home/alice/../../etc/passwd', message: '...' } workspace path rejected

Test plan

  • All existing workspace tests pass
  • New workspace-security-leak.test.ts: 5 tests covering path leak prevention across endpoints
  • API response never contains /home/, /tmp/, or C:\ substrings for security errors

Fixes #276

konard added 2 commits April 22, 2026 20:38
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
@konard konard changed the title [WIP] audit-l2-error-responses-leak-workspace-paths fix(webui): sanitize WorkspaceSecurityError messages in API responses (AUDIT-L2) Apr 22, 2026
@konard konard marked this pull request as ready for review April 22, 2026 20:42
@konard
Copy link
Copy Markdown
Author

konard commented Apr 22, 2026

Solution summary

The fix is complete. Here's a summary of what was done:

Root cause: errorResponse() in src/webui/routes/workspace.ts passed the raw WorkspaceSecurityError message to the client. Those messages (from validator.ts) include the user-supplied inputPath (e.g. "Access denied: Path '/home/alice/../../etc/passwd' is outside the workspace..."), leaking server filesystem structure.

Fix (src/webui/routes/workspace.ts):

  • Added createLogger("workspace-routes")
  • errorResponse() now catches WorkspaceSecurityError specifically: logs { attemptedPath, message } at warn level server-side, and returns the generic string "Workspace path is not allowed" to the client with HTTP 403

Tests:

  • Updated workspace-raw.test.ts to expect the new generic message
  • New workspace-security-leak.test.ts with 5 tests covering /raw, /read, /write endpoints, asserting no /home/, /tmp/, or C:\ substrings appear in 403 responses

PR: #277


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Author

konard commented Apr 22, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.070874

📊 Context and tokens usage:

  • 57.3K / 1M (6%) input tokens, 13.2K / 64K (21%) output tokens

Total: (56.9K + 2.2M cached) input tokens, 13.2K output tokens, $1.070874 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (1318KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Author

konard commented Apr 22, 2026

🔄 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.
@konard
Copy link
Copy Markdown
Author

konard commented Apr 22, 2026

🔄 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:

  • 23.1K / 1M (2%) input tokens, 2.5K / 64K (4%) output tokens

Total: (12.4K + 320.0K cached) input tokens, 2.5K output tokens, $0.180168 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (1707KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audit-l2-error-responses-leak-workspace-paths

2 participants