-
Notifications
You must be signed in to change notification settings - Fork 61
fix(rollback): capture and report silent filesystem restoration failures #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DebasmitaBose0
wants to merge
1
commit into
sreerevanth:main
Choose a base branch
from
DebasmitaBose0:fix/359-rollback-filesystem-failure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
partial_restorationand extraction-failure warnings are never actually populated by the real restore flow.FilesystemSnapshot.restore()trackspartialfailures internally and logs a warning, but its return type stayslist[str]— no information about partial failures is returned to the caller. Correspondingly,rollback()(lines 362-376) only appends a warning / never setsresult.partial_restorationfor the "snapshot completely missing" case; there is no code path where a real per-file extraction failure setsresult.partial_restoration = Trueor adds a warning toresult.warnings.This means the PR's stated goal — surfacing degraded/partial filesystem restoration through
RollbackResult— is unmet for the actual partial-extraction scenario; it's only met for the fully-missing-snapshot scenario. This is corroborated bytests/test_rollback.py'stest_rollback_result_tracks_partial_restoration, which only asserts against a manually constructedRollbackResultvia_simulate_partial_restoration()rather than exercisingFilesystemSnapshot.restore()/RollbackEngine.rollback()end-to-end.Consider returning failure info from
restore()and wiring it throughrollback():♻️ Proposed fix to propagate partial-restoration state
`@staticmethod` async def restore( snapshot_path: Path, target_path: Path, - ) -> list[str]: + ) -> tuple[list[str], list[str]]: restored: list[str] = [] partial: list[str] = [] ... - return restored + return restored, partialif restore_filesystem: if cp.snapshot_path and cp.snapshot_path.exists(): - restored = await FilesystemSnapshot.restore( + restored, partial = await FilesystemSnapshot.restore( snapshot_path=cp.snapshot_path, target_path=cwd, ) result.rolled_back_files = restored + if partial: + result.partial_restoration = True + result.warnings.append( + f"Failed to restore {len(partial)} file(s) from snapshot" + ) logger.info("Restored %d files from snapshot", len(restored))Also applies to: 362-376
🤖 Prompt for AI Agents
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does Python 3.12 tarfile raise FilterError from TarFile.extract with filter="data" for path traversal members?💡 Result:
In Python 3.12, while the 'data' filter is intended to provide protection against common security risks—including path traversal—it has been found to be insufficient against several bypass techniques [1][2]. Specifically, simply using
filter="data"does not guarantee that aFilterErrorwill be raised for all path traversal attempts. Multiple vulnerabilities have been identified (such as CVE-2025-4517 and CVE-2024-12718) where untrusted archives can bypass this filter, allowing for arbitrary filesystem writes or metadata modifications outside of the intended extraction directory [1][3][4]. Because of these security bypasses, Python versions 3.12.0 through 3.12.10 are considered affected [5]. The Python maintainers recommend upgrading to a patched version (e.g., 3.12.11 or later) to address these vulnerabilities [5]. If you cannot upgrade, it is recommended that you implement additional manual checks, such as verifying that no members contain insecure path segments (like "..") in their names or link targets, before proceeding with extraction [1][4]. While theFilterErrorexception exists in thetarfilemodule to signal that a filter has refused to extract a member, these security vulnerabilities demonstrate that the 'data' filter implementation can fail to detect or block all malicious path traversal vectors, thereby failing to raise the expected error [1][6][4].Citations:
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 251
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 551
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 811
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 361
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 238
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 14998
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 1234
🏁 Script executed:
Repository: sreerevanth/AgentWatch
Length of output: 15963
Re-raise
tarfile.FilterErrorinrestore()The per-memberexcept Exceptionswallows thedatafilter’s security exception and turns a malicious archive into a partial restore. Catchtarfile.FilterErrorseparately and re-raise it so unsafe snapshots still fail fast.🤖 Prompt for AI Agents