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
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) 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. - Floci version / image tag: local Docker image built from main commit
Assistant
Build succeeded. Let's run the app in background and test with curl using raw path.
Assistant
Server is running. Now let's create bucket and test raw dot-dot path with curl using
--path-as-is.Assistant
Good, test passes currently. Now let's run the whole set of traversal-related tests together to see current state (since @Order dependent, might need earlier tests like bucket creation).
Assistant
Now let's find
extractObjectKey:Assistant
jakarta.ws.rs.*is already imported, soWebApplicationExceptionis available. Now let's editextractObjectKeyand add the raw check.Assistant
None of these are relevant to our new call sites. Now let's add the fix.
Assistant
Now let's rebuild and test.
Assistant
Build succeeded. Now let's run the server and reproduce the issue scenario.
Assistant
Fresh build. Let's check if maybe curl's URI parsing on the client side (even with
--path-as-is) is stripping the raw request differently. Let's use-vto inspect what's actually sent.Assistant
That old process 4580 is still up (the "kill -9 4579" earlier didn't target the right PID). Let's kill it properly and restart.
Assistant
Good, now truly fresh process 7340. Let's test again.
Assistant
Now let's rebuild and test again.
Assistant
Now rebuild and test to confirm the hypothesis.
Assistant
Now let's remove the debug prints and add the fix to
validateRawUri.Assistant
Now let's remove the debug print statements we added earlier.
Assistant
Now let's rebuild and rerun the manual reproduction along with the pre-existing test scenarios.
Assistant
Excellent! Exactly as designed. The issue's repro case now gives empty-body 400, the percent-encoded cases still work as before (preserving those tests), and query-string traversal (204) is unaffected.
Assistant
Now let's run the existing S3 test suite to see the impact.
Assistant
Confirmed pre-existing failure, unrelated to our fix. Let's restore our changes.
Assistant
Now let's rebuild with our fix and run the full S3 test suites (both integration and unit) to see overall impact and confirm nothing else broke.
Assistant
Now let's run the full S3 integration and unit test suites for final verification.
Assistant
All good and consistent. Let's rerun the full S3-related test suites once more to confirm this new addition doesn't break anything.
Assistant
Same results as before—no new regressions introduced by the headBucket change. Let's view the final diff.
Assistant
This is a clean, minimal, well-targeted fix. Let's clean up temp files and processes.
Assistant
Now let me go through the checklist:
Assistant
Summary
I investigated the issue and found that the root cause was more subtle than it first appeared:
-
Reproduced the bug: Confirmed that returns an XML error body instead of AWS's actual behavior (empty-body HTTP 400).
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.