CVE-2024-9312: Github.com/ubuntu/authd Authd Allows Attacker-controlled Usernames To Vulnerability

MODERATE
Advisory Identifier: GHSA-4gfw-wf7c-w6g2
CVSS 7.5
CWE-286
Published
Advisory Summary

CVE-2024-9312 is a MODERATE (CVSS 7.5) authd allows attacker-controlled usernames to vulnerability (CWE-286: Incorrect User Management) affecting Github.com/ubuntu/authd libraries in the Go ecosystem. The issue involves authd allows attacker-controlled usernames to yield controllable uids. Remediation is available in the latest vendor maintenance releases.

CVE-2024-9312 at a Glance

CVE Identifier CVE-2024-9312
GHSA Identifier GHSA-4gfw-wf7c-w6g2
Severity MODERATE
CVSS v3.1 Base Score 7.5
CWE Classification CWE-286: Incorrect User Management
Affected Product Github.com/ubuntu/authd
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/S:C/C:H/I:H/A:H).

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

How to Fix CVE-2024-9312

To remediate this vulnerability, upgrade all affected Github.com/ubuntu/authd 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/ubuntu/authd fixed: Latest secure release
Upgrade github.com/ubuntu/authd to Latest secure release
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/ubuntu/authd

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-9312, inspect your project dependencies for Github.com/ubuntu/authd:

inspect dependencies for github.com/ubuntu/authd

Analyze the terminal output to locate any version of Github.com/ubuntu/authd in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), 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-286: Incorrect User Management, where the product does not properly manage a user within its environment. In Github.com/ubuntu/authd, 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

CVE description: Authd, through version 0.3.6, did not sufficiently randomize user IDs to prevent collisions. A local attacker who can register user names could spoof another user's ID and gain their privileges. ----- original report ----- # Cause authd assigns user IDs as a pure function of the user name. Moreover, the set of UIDs is much too small for pseudo-random assignment to work: the birthday bound predicts random collisions will occur with probability 50% after only 54 562 IDs were assigned. `authd` only checks for uniqueness [within its local cache](https://github.com/ubuntu/authd/blob/4946962aa4ac6e5b7d2b53503026659581c73907/internal/users/cache/update.go#L67-L71), which - may be inconsistent across multiple systems within the same domain ; - may be purged, due to being stored in `/var/cache` ; - automatically removes entries of users who have not logged into that specific system within the last 6 months. The current `GenerateID` method, authored in September 2024 (commit a6c85ed24b8d17a2d11c859e8d70f5a52fa69690), repeatedly hashes the user name until the 4 leading bytes fall into the interval [60 000; 2³¹[ : https://github.com/ubuntu/authd/blob/f9f851540e6377fca18a45ce7a02d024c1dbd6e9/internal/users/manager.go#L425 https://github.com/ubuntu/authd/blob/f9f851540e6377fca18a45ce7a02d024c1dbd6e9/internal/services/nss/nss.go#L188 Previous versions are affected by similar issues, though without the use of a cryptographic hash in `GenerateID`, making exploitation computationally-easier. # Impact Since GenerateID is a pure function with no secret input, and the set of UIDs is small, an adversary which can register users with chosen names can - register multiple users with colliding IDs, or - register a single user whose ID collides with a target user's, whether one managed by `authd`, or a system user whose well-known ID is in a range which [overlaps `authd`'s]. In the latter case, as all access control performed by the Linux kernel (and other Unices' kernels) is based on IDs and not usernames, if the attacker can sign into a system, they will have the same privileges as the target user. The attacker can bypass the uniqueness check in (at least) the following ways: - engineer a situation where the system administrator purges `/var/cache` ; - target a system account [whose UID is in `authd`'s range](https://github.com/ubuntu/authd/issues/547) ; - target an account which hasn't logged into a specific system in more than 6 months. Note that this isn't limited to inactive accounts *within the entire domain*, and impersonation on a given system can potentially be leveraged to compromise the target account on other systems; for example: - user `alice` is known to log into `1.example.com` ; - the attacker computes a preimage (a username which yields the same UID), let's call it `bob` ; - the attacker creates the account `bob` and logs into `2.example.com`, succeeding if alice hasn't (recently) logged into that system ; - the attacker can now manipulate resources exposed on `2` as if they were alice; assuming `/home` is shared, they could manipulate `~alice/.ssh/authorized_keys`, `~alice/.config`, alice's shell's initialization file, etc. Note: NFSv4's `idmap` mechanism may prevent this, but isn't enabled by default (unless Kerberos is used, which isn't the case in an `authd` deployment) - at that point, gaining code execution as alice on `1.example.com` is usually trivial. Since the necessary computation can be performed entirely offline, this wouldn't be affected by any rate-limits, and the only audit trail would be a single user registration. This would require on average less than 2³¹ computations of `GenerateID`: assuming SHA-256's cost is 25 cycles-per-byte, a clock speed of 3GHz, and short (≤32B) generated usernames, this is less than 10 minutes of a single core's time. [overlaps `authd`'s]: https://github.com/ubuntu/authd/issues/547 # Remediation The simplest and likely-best remediation path would be for the external IdP to provide a guaranteed-unique user ID in the correct range. In OIDC, this is commonly communicated through a claim, though its name would need to be configurable as there's no real standard: - CERN uses `cern_person_id`: https://auth.docs.cern.ch/user-documentation/oidc/config/ ; - Okta, Zitadel, and many other IdPs, require the realm's administrator to define a custom attribute, conventionally called `uid` or `uidNumber` ; - etc. This is also supported by other commonplace identity providers, such as LDAP and Active Directory: https://learn.microsoft.com/en-us/windows/win32/adschema/a-uidNumber MS Entra presumably supports this as well. If that is not possible for some reason, architectural changes to authd would likely be required: assigning user IDs from a small space (such as Linux's 32b UIDs) requires mutable state to ensure uniqueness, whereas authd's design currently assumes no mutable state is held, aside from some transient, local cache. Moreover, that mutable state may need to be synchronised across multiple machines as uniform UIDs are often necessary, for instance when accessing a common networked filesystem. # Acknowledgements Thanks to Michael Gebetsroither for assisting with the writeup, and Jamie Bliss for the same as well as investigating when the issue was introduced in authd.

CVE-2024-9312 Affected Github.com/ubuntu/authd Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
github.com/ubuntu/authd
Go
≤ 0.0.0-20230706090440-d8cb2d561419

References

Frequently Asked Questions

What is CVE-2024-9312?
CVE-2024-9312 is a security vulnerability in Github.com/ubuntu/authd involving Authd allows attacker-controlled usernames to yield controllable UIDs under CWE-286: Incorrect User Management.
Which Github.com/ubuntu/authd versions are affected?
Affected versions include releases prior to current release patches across affected packages: github.com/ubuntu/authd.
What version fixes CVE-2024-9312?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/ubuntu/authd affected?
Yes, github.com/ubuntu/authd is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2024-9312?
CVE-2024-9312 has a CVSS v3.1 base score of 7.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2024-9312?
CVE-2024-9312 is classified under CWE-286: Incorrect User Management (The product does not properly manage a user within its environment.).
How can I check Go dependencies for CVE-2024-9312?
Run the dependency tree command: 'inspect dependencies for github.com/ubuntu/authd'. 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-4gfw-wf7c-w6g2",
  "modified" : "2024-10-10T16:43:58Z",
  "published" : "2024-10-10T16:43:58Z",
  "aliases" : [ "CVE-2024-9312" ],
  "summary" : "Authd allows attacker-controlled usernames to yield controllable UIDs",
  "details" : "CVE description:\n\nAuthd, through version 0.3.6, did not sufficiently randomize user IDs to prevent collisions. A local attacker who can register user names could spoof another user's ID and gain their privileges.\n\n\n----- original report -----\n# Cause\nauthd assigns user IDs as a pure function of the user name. Moreover, the set of UIDs is much too small for pseudo-random assignment to work: the birthday bound predicts random collisions will occur with probability 50% after only 54 562 IDs were assigned.\n\n`authd` only checks for uniqueness [within its local cache](https://github.com/ubuntu/authd/blob/4946962aa4ac6e5b7d2b53503026659581c73907/internal/users/cache/update.go#L67-L71), which\n- may be inconsistent across multiple systems within the same domain ;\n- may be purged, due to being stored in `/var/cache` ;\n- automatically removes entries of users who have not logged into that specific system within the last 6 months.\n\nThe current `GenerateID` method, authored in September 2024 (commit a6c85ed24b8d17a2d11c859e8d70f5a52fa69690),\nrepeatedly hashes the user name until the 4 leading bytes fall into the interval [60 000; 2³¹[ :\nhttps://github.com/ubuntu/authd/blob/f9f851540e6377fca18a45ce7a02d024c1dbd6e9/internal/users/manager.go#L425\nhttps://github.com/ubuntu/authd/blob/f9f851540e6377fca18a45ce7a02d024c1dbd6e9/internal/services/nss/nss.go#L188\n\nPrevious versions are affected by similar issues, though without the use of a cryptographic hash in `GenerateID`, making exploitation computationally-easier.\n\n\n# Impact\n\nSince GenerateID is a pure function with no secret input, and the set of UIDs is small, an adversary which can register users with chosen names can\n- register multiple users with colliding IDs, or\n- register a single user whose ID collides with a target user's, whether one managed by `authd`, or a system user whose well-known ID is in a range which [overlaps `authd`'s].\n\nIn the latter case, as all access control performed by the Linux kernel (and other Unices' kernels) is based on IDs and not usernames, if the attacker can sign into a system, they will have the same privileges as the target user.  The attacker can bypass the uniqueness check in (at least) the following ways:\n- engineer a situation where the system administrator purges `/var/cache` ;\n- target a system account [whose UID is in `authd`'s range](https://github.com/ubuntu/authd/issues/547) ;\n- target an account which hasn't logged into a specific system in more than 6 months.\n  Note that this isn't limited to inactive accounts *within the entire domain*, and impersonation on a given system can potentially be leveraged to compromise the target account on other systems; for example:\n  - user `alice` is known to log into `1.example.com` ;\n  - the attacker computes a preimage (a username which yields the same UID), let's call it `bob` ;\n  - the attacker creates the account `bob` and logs into `2.example.com`, succeeding if alice hasn't (recently) logged into that system ;\n  - the attacker can now manipulate resources exposed on `2` as if they were alice; assuming `/home` is shared, they could manipulate `~alice/.ssh/authorized_keys`, `~alice/.config`, alice's shell's initialization file, etc.\n    Note: NFSv4's `idmap` mechanism may prevent this, but isn't enabled by default (unless Kerberos is used, which isn't the case in an `authd` deployment)\n  - at that point, gaining code execution as alice on `1.example.com` is usually trivial.\n\nSince the necessary computation can be performed entirely offline, this wouldn't be affected by any rate-limits, and the only audit trail would be a single user registration. This would require on average less than 2³¹ computations of `GenerateID`: assuming SHA-256's cost is 25 cycles-per-byte, a clock speed of 3GHz, and short (≤32B) generated usernames, this is less than 10 minutes of a single core's time.\n\n[overlaps `authd`'s]: https://github.com/ubuntu/authd/issues/547\n\n# Remediation\n\nThe simplest and likely-best remediation path would be for the external IdP to provide a guaranteed-unique user ID in the correct range.\nIn OIDC, this is commonly communicated through a claim, though its name would need to be configurable as there's no real standard:\n- CERN uses `cern_person_id`: https://auth.docs.cern.ch/user-documentation/oidc/config/ ;\n- Okta, Zitadel, and many other IdPs, require the realm's administrator to define a custom attribute, conventionally called `uid` or `uidNumber` ;\n- etc.\n\nThis is also supported by other commonplace identity providers, such as LDAP and Active Directory:\nhttps://learn.microsoft.com/en-us/windows/win32/adschema/a-uidNumber\n\nMS Entra presumably supports this as well.\n\n\nIf that is not possible for some reason, architectural changes to authd would likely be required:\nassigning user IDs from a small space (such as Linux's 32b UIDs) requires mutable state to ensure uniqueness, whereas authd's design currently assumes no mutable state is held, aside from some transient, local cache.\nMoreover, that mutable state may need to be synchronised across multiple machines as uniform UIDs are often necessary, for instance when accessing a common networked filesystem.\n\n\n# Acknowledgements\n\nThanks to Michael Gebetsroither for assisting with the writeup, and Jamie Bliss for the same as well as investigating when the issue was introduced in authd.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/ubuntu/authd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.0.0-20230706090440-d8cb2d561419"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ubuntu/authd/security/advisories/GHSA-4gfw-wf7c-w6g2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-9312"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ubuntu/authd"
  }, {
    "type" : "WEB",
    "url" : "https://www.cve.org/CVERecord?id=CVE-2024-9312"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-286" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-10-10T16:43:58Z",
    "nvd_published_at" : "2024-10-10T14:15:05Z"
  }
}