CVE-2025-70952: Path Traversal String Startswith Bypass

Using `String.startsWith()` to check if a file path is safely contained within a directory is vulnerable to a partial path match bypass. For example, checking if `/tmp/dir_evil` startsWith `/tmp/dir` returns true, bypassing validation and potentially leading to path traversal (Zip Slip) attacks. Use the `java.nio.file.Path.startsWith()` method instead, which

Provally CuratedPublic repositoryHighHigh confidenceVerifiedApache-2.0Java
greprules fetch cve-2025-70952-path-traversal-string-startswith-bypass --engine opengrep

Description

Using `String.startsWith()` to check if a file path is safely contained within a directory is vulnerable to a partial path match bypass. For example, checking if `/tmp/dir_evil` startsWith `/tmp/dir` returns true, bypassing validation and potentially leading to path traversal (Zip Slip) attacks. Use the `java.nio.file.Path.startsWith()` method instead, which