CVE-2024-21624: Nonebot2 NoneBot Potential Information Leak Vulnerability

MODERATE
Advisory Identifier: GHSA-59j8-776v-xxxg
CVSS 5.7
CWE-200 CWE-1336
Published
Advisory Summary

CVE-2024-21624 is a MODERATE (CVSS 5.7) nonebot potential information leak vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Nonebot2 libraries in the PyPI ecosystem. The issue involves nonebot potential information leak in user-constructed message templates. Remediation is available by upgrading affected packages to version 2.2.0.

CVE-2024-21624 at a Glance

CVE Identifier CVE-2024-21624
GHSA Identifier GHSA-59j8-776v-xxxg
Severity MODERATE
CVSS v3.1 Base Score 5.7
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product Nonebot2
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.7

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:U/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 Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-21624

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

nonebot2 fixed: 2.2.0
pip install nonebot2>=2.2.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 nonebot2

How to Check if You Are Affected

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

pip show nonebot2

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. In Nonebot2, 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 This security advisory pertains to a potential information leak (e.g., environment variables) in instances where developers utilize `MessageTemplate` and incorporate user-provided data into templates. ### Patches The identified vulnerability has been remedied in fix #2509 and will be included in versions released after 2.1.3. Users are strongly advised to upgrade to these patched versions to safeguard against the vulnerability. ### Workarounds A temporary workaround involves filtering underscores before incorporating user input into the message template. ### References - [Pull Request #2509](https://github.com/nonebot/nonebot2/pull/2509) - [CWE-1336](https://cwe.mitre.org/data/definitions/1336.html)

CVE-2024-21624 Affected Nonebot2 Versions

1 component(s)
Fixed Versions:
2.2.0
Product / Package Ecosystem Affected Versions Fixed Version
nonebot2
PyPI
≥ 2.0.0a16
< 2.2.0
2.2.0

References

Frequently Asked Questions

What is CVE-2024-21624?
CVE-2024-21624 is a security vulnerability in Nonebot2 involving NoneBot Potential Information Leak in User-Constructed Message Templates under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which Nonebot2 versions are affected?
Affected versions include releases prior to 2.2.0 across affected packages: nonebot2.
What version fixes CVE-2024-21624?
Upgrading to 2.2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nonebot2 affected?
Yes, nonebot2 is affected in releases prior to 2.2.0. Upgrade your dependency to 2.2.0 or later.
What is the CVSS score of CVE-2024-21624?
CVE-2024-21624 has a CVSS v3.1 base score of 5.7 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2024-21624?
CVE-2024-21624 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check PyPI dependencies for CVE-2024-21624?
Run the dependency tree command: 'pip show nonebot2'. 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-59j8-776v-xxxg",
  "modified" : "2024-02-16T22:31:37Z",
  "published" : "2024-02-09T15:04:08Z",
  "aliases" : [ "CVE-2024-21624" ],
  "summary" : "NoneBot Potential Information Leak in User-Constructed Message Templates",
  "details" : "### Impact\nThis security advisory pertains to a potential information leak (e.g., environment variables) in instances where developers utilize `MessageTemplate` and incorporate user-provided data into templates.\n\n### Patches\nThe identified vulnerability has been remedied in fix #2509 and will be included in versions released after 2.1.3. Users are strongly advised to upgrade to these patched versions to safeguard against the vulnerability.\n\n### Workarounds\nA temporary workaround involves filtering underscores before incorporating user input into the message template.\n\n### References\n- [Pull Request #2509](https://github.com/nonebot/nonebot2/pull/2509)\n- [CWE-1336](https://cwe.mitre.org/data/definitions/1336.html)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "nonebot2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0a16"
      }, {
        "fixed" : "2.2.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.1.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nonebot/nonebot2/security/advisories/GHSA-59j8-776v-xxxg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-21624"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nonebot/nonebot2/pull/2509"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nonebot/nonebot2/commit/b65b3b438c95894654fd9081139989c757bdc6c1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nonebot/nonebot2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/nonebot2/PYSEC-2024-37.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1336", "CWE-200" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-02-09T15:04:08Z",
    "nvd_published_at" : "2024-02-09T23:15:08Z"
  }
}