Skip to content

[rajashidattapy] fix: apply os.sep boundary to serve/seed path guards (#136) - #139

Closed
rajarshidattapy wants to merge 1 commit into
openswarm-ai:mainfrom
rajarshidattapy:rajashidattapy/fix/outputs-workspace-prefix-collision
Closed

rajarshidattapy wants to merge 1 commit into
openswarm-ai:mainfrom
rajarshidattapy:rajashidattapy/fix/outputs-workspace-prefix-collision

Conversation

@rajarshidattapy

Copy link
Copy Markdown

Description

Fixes #136.

serve_workspace_file() and the workspace seed writer validated workspace containment using a bare startswith(folder) comparison. As a result, a sibling workspace whose ID was a string prefix of the target workspace (e.g. abc vs. abc-evil) satisfied the containment check, leaving these two endpoints inconsistent with the stronger validation already implemented by write_workspace_file() and delete_workspace_file().

Changes

  • Update serve_workspace_file() and the workspace seed writer to use the same directory-boundary check already employed by the write/delete endpoints:
    full_path != folder_norm and not full_path.startswith(folder_norm + os.sep)
  • Prevent sibling workspace prefix collisions such as abc matching abc-evil.
  • Align all workspace path validation sites on a single containment rule for consistent behavior.

Validation

  • Verified that the updated guard rejects prefix-colliding sibling workspace paths while preserving valid in-workspace access.
  • Behavior is now consistent across all four workspace file endpoints.

…#136)

serve_workspace_file and the workspace seed writer checked containment with
a bare startswith(folder), so a sibling workspace whose id is a string
prefix of the target (abc vs abc-evil) passed the guard. Match the stronger
form already used by write_workspace_file/delete_workspace_file:
startswith(folder_norm + os.sep) with the folder-itself equality escape.
@rajarshidattapy
rajarshidattapy force-pushed the rajashidattapy/fix/outputs-workspace-prefix-collision branch from 196ba06 to 0e83dcc Compare July 30, 2026 11:45
@rajarshidattapy

Copy link
Copy Markdown
Author

Hey @ciregenz can you review this PR?

@rajarshidattapy rajarshidattapy closed this by deleting the head repository Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant