mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-17 19:48:35 +02:00
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:
1 parent
4f8af455bf
commit
b44cf51fe9
3 files changed
+53
-6
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user