CVE-2024-39308: Rails admin Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-8qgm-g2vv-vwvc
CVSS 6.8
CWE-79
Published
Advisory Summary

CVE-2024-39308 is a MODERATE (CVSS 6.8) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Rails admin libraries in the RubyGems ecosystem. The issue involves railsadmin cross-site scripting vulnerability in the list view. Remediation is available by upgrading affected packages to version 3.1.3.

CVE-2024-39308 at a Glance

CVE Identifier CVE-2024-39308
GHSA Identifier GHSA-8qgm-g2vv-vwvc
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 Rails admin
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-2024-39308

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

rails_admin fixed: 3.1.3
Upgrade rails_admin to 3.1.3
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 rails_admin

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-39308, inspect your project dependencies for Rails admin:

inspect dependencies for rails_admin

Analyze the terminal output to locate any version of Rails admin in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.3), 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 Rails admin, 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 RailsAdmin list view has the XSS vulnerability, caused by improperly-escaped HTML title attribute. The issue was originally reported in https://github.com/railsadminteam/rails_admin/issues/3686. ### Patches Upgrade to [3.1.4](https://rubygems.org/gems/rails_admin/versions/3.1.4). The vulnerability itself was patched in 3.1.3 but it has a functionality issue. Initially the vulnerability was thought to exist in versions before 3.0, but it didn't. 2.x users can stay on 2.2.1. ### Workarounds 1. Copy the index view (located under the path `app/views/rails_admin/main/index.html.erb`) from the RailsAdmin version you use, and place it into your application by using the same path. 2. Open the view file by an editor, and change the way to populate the td tag: ```diff <% properties.map{ |property| property.bind(:object, object) }.each do |property| %> <% value = property.pretty_value %> - <td class="<%= [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?).join(' ') %>" title="<%= value %>"> + <%= content_tag(:td, class: [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?), title: strip_tags(value.to_s)) do %> <%= value %> - </td> + <% end %> <% end %> ``` **Note:** The view file created by this needs to be removed after upgrading RailsAdmin afterwards, unless this old view continue to be used. Only do this if you can't upgrade RailsAdmin now for a reason. ### References https://owasp.org/www-community/attacks/xss/ https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags

CVE-2024-39308 Affected Rails admin Versions

1 component(s)
Fixed Versions:
3.1.3
Product / Package Ecosystem Affected Versions Fixed Version
rails_admin
RubyGems
≥ 3.0.0.beta
< 3.1.3
3.1.3

References

Frequently Asked Questions

What is CVE-2024-39308?
CVE-2024-39308 is a security vulnerability in Rails admin involving RailsAdmin Cross-site Scripting vulnerability in the list view under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Rails admin versions are affected?
Affected versions include releases prior to 3.1.3 across affected packages: rails_admin.
What version fixes CVE-2024-39308?
Upgrading to 3.1.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is rails_admin affected?
Yes, rails_admin is affected in releases prior to 3.1.3. Upgrade your dependency to 3.1.3 or later.
What is the CVSS score of CVE-2024-39308?
CVE-2024-39308 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-2024-39308?
CVE-2024-39308 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-2024-39308?
Run the dependency tree command: 'inspect dependencies for rails_admin'. 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-8qgm-g2vv-vwvc",
  "modified" : "2024-07-11T20:24:10Z",
  "published" : "2024-07-08T14:14:43Z",
  "aliases" : [ "CVE-2024-39308" ],
  "summary" : "RailsAdmin Cross-site Scripting vulnerability in the list view",
  "details" : "### Impact\nRailsAdmin list view has the XSS vulnerability, caused by improperly-escaped HTML title attribute.\nThe issue was originally reported in https://github.com/railsadminteam/rails_admin/issues/3686.\n\n### Patches\nUpgrade to [3.1.4](https://rubygems.org/gems/rails_admin/versions/3.1.4). The vulnerability itself was patched in 3.1.3 but it has a functionality issue.\nInitially the vulnerability was thought to exist in versions before 3.0, but it didn't. 2.x users can stay on 2.2.1.\n\n### Workarounds\n1. Copy the index view (located under the path `app/views/rails_admin/main/index.html.erb`) from the RailsAdmin version you use, and place it into your application by using the same path.\n2. Open the view file by an editor, and change the way to populate the td tag:\n\n```diff\n               <% properties.map{ |property| property.bind(:object, object) }.each do |property| %>\n                 <% value = property.pretty_value %>\n-                <td class=\"<%= [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?).join(' ') %>\" title=\"<%= value %>\">\n+                <%= content_tag(:td, class: [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?), title: strip_tags(value.to_s)) do %>\n                   <%= value %>\n-                </td>\n+                <% end %>\n               <% end %>\n```\n\n**Note:** The view file created by this needs to be removed after upgrading RailsAdmin afterwards, unless this old view continue to be used. Only do this if you can't upgrade RailsAdmin now for a reason.\n\n### References\nhttps://owasp.org/www-community/attacks/xss/\nhttps://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:H/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "rails_admin"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0.beta"
      }, {
        "fixed" : "3.1.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/railsadminteam/rails_admin/security/advisories/GHSA-8qgm-g2vv-vwvc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-39308"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/railsadminteam/rails_admin/issues/3686"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/railsadminteam/rails_admin/commit/b5a287d82e2cbd1737a1a01e11ede2911cce7fef"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/railsadminteam/rails_admin/commit/d84b39884059c4ed50197cec8522cca029a17673"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/railsadminteam/rails_admin"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rails_admin/CVE-2024-39308.yml"
  }, {
    "type" : "WEB",
    "url" : "https://rubygems.org/gems/rails_admin/versions/2.3.0"
  }, {
    "type" : "WEB",
    "url" : "https://rubygems.org/gems/rails_admin/versions/3.1.3"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-08T14:14:43Z",
    "nvd_published_at" : "2024-07-08T15:15:22Z"
  }
}