You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Path traversal via unsanitized Gemini batch-job display_name
GenAIGeminiCreateBatchJobOperator and GenAIGeminiCreateEmbeddingsBatchJobOperator name the local results file after job.display_name, a field returned in the batch-job metadata. job.name is already sanitized against / at that spot, but display_name (used first) is not, so a .. in it lands the .jsonl outside results_folder on the worker. The check now resolves the join and refuses anything escaping results_folder, applied at both sites, matching the sync_to_local_dir guards already in the GCS and S3 hooks.
Was generative AI tooling used to co-author this PR?
Could we use Path.resolve() for the containment check here, matching the existing GCS/S3 sync_to_local_dir guards? abspath() catches .. traversal, but it does not resolve symlinks.
For example, if results_folder/link is a symlink to a directory outside results_folder, a display_name like link/evil would still pass the commonpath() check while writing outside the intended folder.
Using Path(results_folder).resolve() and checking the resolved target path is relative to that resolved base would make the containment guarantee stronger and align this with the existing guards.
Good point on the symlink gap. Switched the check to Path(results_folder).resolve() and resolved_target.is_relative_to(base), so a symlinked subdir pointing outside now gets rejected too. That matches the GCS/S3 sync_to_local_dir guards. Tests still pass.
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
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.
Path traversal via unsanitized Gemini batch-job display_name
GenAIGeminiCreateBatchJobOperatorandGenAIGeminiCreateEmbeddingsBatchJobOperatorname the local results file afterjob.display_name, a field returned in the batch-job metadata.job.nameis already sanitized against/at that spot, butdisplay_name(used first) is not, so a..in it lands the.jsonloutsideresults_folderon the worker. The check now resolves the join and refuses anything escapingresults_folder, applied at both sites, matching thesync_to_local_dirguards already in the GCS and S3 hooks.Was generative AI tooling used to co-author this PR?