Validate ovpack ZIP member paths during import and add tests to reject unsafe entries#344
Merged
MaojiaSheng merged 2 commits intovolcengine:mainfrom Feb 28, 2026
Merged
Conversation
…security-vulnerability Validate ovpack ZIP member paths during import and add tests to reject unsafe entries
MaojiaSheng
approved these changes
Feb 28, 2026
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.
Motivation
import_ovpack processes attacker-controlled ZIP member names. Without strict validation, malformed entries (e.g. traversal segments, absolute paths, Windows-style paths, or root mismatches) can lead to unsafe import behavior. This change hardens import path handling and adds explicit regression coverage.
What changed
Added _validate_ovpack_member_path(zip_path, base_name) to enforce strict member-path rules and fail fast on unsafe input. Specifically rejects:
empty member paths
backslash-containing paths
absolute paths
drive-prefixed paths
parent traversal (..) components
entries whose root directory does not match the expected archive root (base_name)
Integrated member validation into import_ovpack before any directory creation or file write logic, and used validated paths for subsequent operations (mkdir, read, write_file_bytes).
Added client-level import security tests that build crafted ovpack files and assert ValueError is raised for each unsafe pattern (../, absolute, drive-prefix, backslash path, wrong-root).
Security impact
This prevents ZIP member path abuse during .ovpack imports and ensures unsafe archive entries are rejected deterministically before I/O.
Testing
Added parametrized coverage in tests/client/test_import_export.py for unsafe entry patterns and expected validation errors.
Existing import/export tests remain in place under TestImportOvpack/TestExportOvpack.