Skip to content

rgw: reject unrecognized query params in s3 requests - #72470

Draft
cbodley wants to merge 2 commits into
ceph:mainfrom
cbodley:wip-80921
Draft

cbodley wants to merge 2 commits into
ceph:mainfrom
cbodley:wip-80921

Conversation

@cbodley

@cbodley cbodley commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

s3 uses query parameters to represent "subresources" and routes those requests to different rest apis. rgw supports lots of these subresources, but not all of them - and aws continues to add more

rgw does this routing in RGWOp factory functions like RGWHandler_REST_Bucket_S3::op_put(), where we check query parameters for the subresources we support, then fall back to the default resource like RGWCreateBucket_ObjStore_S3

the risk of this strategy is that requests for subresources we don't support get incorrectly mapped to the default bucket/object resource. this can result in data loss when a PUT request falls back to PutObject and overwrites an existing object, or when a DELETE request falls back to DeleteBucket and removes a bucket prematurely

to mitigate this risk, both for current subresources that we don't support and for subresources added to aws in the future, we can't fall back to the default resource if the request conains any unrecognized query parameters

Fixes: https://tracker.ceph.com/issues/80921

Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

this test exercises success_redirect_action for PostObject requests,
which return a 303 See Also redirect with a Location response header
that adds some query params like bucket, key, etag

the uploader gives an arbitrary url for that redirect, not one that's
served by aws s3. but this test case relies on request.post() to follow
that direct back to the rgw endpoint so it can inspect the redirected
request's url

because of the additional query params on that url, that redirected
request now gets rejected by rgw. instead of expecting the test to
follow that redirect successfully, disable redirect so that we just
expect an http response with status 303 and a Location header with the
proper redirect url

Signed-off-by: Casey Bodley <[email protected]>
Comment thread src/rgw/rgw_rest_s3.cc
"max-keys", "prefix", "version-id-marker",
// rgw extensions
"allow-unordered",
"read-stats",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multisite uses query param 'objs-container' for bucket listing. should we add it here under rgw extensions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, updated. in hindsight, that probably should have been under RGW_SYS_PARAM_PREFIX so it goes to get_sys_params() instead of get_params()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like sigv2 auth params don't contain 'x-amz' prefix https://github.com/ceph/ceph/blob/main/src/rgw/rgw_rest_s3.cc#L7017. will have to add those explicitly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall, it feels like a maintenance burden :(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall, it feels like a maintenance burden :(

my main concern with this approach is the risk of regression, by rejecting (malformed?) requests that worked before

i'm not as concerned about maintenance burden. it just means that as we add support for new query paremeters, we'll have to update these lists too. and since we're writing test cases for these features, those tests will hit the "X names an S3 API that rgw does not implement" errors which should make the fix obvious

my concern about the original approach from #72114 is that every time aws introduces a new feature, rgw gains a new way to lose data. in my opinion, my approach here is the only way to prevent these data loss bugs for good

@cbodley

cbodley commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@adamemerson adamemerson self-assigned this Oct 9, 2026
s3 uses query parameters to represent "subresources" and routes those
requests to different rest apis. rgw supports lots of these
subresources, but not all of them - and aws continues to add more

rgw does this routing in RGWOp factory functions like
RGWHandler_REST_Bucket_S3::op_put(), where we check query parameters for
the subresources we support, then fall back to the default resource like
RGWCreateBucket_ObjStore_S3

the risk of this strategy is that requests for subresources we don't
support get incorrectly mapped to the default bucket/object resource.
this can result in data loss when a PUT request falls back to PutObject
and overwrites an existing object, or when a DELETE request falls back
to DeleteBucket and removes a bucket prematurely

to mitigate this risk, both for current subresources that we don't
support and for subresources added to aws in the future, we can't fall
back to the default resource if the request contains any unrecognized
query parameters

Fixes: https://tracker.ceph.com/issues/80921

Signed-off-by: Casey Bodley <[email protected]>
@cbodley

cbodley commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

discussed in the weekly rgw meeting, and the general consensus was for this approach over #72114. additional points made:

  • admins need visibility into rejected requests: ops log already includes query parameters that can be correlated with 405 errors
  • admins need to work around known clients sending extra (harmless) query params
  • admins need to work around new query params added to s3 sdks in the future that rgw would start rejecting

for the latter two points, i suggested a config option for each fallback (ex rgw_put_bucket_allowed_params, rgw_delete_object_allowed_params, etc) so that admins could inject additional params they consider to be safe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants