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:An error occurred (InvalidKey) when calling the PutObject operation: The specified key is invalid.Reproduction
printf '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
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) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- Floci version / image tag: local Docker image built from main commit
- Assistant
I’ll inspect the repository to locate S3 request routing and key validation, then trace how dot-dot path requests are currently converted into
InvalidKey. I’ll make the smallest source change consistent with existing error handling, run focused tests (and broader relevant tests if available), and verify the resulting HTTP status/body behavior before submitting. - Assistant
The relevant behavior is in
S3Controller: object methods decode the raw URI, thenvalidateKeyNoTraversalthrowsAwsException("InvalidKey", ...), and the method-level catch serializes that exception as XML. AWS’s distinction here is request-level rejection, so I’ll detect any decoded..path segment in the object portion before key extraction and return a bare 400 response for PUT and DELETE. Other invalid keys (for example null bytes) will retain the existingInvalidKeyXML behavior, and GET/bucket operations will remain unchanged. - Assistant
The first edit attempt could not run because this environment has no
python3; no files were changed. I’ll apply the same focused change using the available shell tooling, then inspect the diff and compile/test it. - Assistant
The source change is now applied and the diff is clean. A compile attempt was blocked by the repository wrapper requiring
HOMEto be set in this shell, so I’ll rerun with an explicit temporary HOME and then execute the focused S3 integration tests if the build environment supports them. - Assistant
Verification is complete: compilation succeeds, the focused S3 integration test for encoded traversal passes with the new response behavior, and
git diff --checkreports no formatting errors. The service unit test suite has one unrelated pre-existing environment failure (copyObjectWithNonASCIIKeyunder the container’s character encoding); it does not involve this change. The implementation also handles internal traversal (docs/../file), encoded dot segments, multiple dot-dot segments, and DELETE requests while preserving existing errors for malformed/non-traversal keys. I’ll now submit the change.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.