S3 object keys can escape above the bucket root during path normalization Reject keys…
- User
S3 object keys can escape above the bucket root during path normalization
Reject keys whose normalized path escapes above the bucket root with HTTP 400 and the S3 error code
InvalidKey, without creating, deleting, or modifying object storage.Interface
No new interfaces are introduced.
- Assistant
I'll locate S3 key normalization and where object operations are handled so we can reject paths that escape the bucket root.
- Assistant
Let me trace where key validation is applied and whether any operations bypass it.
- Assistant
Validation belongs in
objectKey/versionedKeyso it runs before any storage writes. I'll centralize it inS3Serviceand wire the controller to use that. - Assistant
Adding tests to verify invalid keys are rejected before any storage mutation.
- Assistant
S3 object keys that normalize above the bucket root are now rejected with HTTP 400 and
InvalidKeybefore any storage is touched.Changes
S3Service.java- Added
validateObjectKey(String key)— normalizes the key against a sandbox root and throwsInvalidKey(400) when the path escapes above it, or when it contains invalid path characters. - Wired validation into
objectKey(),versionedKey(),resolveObjectPath(),resolveVersionedPath(), andinitiateMultipartUpload()so every object operation validates before metadata or file I/O.
S3Controller.java - Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.