Skip to content

refactor(security): drop the dead symlink guard in workspace path check #3854

Closed

Description

@dan-petty

Problem

_is_safe_workspace_path in src/devops_cli/ai/tools/builtin_tools.py returns False when target.is_symlink(). No public tool reaches this branch. Each caller (list_files, search_code, read_file, _is_valid_dir_entry, _is_searchable_file, _workspace_target) resolves the path first, and a resolved path is never a symlink. A mutation run that deletes the branch leaves all tests green.

Wanted

Delete the dead branch. The is_safe_subpath check stays. A link that points out of the workspace is still denied, because the resolved target lies outside it. The tests in tests/security/test_builtin_tools.py already prove this.

Source

Review of the pull request for #3761.

Alternatives check of 2026-11-08: not-applicable.
Class: refactor, no search.
Tool: none found.

Proposed design

Problem statement

The function _is_safe_workspace_path in src/devops_cli/ai/tools/builtin_tools.py returns False when target.is_symlink(). No caller reaches this branch, because each caller resolves the path first and a resolved path is never a symlink. The branch is dead code. It also suggests a protection that the code does not give. The is_safe_subpath check alone keeps the workspace boundary.

Acceptance criteria

Requirement: Dead symlink guard removed

The function _is_safe_workspace_path SHALL decide only by the is_safe_subpath check and SHALL NOT call is_symlink().

Scenario: A path inside the workspace is allowed

  • WHEN read_file reads a regular file inside the workspace
  • THEN The reply is the content of the file, as before the change.

Requirement: Link out of the workspace stays denied

The tools read_file and list_files MUST deny a symbolic link whose resolved target lies outside the workspace.

Scenario: A link that points out of the workspace

  • WHEN read_file is called on a link in the workspace that points to a file outside it, and list_files is called on a link that points to a directory outside it
  • THEN read_file returns the access denied reply and list_files returns an empty list.

Requirement: Link inside the workspace stays readable

The tool read_file SHALL read a symbolic link whose resolved target lies inside the workspace.

Scenario: A link that points inside the workspace

  • WHEN read_file is called on a link in the workspace that points to a file in the workspace
  • THEN The reply is the content of the target file.

Existing Tool Considered

No outside tool applies. The change deletes two lines of code and adds none. The alternatives check gave not-applicable for a refactor. The cost is one small edit and one run of the existing tests, with no new maintenance.

Key questions

  • Does any caller of _is_safe_workspace_path pass an unresolved path, so that the symlink branch is live?: No. The callers list_files, read_file, search_code, _is_valid_dir_entry, _is_searchable_file and _workspace_target all call resolve() on the path before the check. A resolved path is never a symlink. The function has no other caller, and the existing test test_a_path_outside_the_workspace_is_denied_and_so_is_a_link_out_of_it covers the link cases through the public tools. [sources: src/devops_cli/ai/tools/builtin_tools.py, tests/security/test_builtin_tools.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/refactor
    scope/security
    status/new
    value/low
    effort/low
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The refactor prefix of the title gives the type.
    • Scope: scope/security. The (security) scope of the title gives the scope.
    • Priority: P3-Low. Removing unreachable dead code has no user-facing effect and no risk.
    • Value: Low. No behaviour changes; it only simplifies the code path.
    • Effort: Low. Delete one branch and confirm existing tests still pass.
    • Related: fix(ai): Refuse uv audit when project is outside workspace #2440, which asks for a different change. Both work on workspace path checks in builtin_tools.py, but the candidate removes dead code while #2440 adds a missing boundary check for uv audit.
  3. added
    priority/p3-low
    on Nov 6, 2026
  4. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: refactor. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.

  5. added
    status/ready
    and removed
    status/new
    on Nov 9, 2026
  6. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 1b37dbc (see proposed design in issue body).

  7. added
    status/in-progress
    and removed
    status/ready
    on Nov 14, 2026
  8. removed
    status/in-progress
    on Nov 14, 2026
  9. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p3-lowscope/securitysource/agenttype/refactorvalue/low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions