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 where S3 object keys are normalized and add validation to reject paths that escape the bucket root with
InvalidKey. - Assistant
Tests pass; I'll trace all S3 key entry points to see if validation is missing anywhere.
- Assistant
Validation exists only on disk paths and runs too late in some flows. I'll centralize it in
S3Serviceand call it before any storage operations. - Assistant
S3 object keys that normalize above the bucket root are now rejected with HTTP 400 and
InvalidKey, before any storage is touched.Changes
S3Service- Added
validateObjectKey(String key)— normalizes the key (stripping leading/) and rejects paths that escape the bucket root, plus invalid path characters. - Wired it into
objectKey(),versionedKey(),resolveObjectPath(),resolveVersionedPath(), andinitiateMultipartUpload()so validation runs before metadata or file writes. - Because
objectKey()/versionedKey()are used on every object operation, invalid keys are rejected before reads or writes — including in-memory mode, which previously skipped the disk-only guard.
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.