CVE-2023-49090: Carrierwave Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-gxhx-g4fq-49hj
CVSS 6.8
CWE-79
Published
Advisory Summary

CVE-2023-49090 is a MODERATE (CVSS 6.8) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Carrierwave libraries in the RubyGems ecosystem. The issue involves carrierwave content-type allowlist bypass vulnerability, possibly leading to xss. Remediation is available by upgrading affected packages to version 3.0.5, 2.2.5.

CVE-2023-49090 at a Glance

CVE Identifier CVE-2023-49090
GHSA Identifier GHSA-gxhx-g4fq-49hj
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Carrierwave
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 6.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2023-49090

To remediate this vulnerability, upgrade all affected Carrierwave dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

carrierwave fixed: 3.0.5
Upgrade carrierwave to 3.0.5
carrierwave fixed: 2.2.5
Upgrade carrierwave to 2.2.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for carrierwave

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-49090, inspect your project dependencies for Carrierwave:

inspect dependencies for carrierwave

Analyze the terminal output to locate any version of Carrierwave in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Carrierwave, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact [CarrierWave::Uploader::ContentTypeAllowlist](https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/content_type_allowlist.rb) has a Content-Type allowlist bypass vulnerability, possibly leading to XSS. The validation in `allowlisted_content_type?` determines Content-Type permissions by performing a partial match. If the `content_type` argument of `allowlisted_content_type?` is passed a value crafted by the attacker, Content-Types not included in the `content_type_allowlist` will be allowed. In addition, by setting the Content-Type configured by the attacker at the time of file delivery, it is possible to cause XSS on the user's browser when the uploaded file is opened. ### Patches Upgrade to [3.0.5](https://rubygems.org/gems/carrierwave/versions/3.0.5) or [2.2.5](https://rubygems.org/gems/carrierwave/versions/2.2.5). ### Workarounds When validating with `allowlisted_content_type?` in [CarrierWave::Uploader::ContentTypeAllowlist](https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/content_type_allowlist.rb) , forward match(`\A`) the Content-Type set in `content_type_allowlist`, preventing unintentional permission of `text/html;image/png` when you want to allow only `image/png` in `content_type_allowlist`. ### References [OWASP - File Upload Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html#content-type-validation)

CVE-2023-49090 Affected Carrierwave Versions

2 component(s)
Fixed Versions:
3.0.52.2.5
Product / Package Ecosystem Affected Versions Fixed Version
carrierwave
RubyGems
≥ 3.0.0
< 3.0.5
3.0.5
carrierwave
RubyGems
< 2.2.5
2.2.5

References

Frequently Asked Questions

What is CVE-2023-49090?
CVE-2023-49090 is a security vulnerability in Carrierwave involving CarrierWave Content-Type allowlist bypass vulnerability, possibly leading to XSS under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Carrierwave versions are affected?
Affected versions include releases prior to 3.0.5, 2.2.5 across affected packages: carrierwave.
What version fixes CVE-2023-49090?
Upgrading to 3.0.5, 2.2.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is carrierwave affected?
Yes, carrierwave is affected in releases prior to 3.0.5, 2.2.5. Upgrade your dependency to 3.0.5, 2.2.5 or later.
What is the CVSS score of CVE-2023-49090?
CVE-2023-49090 has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2023-49090?
CVE-2023-49090 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check RubyGems dependencies for CVE-2023-49090?
Run the dependency tree command: 'inspect dependencies for carrierwave'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-gxhx-g4fq-49hj",
  "modified" : "2023-11-29T21:33:27Z",
  "published" : "2023-11-29T21:33:27Z",
  "aliases" : [ "CVE-2023-49090" ],
  "summary" : "CarrierWave Content-Type allowlist bypass vulnerability, possibly leading to XSS",
  "details" : "### Impact\n[CarrierWave::Uploader::ContentTypeAllowlist](https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/content_type_allowlist.rb) has a Content-Type allowlist bypass vulnerability, possibly leading to XSS. \n\nThe validation in `allowlisted_content_type?` determines Content-Type permissions by performing a partial match.\nIf the `content_type` argument of `allowlisted_content_type?` is passed a value crafted by the attacker, Content-Types not included in the `content_type_allowlist` will be allowed.\n\nIn addition, by setting the Content-Type configured by the attacker at the time of file delivery, it is possible to cause XSS on the user's browser when the uploaded file is opened.\n\n### Patches\nUpgrade to [3.0.5](https://rubygems.org/gems/carrierwave/versions/3.0.5) or [2.2.5](https://rubygems.org/gems/carrierwave/versions/2.2.5).\n\n### Workarounds\nWhen validating with `allowlisted_content_type?` in [CarrierWave::Uploader::ContentTypeAllowlist](https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/content_type_allowlist.rb) , forward match(`\\A`) the Content-Type set in `content_type_allowlist`, preventing unintentional permission of `text/html;image/png` when you want to allow only `image/png` in `content_type_allowlist`.\n\n### References\n[OWASP - File Upload Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html#content-type-validation)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "carrierwave"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.0.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "carrierwave"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.2.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/carrierwaveuploader/carrierwave/security/advisories/GHSA-gxhx-g4fq-49hj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-49090"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/carrierwaveuploader/carrierwave/commit/39b282db5c1303899b3d3381ce8a837840f983b5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/carrierwaveuploader/carrierwave/commit/863d425c76eba12c3294227b39018f6b2dccbbf3"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/carrierwaveuploader/carrierwave"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/uploader/content_type_allowlist.rb"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/carrierwave/CVE-2023-49090.yml"
  }, {
    "type" : "WEB",
    "url" : "https://rubygems.org/gems/carrierwave/versions/2.2.5"
  }, {
    "type" : "WEB",
    "url" : "https://rubygems.org/gems/carrierwave/versions/3.0.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-11-29T21:33:27Z",
    "nvd_published_at" : "2023-11-29T15:15:08Z"
  }
}