Skip to content

fix(security): enforce path boundary checks in skill manager operations#7065

Closed
Dusk1e wants to merge 1 commit into
NousResearch:mainfrom
Dusk1e:fix/skill-manage-symlink-escape
Closed

fix(security): enforce path boundary checks in skill manager operations#7065
Dusk1e wants to merge 1 commit into
NousResearch:mainfrom
Dusk1e:fix/skill-manage-symlink-escape

Conversation

@Dusk1e

@Dusk1e Dusk1e commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Vulnerability Description

  • Target File: tools/skill_manager_tool.py
  • Vulnerability Type: Path Traversal via Symbolic Link (CWE-22)
  • Status: Mitigated

Problem: The skill_manage utility's supporting file operations previously relied on a naive substring check (searching for .. segments). This approach failed to account for symbolic links, which could allow a malicious skill to bypass the intended directory boundaries and access sensitive files on the host system (e.g., credentials, configuration files).


2. Technical Mitigation

This patch replaces basic string filtering with a robust Resolved Path Boundary Check.

  • Helper Implementation: Added a centralized _is_safe_path validation (line 243) using Path.resolve().
  • Execution Funnels: Integrated mandatory boundary enforcement into the following critical I/O paths:
    • _patch_skill (line 406)
    • _write_file (line 519)
    • _remove_file (line 554)
  • Outcome: Any operation resulting in a resolved path outside the designated skill_dir is now strictly aborted.

3. Regression Testing & Verification

Three security-focused test cases have been added to tests/tools/test_skill_manager_tool.py to ensure long-term stability:

  • test_patch_skill_fails_on_symlink_escape (line 335): Confirms that patching files outside the skill root via symlink is blocked.

  • test_write_file_fails_on_symlink_escape (line 399): Verifies that writes to external directories are rejected.

  • test_remove_file_fails_on_symlink_escape (line 434): Ensures unauthorized file deletion is prohibited.

  • Verification: git diff --check passed. Logic follows established security patterns used in other hardened modules of the project.


  • Test Command: python -m pytest tests/tools/test_skill_manager_tool.py -q

@Dusk1e Dusk1e force-pushed the fix/skill-manage-symlink-escape branch from 3a7530f to 2afbc7a Compare April 10, 2026 09:36
@Dusk1e Dusk1e force-pushed the fix/skill-manage-symlink-escape branch from 2afbc7a to 61791c6 Compare April 10, 2026 09:37
@Dusk1e Dusk1e closed this Apr 10, 2026
@Dusk1e Dusk1e deleted the fix/skill-manage-symlink-escape branch April 10, 2026 09:41
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #7156. Your symlink traversal fix was cherry-picked with authorship preserved — clean, correct CWE-22 mitigation. Thanks, @Dusk1e!

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.

3 participants