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
Investigating how Floci validates S3 object keys and handles dot-dot path segments.
- Assistant
Implementing the fix: URI dot-dot traversal should return HTTP 400 with an empty body (AWS behavior), not an
InvalidKeyXML error. Adding a dedicated exception and calling URI validation fromextractObjectKey. - Assistant
Restoring decode-error handling that was accidentally removed:
- Assistant
The HTTP layer may be normalizing paths before our check. Investigating how the raw request URI is accessed:
- Assistant
Path normalization is stripping
..from the Vert.x URI before our check runs. Detecting dot-dot segments in the object key path instead: - Assistant
Extracting validation into a testable utility and adding unit tests to debug the detection logic.
- Assistant
Switching to handling this in
xmlErrorResponsevia a sentinel error code, since theExceptionMappermay not be registered in the test runtime. - Assistant
Removing the cross-layer dependency from
AwsExceptionMapper: - Assistant
RestAssured may normalize paths. Adding an HttpClient-based test and verifying what the server receives:
- Assistant
extractObjectKeyisn't being called — InvalidKey must originate elsewhere. Searching for the source: - Assistant
All targeted tests passed. Running the full traversal test set and related S3 tests:
- Assistant
Fixed. S3 object requests with dot-dot path segments in the URI now return HTTP 400 with an empty body, matching AWS.
Root cause
For a request like
PUT /raw-path-bucket/../bad.txt, the HTTP stack normalizes the path to/bad.txtbefore JAX-RS routing, so the request often lands oncreateBucketinstead ofputObject. The raw Vert.x URI still contains.., and the existingvalidateRawUri()check threw anInvalidKeyXML error instead of an empty 400.Changes
-
S3KeyPathValidator— shared logic to detect dot-dot segments above the bucket root (including%2E%2E-encoded forms). -
extractObjectKey— validates both the raw and decoded key path before other checks; throws a sentinelS3EmptyBadRequesterror for dot-dot traversal. -
validateRawUri— uses the same empty-400 response for dot-dot in the raw request URI (covers misrouted requests like the example above).
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.