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
Implementing early key validation in
S3Serviceso invalid keys are rejected before any storage writes, and adding tests to confirm object storage isn't modified. - Assistant
Implementing centralized key validation and applying it across all object-key entry points.
- Assistant
Hardened S3 key validation so traversal keys are rejected before any storage is touched.
Problem
Path traversal guards lived in
resolveObjectPath, which runs only when reading/writing files.putObjectupdated the in-memoryobjectStorefirst, so a key like../outside.txtcould leave metadata behind even when the filesystem write failed withInvalidKey.Fix
S3Service- Added
rejectKeyEscapingBucketRoot(String key)— normalizes the key against a synthetic bucket root and throwsAwsException("InvalidKey", ..., 400)when normalization escapes above it (or on invalid path characters). - Called it at the start of object operations (
storeObject,getStoredObject,deleteObject,copyObject, tagging, retention, legal hold, multipart init, etc.) any / filesystem changes.
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.