derrickaw opened a new pull request, #41497: URL: https://github.com/apache/beam/pull/41497
Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria: - The PR remediates confirmed, live Code Scanning finding(s) (`CodeQL` / `zizmor`) on `master` without altering intended public API or workflow semantics - The fix is minimal, idiomatic, and avoids suppressing alerts or masking underlying defects - Relevant unit tests, linters, and CI checks have been verified If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :) ## Summary - Resolves CodeQL `java/zipslip` (`CWE-022`, High/Error, [alert #89](https://github.com/apache/beam/security/code-scanning/89)) in `org.apache.beam.sdk.util.ZipFiles.unzipFile`. - Replaces manual `..` string-splitting in `checkName` with canonical `Path.startsWith` verification (`targetFile.getCanonicalFile().toPath().startsWith(canonicalTargetDir)`) prior to creating directories or writing extracted files, preventing directory traversal, sibling-prefix bypasses (`../target_sibling/...`), and symlink escapes outside `targetDirectory`. - Adds regression unit tests in `ZipFilesTest` covering Zip Slip traversal entries (`../escaped.txt`, `nested/../../escaped.txt`, `../target_sibling/escaped.txt`) while preserving valid filenames containing double dots (`foo..bar.txt`). ## Verification - `./gradlew :sdks:java:core:spotlessCheck :sdks:java:core:test --tests org.apache.beam.sdk.util.ZipFilesTest` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
