CVE-2021-37941: Elastic apm APM Java Agent Local Privilege Vulnerability

HIGH
Advisory Identifier: GHSA-r562-m862-63w3
CVSS 7.8
CWE-269
Published
Advisory Summary

CVE-2021-37941 is a HIGH (CVSS 7.8) apm java agent local privilege vulnerability (CWE-269: Improper Privilege Management) affecting Elastic apm libraries in the PyPI ecosystem. The issue involves apm java agent local privilege escalation. Remediation is available by upgrading affected packages to version 1.27.0.

CVE-2021-37941 at a Glance

CVE Identifier CVE-2021-37941
GHSA Identifier GHSA-r562-m862-63w3
Severity HIGH
CVSS v3.1 Base Score 7.8
CWE Classification CWE-269: Improper Privilege Management
Affected Product Elastic apm
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.8

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

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

How to Fix CVE-2021-37941

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

elastic-apm fixed: 1.27.0
pip install elastic-apm>=1.27.0
Verify Direct and Transitive Dependencies

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

pip show elastic-apm

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2021-37941, inspect your installed packages using pip:

pip show elastic-apm

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

Note: The pip show elastic-apm command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-269: Improper Privilege Management, where the product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor. In Elastic apm, 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

A local privilege escalation issue was found with the APM Java agent, where a user on the system could attach a malicious file to an application running with the APM Java agent. Using this vector, a malicious or compromised user account could use the agent to run commands at a higher level of permissions than they possess. This vulnerability affects users that have set up the agent via the attacher cli 3, the attach API 2, as well as users that have enabled the profiling_inferred_spans_enabled option

CVE-2021-37941 Affected Elastic apm Versions

1 component(s)
Fixed Versions:
1.27.0
Product / Package Ecosystem Affected Versions Fixed Version
elastic-apm
PyPI
≥ 1.10.0
< 1.27.0
1.27.0

References

Frequently Asked Questions

What is CVE-2021-37941?
CVE-2021-37941 is a security vulnerability in Elastic apm involving APM Java Agent Local Privilege Escalation under CWE-269: Improper Privilege Management.
Which Elastic apm versions are affected?
Affected versions include releases prior to 1.27.0 across affected packages: elastic-apm.
What version fixes CVE-2021-37941?
Upgrading to 1.27.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is elastic-apm affected?
Yes, elastic-apm is affected in releases prior to 1.27.0. Upgrade your dependency to 1.27.0 or later.
What is the CVSS score of CVE-2021-37941?
CVE-2021-37941 has a CVSS v3.1 base score of 7.8 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-37941?
CVE-2021-37941 is classified under CWE-269: Improper Privilege Management (The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.).
How can I check PyPI dependencies for CVE-2021-37941?
Run the dependency tree command: 'pip show elastic-apm'. 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-r562-m862-63w3",
  "modified" : "2024-04-22T22:34:38Z",
  "published" : "2021-12-09T00:00:28Z",
  "aliases" : [ "CVE-2021-37941" ],
  "summary" : "APM Java Agent Local Privilege Escalation",
  "details" : "A local privilege escalation issue was found with the APM Java agent, where a user on the system could attach a malicious file to an application running with the APM Java agent. Using this vector, a malicious or compromised user account could use the agent to run commands at a higher level of permissions than they possess. This vulnerability affects users that have set up the agent via the attacher cli 3, the attach API 2, as well as users that have enabled the profiling_inferred_spans_enabled option",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "elastic-apm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.10.0"
      }, {
        "fixed" : "1.27.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-37941"
  }, {
    "type" : "WEB",
    "url" : "https://discuss.elastic.co/t/apm-java-agent-security-update/289627"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/elastic/apm-agent-python"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-269" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-22T22:34:38Z",
    "nvd_published_at" : "2021-12-08T22:15:00Z"
  }
}