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:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /floci, current file: none) bash-$
- Floci version / image tag: local Docker image built from main commit
Assistant
Let me start by understanding the repository structure and then find the relevant code that handles S3 requests with dot-dot paths.
The issue is about S3 object requests with keys containing
..(dot-dot) path segments. AWS returns HTTP 400 Bad Request with an empty response body for such requests, but Floci returns anInvalidKeyerror body.Let me first explore the repository structure.
Assistant
This is a Java/Maven project. Let me explore the source code structure.
Assistant
Let me search for S3-related files and the
InvalidKeyerror.Assistant
Let me look at the S3 controller and service to understand how dot-dot paths are handled.
Assistant
Let me look at the relevant sections of the S3Controller.java around line 2542, and S3Service.java around line 2200
Assistant
Let me use the open command properly.
Assistant
Now let me look at the AwsExceptionMapper to understand how AwsException errors are handled
Assistant
Let me find where
validateRawUriandvalidateKeyNoTraversalare calledAssistant
Let me look at the context around where validateRawUri is called (line 156, 243, 297) and where validateKeyNoTraversal is called (line 2166).
Assistant
Let me also check how PutObject is handled. Let me look at the PutObject method
Assistant
Let me look at the putObject method (line 438) to understand the full flow.
Assistant
Let me look at the xmlErrorResponse method and understand the error response flow
Assistant
Let me look at the xmlErrorResponse method at line 1975.
Assistant
Let me look at S3Service.java around the InvalidKey lines.
Assistant
Let me look at the createBucket method to see how it handles AwsException differently.
Assistant
Let me look at the catch block for createBucket (around line 130).
Assistant
Let me look at the imports in S3Controller.java to see what's available.
Assistant
Let me check the AwsException class hierarchy
Assistant
Let me check where resolveObjectPath is called
Assistant
Let me check if there are other exception mappers that might interfere
Assistant
Let me check the project's framework/dependencies
Assistant
Let me first reproduce the issue. Let me check if the service can be started or if there are tests I can run
Assistant
Let me search for related tests about dot-dot or path traversal
Assistant
Let me look at the S3IntegrationTest around the path traversal tests
Assistant
Let me use a different approach.
Assistant
Now I have a clear understanding. Let me implement the fix. When path traversal is detected (dot-dot escaping the bucket), the response should be HTTP 400 with an empty body, not an InvalidKey error.
Let me first look at how to properly throw an empty-body 400 response. I'll use
jakarta.ws.rs.WebApplicationExceptionwhich JAX-RS handles with empty body by default.Let me check the current code flow more closely to ensure this approach works:
Assistant
Let me also look at the S3Service code to understand if I need to change it too
Assistant
Now I'll implement the fix. The approach is to use
jakarta.ws.rs.WebApplicationExceptionfor path traversal cases, which results in an empty body 400 response (matching AWS behavior), while keepingAwsExceptionfor other InvalidKey cases like invalid characters.Let me edit
validateKeyNoTraversalAssistant
Now change line 2544 in `validateRawUri
Assistant
Now let me change S3Service.java for
resolveObjectPathand `resolveVersionedPathAssistant
Let me check the S3Service imports to add the needed ones
Assistant
Now let me change both lines in S3Service.java. First line 2200:
Assistant
Now change line 2215:
Assistant
Now let me verify the changes compile. Let me first check if Maven is available and try to compile:
Assistant
Let me set HOME and try again:
Assistant
Let me check the S3ServiceTest to see how it handles the traversal tests
Assistant
Let me check if there are any general Exception catch blocks that could interfere
Assistant
Let me check the Exception catch blocks that might interfere
Assistant
Let me check line 2091
Assistant
Let me check line 2244
Assistant
Let me review all the changes I've made
Assistant
Let me check if DeleteObject also calls the validation methods
Assistant
Let me check deleteObject method
Assistant
Let me check if there are any other InvalidKey throws related to path traversal that I might have missed
Assistant
Let me verify the code compiles correctly by running the tests related to S3
Assistant
Let me verify that the
copyObjectWithNonASCIIKeytest failure is pre-existing (not related to my change):Assistant
Good, the
copyObjectWithNonASCIIKeytest failure is pre-existing. Let me restore my changes:Assistant
Let me run the S3IntegrationTest to confirm the impact of my changes:
Assistant
Let me verify the specific tests that should still pass actually do:
Assistant
Let me see the detailed failures
Assistant
Let me check if these tests were already failing before my change:
Assistant
Good, these are pre-existing test failures. Let me restore my changes.
Assistant
Let me check if S3Service is used from non-HTTP contexts
Assistant
Let me verify there are no intermediate catch blocks in the S3Service call chain that could catch WebApplicationException
Assistant
Let me check the catch blocks at lines 905 and around 1886 to see if they're in the call path
Assistant
Let me check the catch blocks around line 1886
Assistant
Let me check line 2055
Assistant
Let me check the S3Service.putObject method
Assistant
Let me check if CloudFormation service catches exceptions from S3 calls
Assistant
Let me verify the final state of my changes
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →