CVE-2024-5138: CVE-2024-5138 Snapd Snapctl Auth Bypass Vulnerability

MODERATE
Advisory Identifier: GHSA-p9v8-q5m4-pf46
CVSS 4.0
CWE-285
Published
Advisory Summary

CVE-2024-5138 is a MODERATE (CVSS 4.0) snapd snapctl auth bypass vulnerability (CWE-285: Improper Authorization) affecting CVE-2024-5138 libraries in the Go ecosystem. The issue involves snapd snapctl auth bypass. Remediation is available by upgrading affected packages to version 2.63.1, 0.0.0-20240524114846-68ee9c6aa916.

CVE-2024-5138 at a Glance

CVE Identifier CVE-2024-5138
GHSA Identifier GHSA-p9v8-q5m4-pf46
Severity MODERATE
CVSS v3.1 Base Score 4.0
CWE Classification CWE-285: Improper Authorization
Affected Product CVE-2024-5138
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 4.0

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

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

How to Fix CVE-2024-5138

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

github.com/snapcore/snapd fixed: 2.63.1
Upgrade github.com/snapcore/snapd to 2.63.1
github.com/snapcore/snapd fixed: 0.0.0-20240524114846-68ee9c6aa916
Upgrade github.com/snapcore/snapd to 0.0.0-20240524114846-68ee9c6aa916
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 github.com/snapcore/snapd

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-5138, inspect your project dependencies for CVE-2024-5138:

inspect dependencies for github.com/snapcore/snapd

Analyze the terminal output to locate any version of CVE-2024-5138 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.63.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-285: Improper Authorization, where the product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action. In CVE-2024-5138, 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 A snap with prior permissions to create a mount entry on the host, such as firefox, normally uses the permission from one of the per-snap hook programs. A unprivileged users cannot normally trigger that behaviour by using `snap run --shell firefox` followed by `snapctl mount`, since snapd validates the requesting user identity (root or non-root). The issue allows unprivileged users to bypass that check by crafting a malicious command line vector which confuses snapd into thinking the help message is requested. Unprivileged user on a default installation of Ubuntu, where firefox is as provided as a snap, may cause a denial-of-service attack by repeatedly mounting hunspell database over and over and eventually exhausting system memory. Other attacks, reliant on the same underying mechanism (mount), are possible. In all cases the snap must be installed and grated permission to perform this action (by connecting an appropriate snap interface), which requires administrative privileges. As such we are focusing on the case of default installation where an unprivileged user may exploit this behavior. ### Patches Patch: https://github.com/canonical/snapd/commit/68ee9c6aa916ab87dbfd9a26030690f2cabf1e14 Release: Available from Snapd 2.64 ### Workarounds Users may disconnect any instances of the mount-control interface to prevent snapd from creating such mount points. For example, the firefox snap has the `host-hunspell` plug, which is of type `mount-control`. The interface can be disconnected with: ```sh sudo snap disconnect firefox:host-hunspell ``` ### References The original bug report was made on Launchpad: https://bugs.launchpad.net/snapd/+bug/2065077 CVE.org: https://www.cve.org/CVERecord?id=CVE-2024-5138 Canonical: https://ubuntu.com/security/CVE-2024-5138

CVE-2024-5138 Affected CVE-2024-5138 Versions

2 component(s)
Fixed Versions:
2.63.10.0.0-20240524114846-68ee9c6aa916
Product / Package Ecosystem Affected Versions Fixed Version
github.com/snapcore/snapd
Go
≥ 2.51.6
< 2.63.1
2.63.1
github.com/snapcore/snapd
Go
< 0.0.0-20240524114846-68ee9c6aa916
0.0.0-20240524114846-68ee9c6aa916

References

Frequently Asked Questions

What is CVE-2024-5138?
CVE-2024-5138 is a security vulnerability in CVE-2024-5138 involving snapd snapctl auth bypass under CWE-285: Improper Authorization.
Which CVE-2024-5138 versions are affected?
Affected versions include releases prior to 2.63.1, 0.0.0-20240524114846-68ee9c6aa916 across affected packages: github.com/snapcore/snapd.
What version fixes CVE-2024-5138?
Upgrading to 2.63.1, 0.0.0-20240524114846-68ee9c6aa916 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/snapcore/snapd affected?
Yes, github.com/snapcore/snapd is affected in releases prior to 2.63.1, 0.0.0-20240524114846-68ee9c6aa916. Upgrade your dependency to 2.63.1, 0.0.0-20240524114846-68ee9c6aa916 or later.
What is the CVSS score of CVE-2024-5138?
CVE-2024-5138 has a CVSS v3.1 base score of 4.0 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2024-5138?
CVE-2024-5138 is classified under CWE-285: Improper Authorization (The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.).
How can I check Go dependencies for CVE-2024-5138?
Run the dependency tree command: 'inspect dependencies for github.com/snapcore/snapd'. 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-p9v8-q5m4-pf46",
  "modified" : "2025-01-16T17:19:07Z",
  "published" : "2025-01-16T17:19:07Z",
  "aliases" : [ "CVE-2024-5138" ],
  "summary" : "CVE-2024-5138: snapd snapctl auth bypass",
  "details" : "### Impact\n\nA snap with prior permissions to create a mount entry on the host, such as firefox, normally uses the permission from one of the per-snap hook programs. A unprivileged users cannot normally trigger that behaviour by using `snap run --shell firefox` followed by `snapctl mount`, since snapd validates the requesting user identity (root or non-root). The issue allows unprivileged users to bypass that check by crafting a malicious command line vector which confuses snapd into thinking the help message is requested.\n\nUnprivileged user on a default installation of Ubuntu, where firefox is as provided as a snap, may cause a denial-of-service attack by repeatedly mounting hunspell database over and over and eventually exhausting system memory.\n\nOther attacks, reliant on the same underying mechanism (mount), are possible. In all cases the snap must be installed and grated permission to perform this action (by connecting an appropriate snap interface), which requires administrative privileges. As such we are focusing on the case of default installation where an unprivileged user may exploit this behavior.\n\n### Patches\n\nPatch: https://github.com/canonical/snapd/commit/68ee9c6aa916ab87dbfd9a26030690f2cabf1e14\nRelease: Available from Snapd 2.64\n\n### Workarounds\n\nUsers may disconnect any instances of the mount-control interface to prevent snapd from creating such mount points. For example, the firefox snap has the `host-hunspell` plug, which is of type `mount-control`. The interface can be disconnected with:\n\n```sh\nsudo snap disconnect firefox:host-hunspell\n```\n\n### References\n\nThe original bug report was made on Launchpad: https://bugs.launchpad.net/snapd/+bug/2065077\nCVE.org: https://www.cve.org/CVERecord?id=CVE-2024-5138\nCanonical: https://ubuntu.com/security/CVE-2024-5138",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/snapcore/snapd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.51.6"
      }, {
        "fixed" : "2.63.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/snapcore/snapd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.0.0-20240524114846-68ee9c6aa916"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/canonical/snapd/security/advisories/GHSA-p9v8-q5m4-pf46"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/canonical/snapd/commit/68ee9c6aa916ab87dbfd9a26030690f2cabf1e14"
  }, {
    "type" : "WEB",
    "url" : "https://bugs.launchpad.net/snapd/+bug/2065077"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/canonical/snapd"
  }, {
    "type" : "WEB",
    "url" : "https://ubuntu.com/security/CVE-2024-5138"
  }, {
    "type" : "WEB",
    "url" : "https://www.cve.org/CVERecord?id=CVE-2024-5138"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-285" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-01-16T17:19:07Z",
    "nvd_published_at" : null
  }
}