CVE-2021-43840: Path traversal when MessageBus :Diagnostics Is Enabled Vulnerability

MODERATE
Advisory Identifier: GHSA-xmgj-5fh3-xjmm
CVSS 4.2
CWE-22
Published
Advisory Summary

CVE-2021-43840 is a MODERATE (CVSS 4.2) :diagnostics is enabled vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Path traversal when MessageBus libraries in the RubyGems ecosystem. The issue involves :diagnostics is enabled. Remediation is available by upgrading affected packages to version 3.3.7.

CVE-2021-43840 at a Glance

CVE Identifier CVE-2021-43840
GHSA Identifier GHSA-xmgj-5fh3-xjmm
Severity MODERATE
CVSS v3.1 Base Score 4.2
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Path traversal when MessageBus
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 4.2

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

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

How to Fix CVE-2021-43840

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

message_bus fixed: 3.3.7
Upgrade message_bus to 3.3.7
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 message_bus

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-43840, inspect your project dependencies for Path traversal when MessageBus:

inspect dependencies for message_bus

Analyze the terminal output to locate any version of Path traversal when MessageBus in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.3.7), 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Path traversal when MessageBus, 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 Users who deployed message bus with diagnostics features enabled (default off) were vulnerable to a path traversal bug, which could lead to disclosure of secret information on a machine if an unintended user were to gain access to the diagnostic route. The impact is also greater if there is no proxy for your web application as the number of steps up the directories is not bounded. For deployments which uses a proxy, the impact varies. For example, If a request goes through a proxy like Nginx with `merge_slashes` enabled, the number of steps up the directories that can be read is limited to 3 levels. ### Patches Patched in 3.3.7. ### Workarounds Disable MessageBus::Diagnostics in production like environments.

CVE-2021-43840 Affected Path traversal when MessageBus Versions

1 component(s)
Fixed Versions:
3.3.7
Product / Package Ecosystem Affected Versions Fixed Version
message_bus
RubyGems
< 3.3.7
3.3.7

References

Frequently Asked Questions

What is CVE-2021-43840?
CVE-2021-43840 is a security vulnerability in Path traversal when MessageBus involving :Diagnostics is enabled under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Path traversal when MessageBus versions are affected?
Affected versions include releases prior to 3.3.7 across affected packages: message_bus.
What version fixes CVE-2021-43840?
Upgrading to 3.3.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is message_bus affected?
Yes, message_bus is affected in releases prior to 3.3.7. Upgrade your dependency to 3.3.7 or later.
What is the CVSS score of CVE-2021-43840?
CVE-2021-43840 has a CVSS v3.1 base score of 4.2 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2021-43840?
CVE-2021-43840 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check RubyGems dependencies for CVE-2021-43840?
Run the dependency tree command: 'inspect dependencies for message_bus'. 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-xmgj-5fh3-xjmm",
  "modified" : "2021-12-17T19:34:45Z",
  "published" : "2021-12-17T19:59:13Z",
  "aliases" : [ "CVE-2021-43840" ],
  "summary" : "Path traversal when MessageBus::Diagnostics is enabled",
  "details" : "### Impact\n\nUsers who deployed message bus with diagnostics features enabled (default off) were vulnerable to a path traversal bug, which could lead to disclosure of secret information on a machine if an unintended user were to gain access to the diagnostic route. The impact is also greater if there is no proxy for your web application as the number of steps up the directories is not bounded. For deployments which uses a proxy, the impact varies. For example, If a request goes through a proxy like Nginx with `merge_slashes` enabled, the number of steps up the directories that can be read is limited to 3 levels. \n\n### Patches\n\nPatched in 3.3.7.\n\n### Workarounds\n\nDisable MessageBus::Diagnostics in production like environments. \n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "message_bus"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.3.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/discourse/message_bus/security/advisories/GHSA-xmgj-5fh3-xjmm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43840"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/discourse/message_bus/commit/9b6deee01ed474c7e9b5ff65a06bb0447b4db2ba"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/discourse/message_bus"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/message_bus/CVE-2021-43840.yml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-12-17T19:34:45Z",
    "nvd_published_at" : "2021-12-17T19:15:00Z"
  }
}