CVE-2024-27285: Yard Cross-Site Scripting Vulnerability
MODERATECVE-2024-27285 is a MODERATE (CVSS 5.4) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Yard libraries in the RubyGems ecosystem. The issue involves yard's default template vulnerable to cross-site scripting in generated frames.html. Remediation is available by upgrading affected packages to version 0.9.36.
CVE-2024-27285 at a Glance
Security Impact
CVSS: 5.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N).
How to Fix CVE-2024-27285
To remediate this vulnerability, upgrade all affected Yard dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade yard to 0.9.36
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for yard
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-27285, inspect your project dependencies for Yard:
inspect dependencies for yard
Analyze the terminal output to locate any version of Yard in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.36), 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 Yard, 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
CVE-2024-27285 Affected Yard Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
yard
|
RubyGems |
< 0.9.36
|
0.9.36
|
References
Frequently Asked Questions
What is CVE-2024-27285?
Which Yard versions are affected?
What version fixes CVE-2024-27285?
Is yard affected?
What is the CVSS score of CVE-2024-27285?
What CWE is associated with CVE-2024-27285?
How can I check RubyGems dependencies for CVE-2024-27285?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-8mq4-9jjh-9xrc",
"modified" : "2025-02-14T18:35:42Z",
"published" : "2024-02-28T18:57:19Z",
"aliases" : [ "CVE-2024-27285" ],
"summary" : "YARD's default template vulnerable to Cross-site Scripting in generated frames.html",
"details" : "### Summary\nThe \"frames.html\" file within the Yard Doc's generated documentation is vulnerable to Cross-Site Scripting (XSS) attacks due to inadequate sanitization of user input within the JavaScript segment of the \"frames.erb\" template file.\n\n### Details\nThe vulnerability stems from mishandling user-controlled data retrieved from the URL hash in the embedded JavaScript code within the \"frames.erb\" template file. Specifically, the script lacks proper sanitization of the hash data before utilizing it to establish the top-level window's location. This oversight permits an attacker to inject malicious JavaScript payloads through carefully crafted URLs.\n\nSnippet from \"frames.erb\":\n(v0.9.34)\n```erb\n<script type=\"text/javascript\">\n var match = unescape(window.location.hash).match(/^#!(.+)/);\n var name = match ? match[1] : '<%= url_for_main %>';\n name = name.replace(/^(\\w+):\\/\\//, '').replace(/^\\/\\//, '');\n window.top.location = name;\n</script>\n```\n\n(v0.9.35)\n```erb\n<script type=\"text/javascript\">\n var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);\n var name = match ? match[1] : '<%= url_for_main %>';\n name = name.replace(/^((\\w*):)?[\\/\\\\]*/gm, '').trim();\n window.top.location.replace(name)\n</script>\n```\n\n### PoC (Proof of Concept)\nTo exploit this vulnerability:\n1. Gain access to the generated Yard Doc.\n2. Locate and access the \"frames.html\" file.\n3. Construct a URL containing the malicious payload in the hash segment, for instance: `#!javascript:xss` for v0.9.34, and `#:javascript:xss` for v0.9.35\n\n### Impact\nThis XSS vulnerability presents a substantial threat by enabling an attacker to execute arbitrary JavaScript code within the user's session context. Potential ramifications include session hijacking, theft of sensitive data, unauthorized access to user accounts, and defacement of websites. Any user visiting the compromised page is susceptible to exploitation. It is critical to promptly address this vulnerability to mitigate potential harm to users and preserve the application's integrity.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "yard"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.9.36"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/lsegal/yard/security/advisories/GHSA-8mq4-9jjh-9xrc"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-27285"
}, {
"type" : "WEB",
"url" : "https://github.com/lsegal/yard/pull/1538"
}, {
"type" : "WEB",
"url" : "https://github.com/lsegal/yard/commit/1fcb2d8b316caf8779cfdcf910715e9ab583f0aa"
}, {
"type" : "WEB",
"url" : "https://github.com/lsegal/yard/commit/2069e2bf08293bda2fcc78f7d0698af6354054be"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-8mq4-9jjh-9xrc"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/lsegal/yard"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/yard/CVE-2024-27285.yml"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2024/03/msg00006.html"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MR3Z2E2UIZZ7YOR7R645EVSBGWMB2RGA"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-02-28T18:57:19Z",
"nvd_published_at" : "2024-02-28T20:15:41Z"
}
}