s3: validate copy source path segments (#9929)

Reject copy sources whose bucket/object fail IsValidBucketName /
IsValidObjectKey, the helpers validateRequestPath already applies to the
request URL. The object is joined onto the bucket path and `.`/`..`
segments are collapsed by the filer, so without this the source need not
stay within the parsed bucket. Route UploadPartCopy through
ValidateCopySource too; it previously only checked for empty bucket/object.
This commit is contained in:
Chris Lu authored and GitHub committed 2026-06-11 17:07:15 -07:00
1 parent 4f8af455bf
commit b44cf51fe9
3 files changed
+53 -6

No files matched your search

+9
View File
@@ -265,6 +265,15 @@ func ValidateCopySource(copySource string, srcBucket, srcObject string) error {
}
}
// `.`/`..` segments are collapsed by the filer's path join; reject them as
// IsValidObjectKey does for the request URL so the source stays in-bucket.
if !s3_constants.IsValidBucketName(srcBucket) || !s3_constants.IsValidObjectKey(srcObject) {
return &CopyValidationError{
Code: s3err.ErrInvalidCopySource,
Message: "Copy source contains invalid path segments",
}
}
return nil
}