Skip to content

rgw: Add missing empty checks to the split string in is_string_in_set(). - #56225

Merged
cbodley merged 1 commit into
ceph:mainfrom
linuxbox2:wip-cors-fix
Mar 20, 2024
Merged

cbodley merged 1 commit into
ceph:mainfrom
linuxbox2:wip-cors-fix

Conversation

@mattbenjamin

Copy link
Copy Markdown
Contributor

In certain cases, where a user misconfigures a CORS rule, the entirety of the string can be token characters (or, at least, the string before and after a given token is all token characters), but != "". If the misconfigured string includes "" we'll try to split the string and we assume that we can pop the list of string elements when "*" isn't first/last, but get_str_list() won't return anything for token-only substrings and thus 'ssplit' will have fewer elements than would be expected for a correct rule. In the case of an empty list, front() has undefined behaviour; in our experience, it often results in a huge allocation attempt because the code tries to copy the string into a local variable 'sl'.

An example of this misconfiguration (and thus a reproduction case) is configuring an origin of " *".

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

In certain cases, where a user misconfigures a CORS rule, the entirety
of the string can be token characters (or, at least, the string before
and after a given token is all token characters), but != "*". If the
misconfigured string includes "*" we'll try to split the string and we
assume that we can pop the list of string elements when "*" isn't
first/last, but get_str_list() won't return anything for token-only
substrings and thus 'ssplit' will have fewer elements than would be
expected for a correct rule. In the case of an empty list, front() has
undefined behaviour; in our experience, it often results in a huge
allocation attempt because the code tries to copy the string into a
local variable 'sl'.

An example of this misconfiguration (and thus a reproduction case) is
configuring an origin of " *".

Signed-off-by: Matt Benjamin <[email protected]>
@cbodley

cbodley commented Mar 15, 2024

Copy link
Copy Markdown
Contributor

@qiuxinyidian

Copy link
Copy Markdown
Contributor

@mattbenjamin @cbodley thank you very much

@cbodley

cbodley commented Mar 15, 2024

Copy link
Copy Markdown
Contributor

The following tests FAILED:
10 - run-tox-mgr-dashboard-lint (Failed)

@cbodley

cbodley commented Mar 15, 2024

Copy link
Copy Markdown
Contributor

jenkins test make check

@cbodley

cbodley commented Mar 15, 2024

Copy link
Copy Markdown
Contributor

jenkins test api

@cbodley
cbodley merged commit ca57c4b into ceph:main Mar 20, 2024
jhoblitt added a commit to jhoblitt/rgw-go that referenced this pull request Oct 16, 2026
…tern does not

is_string_in_set, at v19.2.7 and v20.2.4, matches AllowedOrigin and
AllowedHeader alike. It splits a wildcard member at spaces and tabs as
well as at its *, and tests its prefix and suffix apart, so they may
overlap: ab*bc matches abc, and * example.com matches evilexample.com.
A stored member with two *, which PutBucketCors refuses, fails closed:
*a* acts as *a, and a*b*c never matches. ceph/ceph#56225 fixed the
crash a " *" member caused and left the over-match.

Where access rides on network position, under aws:SourceIp or on an
internal-only gateway, an over-wide match lets an outside page read
through a browser inside, though radosgw sends no
Access-Control-Allow-Credentials. Triage rates it conditional (low) on
that case. rgw-go matches a pattern as written.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

4 participants