fix(pre_seed): security hardening + tempdir permission fix#1199
Open
chaodu-agent wants to merge 5 commits into
Open
fix(pre_seed): security hardening + tempdir permission fix#1199chaodu-agent wants to merge 5 commits into
chaodu-agent wants to merge 5 commits into
Conversation
032827d to
44bf90e
Compare
F1 🔴: Use symlink_metadata() instead of is_file() when setting
permissions — prevents symlink-following attacks on sensitive files.
F3 🟡: Create target dir with create_dir_all() before tempdir_in()
to avoid 'Permission denied' when target doesn't exist yet.
F4 🟡: Use symlink_metadata() in move_recursive — preserve symlinks
as-is without following them (prevents directory escape).
F5 🟡: Update docs to reflect pre-seed is now a default feature.
Note: F2 (path traversal) is already handled by tar::Entry::unpack_in()
which rejects '..' components and absolute paths.
44bf90e to
8c68a29
Compare
The #[cfg(unix)] #[cfg(not(unix))] stacked attributes are contradictory and produce unreachable code on all platforms. The blocks also reference undefined variables (link_target, src_path, dst_path). The non-unix symlink fallback is already handled by create_symlink_or_copy() in move_recursive.
- Reject symlinks with absolute targets or .. components in move_recursive - Remove tarball symlinks with escaping targets after unpack_in - Strip suid/sgid/sticky bits (& 0o0777) in zip permission path (was already done for tarball)
This comment has been minimized.
This comment has been minimized.
- Fix remove_file failing on existing directories in move_recursive symlink branch (use symlink_metadata to decide remove_dir_all vs remove_file) - Fix non-Unix fallback in create_symlink_or_copy silently dropping entries when resolved target doesn't exist (now returns error) - Add tests: move_recursive preserves symlinks, symlink overwrites existing dir, tempdir strategy with non-writable parent, deep target creation
Test now creates target dir (writable) then locks parent to read-only, verifying tempdir_in(target) succeeds where old tempdir_in(parent) would fail.
Collaborator
Author
|
LGTM ✅ — Security hardening is solid, all critical findings from prior round have been addressed. What This PR DoesHardens the How It Works
Findings
Finding Details🟡 F10: Docs slightly inaccurate for crate consumersThe docs state "pre-seed is enabled by default. No feature flag needed." This is accurate for the OpenAB binary (which enables the feature), but library consumers of Baseline Check
What's Good (🟢)
|
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.
Fixes
symlink_metadata()instead ofis_file()to prevent symlink-following attacks when setting permissionscreate_dir_all(target)beforetempdir_in(target)to avoid permission denied when target doesn't existsymlink_metadata()and preserve symlinks as-is without following (prevents directory escape)% N == 0with.is_multiple_of(N)(Rust 1.96 lint)Not Fixed (already safe)
F2 (path traversal):
tar::Entry::unpack_in()already rejects..components and absolute paths — no additional validation needed.