Skip to content

Potential fix for code scanning alert no. 7: Uncontrolled data used in path expression - #62

Merged
acroca merged 1 commit into
mainfrom
alert-autofix-7
Nov 14, 2026
Merged

acroca merged 1 commit into
mainfrom
alert-autofix-7

Conversation

@acroca

@acroca acroca commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/acroca/noxide/security/code-scanning/7

Use pathlib.Path.resolve() plus Path.relative_to() for containment checks in VaultTools._safe_path, instead of string-prefix checks on realpath. This preserves functionality (allow vault-relative paths, reject absolute/escaping paths, follow symlinks) while making the safety property explicit and robust.

Change only assistant/src/assistant/tools.py in _safe_path:

  • Keep the existing rel_path validation (not rel_path.parts / absolute path rejection).
  • Resolve candidate = (root / rel_path).resolve(strict=False).
  • Enforce containment with candidate.relative_to(root) inside a try/except ValueError.
  • Return candidate directly (already a Path).

No behavior change intended beyond stronger, clearer path-jail enforcement.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…n path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@acroca
acroca marked this pull request as ready for review November 14, 2026 22:26
@acroca
acroca merged commit d412bd9 into main Nov 14, 2026
5 checks passed
@acroca
acroca deleted the alert-autofix-7 branch November 14, 2026 22:26
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.

1 participant