Untitled conversation
- User
[BUG] S3 dot-dot object requests return InvalidKey
Service
AWS API Action
Expected behavior
AWS behavior rejects object requests whose key causes a dot-dot path segment to appear in the request URI with HTTP 400 Bad Request and an empty response body.
Actual behavior
Floci returns an
InvalidKeyerror body:textAn error occurred (InvalidKey) when calling the PutObject operation: The specified key is invalid.Reproduction
bashprintf 'safe-data' > body.txt aws --endpoint-url http://localhost:4566 s3api create-bucket \ --bucket raw-path-bucket aws --endpoint-url http://localhost:4566 s3api put-object \ --bucket raw-path-bucket \ --key ../bad.txt \ --body body.txtEnvironment
- Floci version / image tag: local Docker image built from main commit
a7b0826c - Java SDK version (if applicable): N/A; verified with AWS CLI
- How you're running Floci (Docker / native /
mvn quarkus:dev): Docker
Interface
No new interfaces are introduced.
- Floci version / image tag: local Docker image built from main commit
- Assistant
I'll track down where S3 validates object keys and returns
InvalidKey, then align dot-dot path handling with AWS's HTTP 400 empty-body behavior. - Assistant
Implementing the fix: object requests with
..in the URI path should return HTTP 400 with an empty body, notInvalidKey.validateRawUri()exists for bucket ops but isn't called fromextractObjectKey(). - Assistant
Updating integration tests to expect an empty 400 response body:
- Assistant
The tests are failing because the HTTP layer may normalize paths before they reach our handler. Checking what URI the server actually sees:
- Assistant
Adding key-segment validation in
extractObjectKey— the HTTP layer can normalize..out of the URI while the path param still carries the traversal key. - Assistant
Validating the JAX-RS
@PathParam("key")directly — it may still contain..after the HTTP layer normalizes the Vert.x URI. - Assistant
Root cause: paths like
/bucket/../keydon't match/{bucket}/{key:.+}, so they fall through toPUT /{bucket}(createBucket), which runsvalidateRawUri()and returnsInvalidKey. Adding a@PreMatchingfilter to return HTTP 400 with an empty body before routing. - Assistant
Fixed. Object requests with a
..path segment in the URI were returningInvalidKeyXML instead of AWS’s HTTP 400 with an empty body.Root cause
When a URI like
/bucket/%2E%2E/bad.txtis decoded to/bucket/../bad.txt, JAX-RS often does not matchPUT /{bucket}/{key:.+}. The request falls through toPUT /{bucket}(createBucket), which runsvalidateRawUri()and returns anInvalidKeyXML error.That matches what the AWS CLI does with
--key ../bad.txt(percent-encoded dots in the path).Fix
-
S3ObjectDotDotUriFilter—@PreMatchingfilter that detects..at the object-key root in the request URI and aborts with HTTP 400 + empty body before routing. -
S3UriValidation— shared segment-depth logic (allows internal traversal like , rejects root-level ).
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.