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 callsubmit) 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 searching for how InvalidKey and path validation are handled for S3 object keys.
- Assistant
Let me search more specifically for InvalidKey and S3-related code.
- Assistant
rg is not available, let me use grep instead.
- Assistant
I'll inspect the key validation logic and the related tests for path traversal.
- Assistant
Let me check where validation is invoked and whether empty 400 responses already exist elsewhere.
- Assistant
Let me look at how validateRawUri is called and what's around lines 156, 243, 297. Also look at test around line 603 for empty body.
- Assistant
Looking at the AWS behavior more carefully: I need to make Floci return the same 400 empty body response that AWS does for keys containing
../segments, instead of theInvalidKeyerror. - Assistant
Let me look at putObject and deleteObject methods more carefully, and also how AwsException is mapped. Maybe there's a special exception type for empty body responses.
- Assistant
I'll look at git history for this validation and how empty 400 responses are handled.
- Assistant
Let me dig further into PR notes and any related empty-body handling patterns.
- Assistant
I'll check xmlErrorResponse and similar empty-body error patterns next.
- Assistant
I'll inspect xmlErrorResponse and how similar empty-body responses are returned.
- Assistant
I'll implement empty-body 400 for solo screen dot-dot URI rejection and verify imports.
- Assistant
Updating key validation to return HTTP 400 with an empty body for dot-dot path segments, matching AWS.
- Assistant
There's a subtle issue with validateKeyNoTraversal: when we catch InvalidPathException and the code throws AwsException from inside try, the catch only catches InvalidPathException. But if I throw Web...
- Assistant
Next I'll check AGENTS.md for how to run tests and confirm the project builds.
- Assistant
I'll confjirm compile/run behavior and look for globale WebApplicationException handling.
- Assistant
HOME isn't set — I'll export it and rerun the tests.
- Assistant
Unit tests passed. I'll run the path-traversal integration tests next to inspect the HTTP responses.
- Assistant
The empty-body 400 cases look correct; the internal-traversal 404 is likely a missing bucket from out-of-order test runs. Checking setup next.
- Assistant
I'll re-run createBucket with the related traversal tests columna to confirm internal traversal still works.
- Assistant
I'll verify null-byte keys still return InvalidKey with a temporary check.
- Assistant
All temporary checks passed. Cleaning up the temp test file and reviewing 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.