fix(backup): contain restore file paths within the handler root#9760
fix(backup): contain restore file paths within the handler root#9760alhudz wants to merge 2 commits into
Conversation
|
gentle ping |
992162b to
cf75bad
Compare
shiva-istari
left a comment
There was a problem hiding this comment.
Thanks for the fix, @alhudz !
I went through the changes and they look good to me. It would be nice to add a table-driven test for cleanRelPath covering a few edge cases like "", ".", a/../b, absolute paths, and paths with trailing or duplicate separators. I think that would make future regressions less likely.
In addition, an integration test would be valuable to verify the end-to-end behavior and help prevent regressions in the future.
Other than that, LGTM. Happy to see this merged.
|
Both added. |
Description
The
pathfield of a backup manifest is read back from the backup location (readMasterManifest) and used as-is during restore.restore_map.gojoinsmanifest.Pathwith the backup file name and streams it throughfileHandler.Stream->os.Open(filepath.Join(rootDir, prefix, path)).getManifestsToRestorejoins the samemanifest.PathforFileExists, and the s3/minio handler builds object keys the same way ingetObjectPath.JoinPath/getObjectPathdo not contain the relative path, so a manifest left in the backup target withpathset to../../..steers those reads outside the handler root. The fix sits in the handlers because that is the single choke point every backup/restore file op goes through.Repro:worker/backup_handler_test.go(fails before, passes after).Expected:the resolved path stays under the handler root.Actual:JoinPath("../../../../etc/passwd")returns/etc/passwd;getObjectPathreturns../../etc/passwd.Fix:cleanRelPathanchors the path at the root and drops a leading separator /..before the join;JoinPath(file + s3) andgetObjectPathall route through it.Checklist
Conventional Commits syntax, leading
with
fix:,feat:,chore:,ci:, etc.