Validate base_path in FsRepository to prevent path.repo containment bypass - #22328
Conversation
PR Reviewer Guide 🔍(Review updated until commit d773722)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to d773722 Explore these optional code suggestions:
Suggestions up to commit f541f92
Suggestions up to commit df4bed9
Suggestions up to commit 83938d7
|
|
❌ Gradle check result for 83938d7: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit df4bed9 |
|
❌ Gradle check result for df4bed9: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit f541f92 |
|
❌ Gradle check result for f541f92: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit 66855ce |
|
❌ Gradle check result for 66855ce: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
The build is red, seems to be a known flaky test - #21378 |
|
❌ Gradle check result for 66855ce: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
❕ Gradle check result for 66855ce: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22328 +/- ##
============================================
+ Coverage 73.37% 73.41% +0.03%
- Complexity 76063 76075 +12
============================================
Files 6076 6076
Lines 345517 345533 +16
Branches 49733 49738 +5
============================================
+ Hits 253528 253670 +142
+ Misses 71792 71602 -190
- Partials 20197 20261 +64 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ypass The fs repository base_path setting was read verbatim from REST input with no validation. An absolute base_path causes Path.resolve to discard the path.repo-validated location, redirecting all blob-store operations outside the repository (CWE-22) and enabling arbitrary filesystem deletion via the snapshot _cleanup API. Add two layers of defense: - BASE_PATH_SETTING validator rejects absolute and upward-escaping (..) values after normalization (benign interior '..' that cancels out is allowed). - validateBasePathWithinRepo() resolves base_path against the location and verifies the result stays within a configured path.repo directory. Signed-off-by: Aditya Khera <kheraadi@amazon.com>
|
Persistent review updated to latest commit d773722 |
…ypass (#22328) (#22381) The fs repository base_path setting was read verbatim from REST input with no validation. An absolute base_path causes Path.resolve to discard the path.repo-validated location, redirecting all blob-store operations outside the repository (CWE-22) and enabling arbitrary filesystem deletion via the snapshot _cleanup API. Add two layers of defense: - BASE_PATH_SETTING validator rejects absolute and upward-escaping (..) values after normalization (benign interior '..' that cancels out is allowed). - validateBasePathWithinRepo() resolves base_path against the location and verifies the result stays within a configured path.repo directory. Signed-off-by: Aditya Khera <kheraadi@amazon.com> Co-authored-by: Aditya Khera <kheraadi@amazon.com>
Description
The fs repository base_path setting was read verbatim from REST input with no validation. An absolute base_path causes Path.resolve to discard the path.repo-validated location, redirecting all blob-store operations outside the repository (CWE-22) and enabling arbitrary filesystem deletion via the snapshot _cleanup API.
Add two layers of defense:
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.