GHSA-cwv4-h3j5-w3cf: Rama Cross-Site Scripting Vulnerability

LOW
CVSS 3.7
CWE-116
Published
Advisory Summary

GHSA-cwv4-h3j5-w3cf is a LOW (CVSS 3.7) cross-site scripting vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Rama libraries in the crates.io ecosystem. The issue involves rama has stored xss in servedir html directory listing via unescaped file names and uri path. Remediation is available by upgrading affected packages to version 0.3.0-rc.1.

GHSA-cwv4-h3j5-w3cf at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-cwv4-h3j5-w3cf
Severity LOW
CVSS v3.1 Base Score 3.7
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Rama
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 3.7

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

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

How to Fix GHSA-cwv4-h3j5-w3cf

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

rama fixed: 0.3.0-rc.1
Upgrade rama to 0.3.0-rc.1
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 rama

How to Check if You Are Affected

To determine whether your application is affected by GHSA-cwv4-h3j5-w3cf, inspect your project dependencies for Rama:

inspect dependencies for rama

Analyze the terminal output to locate any version of Rama in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.0-rc.1), 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-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Rama, 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

Resolved: https://github.com/plabayo/rama/commit/89ddff578fd78bbebec99482d7030f28c07757a3 ## Summary `plabayo/rama` contains a stored/reflected cross-site scripting issue in the `ServeDir` HTML directory listing feature. When `ServeDir` is configured with `DirectoryServeMode::HtmlFileList`, file names and URI path components are inserted directly into generated HTML without HTML escaping. If an attacker can create or influence a file or directory name inside a served directory, they may inject HTML or JavaScript into the directory listing page. This can execute script in the browser of any user who visits the affected directory listing. ## Affected Repository `plabayo/rama` ## Affected Component `rama-http/src/service/fs/serve_dir/open_file.rs` ## Root Cause The HTML directory listing is constructed using string formatting and inserts untrusted values directly into HTML. The directory listing row includes the file or directory name in both the link text and the `href` attribute: rows.push(format!( "<tr><td>{5} <a href=\"{1}{2}{0}\">{0}</a></td><td>{3}</td><td>{4}</td></tr>", entry.name, uri.path().trim_end_matches('/'), ... )); The navigation breadcrumb also inserts URI path parts into generated HTML: nav_parts.push(format!("<a href=\"{current_path}\">{part}</a>")); The page title and heading also include the current URI path: <title>Directory listing for .{0}</title> <h1>Directory listing for .{0}</h1> These values are not HTML-escaped before being embedded into the generated page. ## Security Impact If an application uses `ServeDir` with `DirectoryServeMode::HtmlFileList`, an attacker who can create or influence file names inside the served directory can inject HTML or JavaScript into the generated directory listing. Possible impact includes: - Script execution in the browser of users viewing the directory listing - Session or token theft if the application uses cookies or browser-accessible credentials - UI redressing or phishing inside the application origin - Unauthorized actions within the same origin if the victim is authenticated - Security boundary impact if the directory listing is served under a trusted application domain The attack requires the directory listing feature to be enabled and the attacker to control or influence at least one file or directory name in the served path. ## Proof of Concept This proof of concept uses a benign payload. Create a directory with a file name containing HTML: mkdir rama-xss-test cd rama-xss-test touch '"><img src=x onerror=alert(document.domain)>.txt' Serve this directory with Rama using `ServeDir` and `DirectoryServeMode::HtmlFileList`. Example intended configuration: ServeDir::new("rama-xss-test") .with_directory_serve_mode(DirectoryServeMode::HtmlFileList) Then visit the directory listing in a browser. Expected behavior: The file name should be displayed as text. Special characters such as `<`, `>`, `"`, and `'` should be HTML-escaped. Actual behavior: The file name is inserted directly into the generated HTML. The browser interprets the injected HTML and executes the benign JavaScript payload. ## Expected Behavior All file names, directory names, URI path parts, and other untrusted values should be escaped before being inserted into HTML. For example: - `<` should become `&lt;` - `>` should become `&gt;` - `"` should become `&quot;` - `'` should become `&#x27;` - `&` should become `&amp;` Untrusted values used inside HTML attributes should be escaped using an attribute-safe escaping function. ## Actual Behavior The directory listing is generated with `format!()` and inserts file names and path values directly into HTML without escaping. ## Suggested Fix Escape all untrusted values before inserting them into the generated HTML. Recommended changes: 1. HTML-escape `entry.name` before using it as link text. 2. Attribute-escape values used inside `href`. 3. HTML-escape URI path components used in breadcrumbs. 4. HTML-escape the current path used in the page title and heading. 5. Add regression tests with file names containing HTML metacharacters. Example test payloads: "><img src=x onerror=alert(1)>.txt <script>alert(1)</script>.txt a&b.txt quote"test.txt single'test.txt The secure output should render these as text only and should not create executable HTML or JavaScript. ## Suggested Severity Medium. Suggested CVSS: `CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N` Rationale: - The vulnerability is remotely reachable when an application exposes `ServeDir` directory listings. - Exploitation requires the attacker to create or influence a file or directory name in the served directory. - User interaction is required because a victim must view the affected directory listing. - The impact is browser-side script execution in the application origin. - Scope may change if the listing is served under a trusted authenticated application origin. ## Additional Notes This report is limited to the HTML directory listing generated by `ServeDir` when `DirectoryServeMode::HtmlFileList` is enabled. This report is not claiming remote code execution on the server. The issue is browser-side cross-site scripting caused by unescaped file names and path values in generated HTML.

GHSA-cwv4-h3j5-w3cf Affected Rama Versions

1 component(s)
Fixed Versions:
0.3.0-rc.1
Product / Package Ecosystem Affected Versions Fixed Version
rama
crates.io
< 0.3.0-rc.1
0.3.0-rc.1

References

Frequently Asked Questions

What is GHSA-cwv4-h3j5-w3cf?
GHSA-cwv4-h3j5-w3cf is a security vulnerability in Rama involving rama has Stored XSS in ServeDir HTML directory listing via unescaped file names and URI path under CWE-116: Improper Encoding or Escaping of Output.
Which Rama versions are affected?
Affected versions include releases prior to 0.3.0-rc.1 across affected packages: rama.
What version fixes GHSA-cwv4-h3j5-w3cf?
Upgrading to 0.3.0-rc.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is rama affected?
Yes, rama is affected in releases prior to 0.3.0-rc.1. Upgrade your dependency to 0.3.0-rc.1 or later.
What is the CVSS score of GHSA-cwv4-h3j5-w3cf?
GHSA-cwv4-h3j5-w3cf has a CVSS v3.1 base score of 3.7 (LOW) with vector string CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with GHSA-cwv4-h3j5-w3cf?
GHSA-cwv4-h3j5-w3cf is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check crates.io dependencies for GHSA-cwv4-h3j5-w3cf?
Run the dependency tree command: 'inspect dependencies for rama'. 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-cwv4-h3j5-w3cf",
  "modified" : "2026-07-07T23:41:12Z",
  "published" : "2026-07-07T23:41:12Z",
  "aliases" : [ ],
  "summary" : "rama has Stored XSS in ServeDir HTML directory listing via unescaped file names and URI path",
  "details" : "Resolved: https://github.com/plabayo/rama/commit/89ddff578fd78bbebec99482d7030f28c07757a3\n\n## Summary\n\n`plabayo/rama` contains a stored/reflected cross-site scripting issue in the `ServeDir` HTML directory listing feature.\n\nWhen `ServeDir` is configured with `DirectoryServeMode::HtmlFileList`, file names and URI path components are inserted directly into generated HTML without HTML escaping. If an attacker can create or influence a file or directory name inside a served directory, they may inject HTML or JavaScript into the directory listing page.\n\nThis can execute script in the browser of any user who visits the affected directory listing.\n\n## Affected Repository\n\n`plabayo/rama`\n\n## Affected Component\n\n`rama-http/src/service/fs/serve_dir/open_file.rs`\n\n## Root Cause\n\nThe HTML directory listing is constructed using string formatting and inserts untrusted values directly into HTML.\n\nThe directory listing row includes the file or directory name in both the link text and the `href` attribute:\n\n    rows.push(format!(\n        \"<tr><td>{5} <a href=\\\"{1}{2}{0}\\\">{0}</a></td><td>{3}</td><td>{4}</td></tr>\",\n        entry.name,\n        uri.path().trim_end_matches('/'),\n        ...\n    ));\n\nThe navigation breadcrumb also inserts URI path parts into generated HTML:\n\n    nav_parts.push(format!(\"<a href=\\\"{current_path}\\\">{part}</a>\"));\n\nThe page title and heading also include the current URI path:\n\n    <title>Directory listing for .{0}</title>\n    <h1>Directory listing for .{0}</h1>\n\nThese values are not HTML-escaped before being embedded into the generated page.\n\n## Security Impact\n\nIf an application uses `ServeDir` with `DirectoryServeMode::HtmlFileList`, an attacker who can create or influence file names inside the served directory can inject HTML or JavaScript into the generated directory listing.\n\nPossible impact includes:\n\n- Script execution in the browser of users viewing the directory listing\n- Session or token theft if the application uses cookies or browser-accessible credentials\n- UI redressing or phishing inside the application origin\n- Unauthorized actions within the same origin if the victim is authenticated\n- Security boundary impact if the directory listing is served under a trusted application domain\n\nThe attack requires the directory listing feature to be enabled and the attacker to control or influence at least one file or directory name in the served path.\n\n## Proof of Concept\n\nThis proof of concept uses a benign payload.\n\nCreate a directory with a file name containing HTML:\n\n    mkdir rama-xss-test\n    cd rama-xss-test\n    touch '\"><img src=x onerror=alert(document.domain)>.txt'\n\nServe this directory with Rama using `ServeDir` and `DirectoryServeMode::HtmlFileList`.\n\nExample intended configuration:\n\n    ServeDir::new(\"rama-xss-test\")\n        .with_directory_serve_mode(DirectoryServeMode::HtmlFileList)\n\nThen visit the directory listing in a browser.\n\nExpected behavior:\n\nThe file name should be displayed as text. Special characters such as `<`, `>`, `\"`, and `'` should be HTML-escaped.\n\nActual behavior:\n\nThe file name is inserted directly into the generated HTML. The browser interprets the injected HTML and executes the benign JavaScript payload.\n\n## Expected Behavior\n\nAll file names, directory names, URI path parts, and other untrusted values should be escaped before being inserted into HTML.\n\nFor example:\n\n- `<` should become `&lt;`\n- `>` should become `&gt;`\n- `\"` should become `&quot;`\n- `'` should become `&#x27;`\n- `&` should become `&amp;`\n\nUntrusted values used inside HTML attributes should be escaped using an attribute-safe escaping function.\n\n## Actual Behavior\n\nThe directory listing is generated with `format!()` and inserts file names and path values directly into HTML without escaping.\n\n## Suggested Fix\n\nEscape all untrusted values before inserting them into the generated HTML.\n\nRecommended changes:\n\n1. HTML-escape `entry.name` before using it as link text.\n2. Attribute-escape values used inside `href`.\n3. HTML-escape URI path components used in breadcrumbs.\n4. HTML-escape the current path used in the page title and heading.\n5. Add regression tests with file names containing HTML metacharacters.\n\nExample test payloads:\n\n    \"><img src=x onerror=alert(1)>.txt\n    <script>alert(1)</script>.txt\n    a&b.txt\n    quote\"test.txt\n    single'test.txt\n\nThe secure output should render these as text only and should not create executable HTML or JavaScript.\n\n## Suggested Severity\n\nMedium.\n\nSuggested CVSS:\n\n`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N`\n\nRationale:\n\n- The vulnerability is remotely reachable when an application exposes `ServeDir` directory listings.\n- Exploitation requires the attacker to create or influence a file or directory name in the served directory.\n- User interaction is required because a victim must view the affected directory listing.\n- The impact is browser-side script execution in the application origin.\n- Scope may change if the listing is served under a trusted authenticated application origin.\n\n## Additional Notes\n\nThis report is limited to the HTML directory listing generated by `ServeDir` when `DirectoryServeMode::HtmlFileList` is enabled.\n\nThis report is not claiming remote code execution on the server. The issue is browser-side cross-site scripting caused by unescaped file names and path values in generated HTML.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rama"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.3.0-rc.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/plabayo/rama/security/advisories/GHSA-cwv4-h3j5-w3cf"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/plabayo/rama/commit/89ddff578fd78bbebec99482d7030f28c07757a3"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/plabayo/rama"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-07T23:41:12Z",
    "nvd_published_at" : null
  }
}