ISSUE DESCRIPTION [BUG] S3 dot-dot object requests return InvalidKey Service Amazon S3…
- User
ISSUE DESCRIPTION
[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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Floci version / image tag: local Docker image built from main commit
- Assistant
I'll start by exploring the repository structure and locating how S3 object keys are validated, especially for dot-dot path segments.
- Assistant
Let me search for InvalidKey and S3-related key validation.
- Assistant
rg is not available, I'll use grep instead.
- Assistant
I'll inspect the key-validation logic and the related S3 tests next.
- Assistant
I'll look for related comments, empty-response handling, and where key validation is invoked.
- Assistant
Let me look at how validateRawUri is called and what Response is returned. Also check AwsException mapper and if there's a way to return empty body 400.
- Assistant
I'll check recent git history and related docs for the intended AWS empty-body behavior.
- Assistant
I'll inspect the recent relative-key rejection commit for the intended empty-body behavior.
- Assistant
I'll inspect how PutObject/DeleteObject handle validation failures and what empty 400 responses look like elsewhere.
- Assistant
I'll search for existing patterns that return an empty 400 response.
- Assistant
Let me look at ServiceEnabledFilter empty 400 and also check if validateRawUri is called for putObject. Looking at the put paths - for
PUT /test-bucket/../../secret.txt: I think I understand the issue now. The bug report shows that Floci returns anInvalidKeyerror for requests likePUT /raw-path-bucket/../bad.txt, but AWS should return a plain 400 with an empty body.Looking at the reproduction, the key `../bad.
- Assistant
I'll change path-traversal rejection to return HTTP 400 with an empty body so it matches AWS behavior.
- Assistant
I'll update the validation methods to throw a WebApplicationException with an empty 400 response.
- Assistant
I'll check the other call site of
validateKeyNoTraversaland whether the service layer should also return an empty 400. - Assistant
I'll compile and run the relevant S3 tests to verify the fix.
- Assistant
HOME is not set. Let me set it.
- Assistant
Compile succeeded. I'll run the related S3 integration tests next.
- Assistant
The empty-body failures match the expected change. I'll check setup ordering and re-run a broader slice to confirm internal traversal still works.
- Assistant
I'll write a small temporary check that runs createBucket plus the dot-dot cases together.
- Assistant
I'll verify null-byte keys still return InvalidKey and that delete-object with
../returns an empty 400. - Assistant
All verification tests passed. I'll remove the temporary test and double-check the final diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.