Repository navigation
fix: reject classification targets outside the archive root - #4
Merged
Merged
Conversation
Changes: - Validate rule and fallback classification targets as children of the managed archive root. - Reject absolute paths, parent-directory traversal, other drive letters, and junctions or symbolic links that escape the archive tree before any file is moved. - Add regression tests and record the security fix in the unreleased changelog. 修改内容: - 将分类规则和 fallback 目标约束为受管归档根目录的子目录。 - 在移动文件前拒绝绝对路径、父目录穿越、其他盘符,以及指向归档树外的 junction 或符号链接。 - 新增回归测试,并在 Unreleased changelog 中记录该安全修复。 Verification: - Windows host, repository venv Python 3.12.14: 94 passed, 1 skipped. - The skipped test requires directory symlink privilege (WinError 1314); junction escape cases passed. 验证: - 在 Windows 主机、仓库虚拟环境 Python 3.12.14 上运行完整测试集:94 passed,1 skipped。 - 跳过的用例需要创建目录符号链接的权限(WinError 1314);junction 逃逸用例已通过。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 概述
Fixes a file classification security issue that could allow configured targets to escape the managed archive root.
修复文件分类目标路径约束缺失的问题,防止分类规则将文件移动到受管归档目录之外。
Changes / 修改内容
English
简体中文
Verification / 验证结果
Windows 11 · Python 3.12.14
简体中文
The skipped test requires Windows symbolic-link privileges (
WinError 1314). Equivalent junction-escape cases passed.跳过的测试需要 Windows 符号链接创建权限(
WinError 1314);相应 junction 越界场景已通过测试。Remaining limitations / 剩余限制
A narrow time-of-check/time-of-use (TOCTOU) race may remain if a validated directory is replaced before file movement. This is outside the current fix scope and should be addressed separately.
如果其他进程在目录校验后、文件移动前替换目录,理论上仍可能存在竞态风险。本次不处理这一独立问题,后续单独跟踪。
Release scope / 发布范围
v0.2.2tag and GitHub Release remain unchanged.本 PR 面向后续未发布版本,不修改现有
v0.2.2发布记录,也不涉及安装器启动逻辑或 Environment Migration 功能。