CVE-2023-30549: Github.com/apptainer/apptainer Unpatched Extfs Vulnerabilities Are Exploitable Vulnerability

HIGH
Advisory Identifier: GHSA-j4rf-7357-f4cg
CVSS 7.0
CWE-416
Published
Advisory Summary

CVE-2023-30549 is a HIGH (CVSS 7.0) unpatched extfs vulnerabilities are exploitable vulnerability (CWE-416: Use After Free) affecting Github.com/apptainer/apptainer libraries in the Go ecosystem. The issue involves unpatched extfs vulnerabilities are exploitable through suid-mode apptainer. Remediation is available by upgrading affected packages to version 1.1.8.

CVE-2023-30549 at a Glance

CVE Identifier CVE-2023-30549
GHSA Identifier GHSA-j4rf-7357-f4cg
Severity HIGH
CVSS v3.1 Base Score 7.0
CWE Classification CWE-416: Use After Free
Affected Product Github.com/apptainer/apptainer
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.0

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

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
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-2023-30549

To remediate this vulnerability, upgrade all affected Github.com/apptainer/apptainer 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/apptainer/apptainer fixed: 1.1.8
Upgrade github.com/apptainer/apptainer to 1.1.8
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/apptainer/apptainer

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-30549, inspect your project dependencies for Github.com/apptainer/apptainer:

inspect dependencies for github.com/apptainer/apptainer

Analyze the terminal output to locate any version of Github.com/apptainer/apptainer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.8), 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-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. In Github.com/apptainer/apptainer, 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 There is an ext4 use-after-free flaw described in CVE-2022-1184 that is exploitable through versions of Apptainer < 1.1.0 and installations that include apptainer-suid < 1.1.8 on older operating systems where that CVE has not been patched. That includes Red Hat Enterprise Linux 7, Debian 10 buster (unless the linux-5.10 package is installed), Ubuntu 18.04 bionic and Ubuntu 20.04 focal. Use-after-free flaws in the kernel can be used to attack the kernel for denial of service and potentially for privilege escalation. ### Background Historically there have been many CVEs published for extfs and a smaller number for squashfs, including serious use-after-free and buffer overrun vulnerabilities, that are scored as "Moderate" or "Low" impact only because unprivileged users were assumed to not have write access to the raw data. Because of those ratings, vendors treat such CVEs as low urgency and either delay a patch until their next major release or never patch older but still supported operating systems at all. Many Linux distributions automatically mount user-writable USB-drive volumes, but those are considered low risk because they require physical access to the machine. However, since setuid-root installations of Apptainer by default allow all users to mount any extfs (specifically, ext3, which is implemented by the ext4 driver) and squashfs filesystem using kernel drivers even though the users have write access to the raw data, the setuid-root installations raise the severity of such unpatched CVEs. CVE-2022-1184 is currently such an unpatched CVE, at least on the above listed operating systems. The descriptions from the operating system vendors about the CVE (referenced below) are incomplete, saying only that it allows a local attacker with user privilege to cause a denial of service. Normally users would not be able to cause it because they cannot modify the filesystem image, and normally vulnerabilities that involve kernel memory corruption by unprivileged users are considered high severity even when there is not yet a known privilege escalation because someone with sufficient kernel knowledge can usually turn such a corruption into a privilege escalation. Red Hat did not list RHEL7 as vulnerable, but they also did not list it as unaffected, and testing confirmed that a filesystem image could be corrupted to get past the check inserted into the filesystem driver to fix the vulnerability (patches linked below). All published squashfs CVEs have been patched in currently supported major operating systems. ### Patches Apptainer 1.1.8 includes a patch that by default disables mounting of extfs filesystem types in setuid-root mode, while continuing to allow mounting of extfs filesystems in non-setuid "rootless" mode using fuse2fs. ### Workarounds These workarounds are possible: 1. Either do not install apptainer-suid (for versions 1.1.0 through 1.1.7) or set `allow setuid = no` in apptainer.conf. This requires having unprivileged user namespaces enabled and except for apptainer 1.1.x versions will disallow mounting of sif files, extfs files, and squashfs files in addition to other, less significant impacts. (Encrypted sif files are also not supported unprivileged in apptainer 1.1.x.) 2. Alternatively, use the `limit containers` options in apptainer.conf/singularity.conf to limit sif files to trusted users, groups, and/or paths. (The option `allow container extfs = no` disallows mounting extfs overlay files but does not disallow mounting of extfs overlay partitions inside SIF files, so it does not help work around the problem.) ### References https://nvd.nist.gov/vuln/detail/CVE-2022-1184 https://access.redhat.com/security/cve/cve-2022-1184 https://security-tracker.debian.org/tracker/CVE-2022-1184 https://ubuntu.com/security/CVE-2022-1184 Kernel patches for CVE-2022-1184: https://github.com/torvalds/linux/commit/65f8ea4cd57dbd46ea13b41dc8bac03176b04233 https://github.com/torvalds/linux/commit/61a1d87a324ad5e3ed27c6699dfc93218fcf3201 ------ ## Addendum 30 May 2023 New information has become available: many ext4 filesytem vulnerabilities similar to the one in CVE-2022-1184 continue to be found, and most of them do not ever have a CVE assigned. The way to locate them is to search for "syzbot" in linux kernel commit messages under fs/ext4. "syzbot" is a public automated system for finding kernel bugs. Especially when syzbot reports are labeled "KASAN" (Kernel Address Sanitizer) and especially if they involve memory corruption including "use after free", "out of bounds", or "user-memory-access", they are vulnerabilities that can potentially be turned into privilege escalation when an unprivileged user has write access to the underlying data. In particular there are two such commits from this month, May 2023, referenced below. They both have commit messages describing a situation of write access to the underlying data while the kernel has that data mounted as a filesystem. These commits have been backported to currently maintained kernel lines in versions 4.19.293 and 5.4.243, but since they are considered moderate severity, most common OS distributions do not include them immediately. For example since RHEL9.2 was recently announced, they are not likely to be available in RHEL9 until 9.3 is released in about another 6 months. Therefore if system administrators want to be protected against these vulnerabilities while still allowing ext4 filesystem mounts through setuid-root apptainer, they should watch for these types of commits and whenever such commits are released the administrators should update to the latest currently maintained kernel version (bypassing their OS vendor's distribution) and reboot. https://github.com/torvalds/linux/commit/2220eaf90992c11d888fe771055d4de3303 https://github.com/torvalds/linux/commit/4f04351888a83e595571de672e0a4a8b74f https://lwn.net/Articles/932137/ https://lwn.net/Articles/932136/

CVE-2023-30549 Affected Github.com/apptainer/apptainer Versions

1 component(s)
Fixed Versions:
1.1.8
Product / Package Ecosystem Affected Versions Fixed Version
github.com/apptainer/apptainer
Go
< 1.1.8
1.1.8

References

GitHub Advisory / Wiki ADVISORY
https://github.com/apptainer/apptainer/security/advisories/GHSA-j4rf-7357-f4cg
NVD — CVE-2023-30549 NVD
https://nvd.nist.gov/vuln/detail/CVE-2022-1184
NVD — CVE-2023-30549 NVD
https://nvd.nist.gov/vuln/detail/CVE-2023-30549
Security Fix Commit FIX COMMIT
https://github.com/apptainer/apptainer/commit/5a4964f5ba9c8d89a0e353b97f51fd607670a9f7
Security Fix Commit FIX COMMIT
https://github.com/torvalds/linux/commit/2220eaf90992c11d888fe771055d4de3303
Security Fix Commit FIX COMMIT
https://github.com/torvalds/linux/commit/4f04351888a83e595571de672e0a4a8b74f
Security Fix Commit FIX COMMIT
https://github.com/torvalds/linux/commit/61a1d87a324ad5e3ed27c6699dfc93218fcf3201
Security Fix Commit FIX COMMIT
https://github.com/torvalds/linux/commit/65f8ea4cd57dbd46ea13b41dc8bac03176b04233
Github.com/apptainer/apptainer Security Information SECURITY
https://www.suse.com/security/cve/CVE-2022-1184.html
Github.com/apptainer/apptainer Security Information SECURITY
https://ubuntu.com/security/CVE-2022-1184
sylabs.io/2023/04/response-to... WEB
https://sylabs.io/2023/04/response-to-cve-2023-30549
Github.com/apptainer/apptainer Security Information SECURITY
https://security.gentoo.org/glsa/202311-13
Github.com/apptainer/apptainer Security Information SECURITY
https://security-tracker.debian.org/tracker/CVE-2022-1184
lwn.net/articles/932137 WEB
https://lwn.net/Articles/932137
lwn.net/articles/932136 WEB
https://lwn.net/Articles/932136
Github.com/apptainer/apptainer Release RELEASE
https://github.com/apptainer/apptainer/releases/tag/v1.1.8
Github.com/apptainer/apptainer Source Repository REPOSITORY
https://github.com/apptainer/apptainer
Github.com/apptainer/apptainer Security Information SECURITY
https://access.redhat.com/security/cve/cve-2022-1184

Frequently Asked Questions

What is CVE-2023-30549?
CVE-2023-30549 is a security vulnerability in Github.com/apptainer/apptainer involving Unpatched extfs vulnerabilities are exploitable through suid-mode Apptainer under CWE-416: Use After Free.
Which Github.com/apptainer/apptainer versions are affected?
Affected versions include releases prior to 1.1.8 across affected packages: github.com/apptainer/apptainer.
What version fixes CVE-2023-30549?
Upgrading to 1.1.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/apptainer/apptainer affected?
Yes, github.com/apptainer/apptainer is affected in releases prior to 1.1.8. Upgrade your dependency to 1.1.8 or later.
What is the CVSS score of CVE-2023-30549?
CVE-2023-30549 has a CVSS v3.1 base score of 7.0 (HIGH) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2023-30549?
CVE-2023-30549 is classified under CWE-416: Use After Free (The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.).
How can I check Go dependencies for CVE-2023-30549?
Run the dependency tree command: 'inspect dependencies for github.com/apptainer/apptainer'. 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-j4rf-7357-f4cg",
  "modified" : "2023-07-07T23:16:31Z",
  "published" : "2023-04-25T19:48:35Z",
  "aliases" : [ "CVE-2023-30549" ],
  "summary" : "Unpatched extfs vulnerabilities are exploitable through suid-mode Apptainer",
  "details" : "### Impact\nThere is an ext4 use-after-free flaw described in CVE-2022-1184 that is exploitable through versions of Apptainer < 1.1.0 and installations that include apptainer-suid < 1.1.8 on older operating systems where that CVE has not been patched.  That includes Red Hat Enterprise Linux 7, Debian 10 buster (unless the linux-5.10 package is installed), Ubuntu 18.04 bionic and Ubuntu 20.04 focal.  Use-after-free flaws in the kernel can be used to attack the kernel for denial of service and potentially for privilege escalation.\n\n### Background\nHistorically there have been many CVEs published for extfs and a smaller number for squashfs, including serious use-after-free and buffer overrun vulnerabilities, that are scored as \"Moderate\" or \"Low\" impact only because unprivileged users were assumed to not have write access to the raw data.  Because of those ratings, vendors treat such CVEs as low urgency and either delay a patch until their next major release or never patch older but still supported operating systems at all.  Many Linux distributions automatically mount user-writable USB-drive volumes, but those are considered low risk because they require physical access to the machine.  However, since setuid-root installations of Apptainer by default allow all users to mount any extfs (specifically, ext3, which is implemented by the ext4 driver) and squashfs filesystem using kernel drivers even though the users have write access to the raw data, the setuid-root installations raise the severity of such unpatched CVEs.  \n\nCVE-2022-1184 is currently such an unpatched CVE, at least on the above listed operating systems.  The descriptions from the operating system vendors about the CVE (referenced below) are incomplete, saying only that it allows a local attacker with user privilege to cause a denial of service.  Normally users would not be able to cause it because they cannot modify the filesystem image, and normally vulnerabilities that involve kernel memory corruption by unprivileged users are considered high severity even when there is not yet a known privilege escalation because someone with sufficient kernel knowledge can usually turn such a corruption into a privilege escalation. \n\nRed Hat did not list RHEL7 as vulnerable, but they also did not list it as unaffected, and testing confirmed that a filesystem image could be corrupted to get past the check inserted into the filesystem driver to fix the vulnerability (patches linked below).\n\nAll published squashfs CVEs have been patched in currently supported major operating systems.\n\n### Patches\nApptainer 1.1.8 includes a patch that by default disables mounting of extfs filesystem types in setuid-root mode, while continuing to allow mounting of extfs filesystems in non-setuid \"rootless\" mode using fuse2fs.\n\n### Workarounds\nThese workarounds are possible:\n1. Either do not install apptainer-suid (for versions 1.1.0 through 1.1.7) or set `allow setuid = no` in apptainer.conf.  This requires having unprivileged user namespaces enabled and except for apptainer 1.1.x versions will disallow mounting of sif files, extfs files, and squashfs files in addition to other, less significant impacts.  (Encrypted sif files are also not supported unprivileged in apptainer 1.1.x.)\n2. Alternatively, use the `limit containers` options in apptainer.conf/singularity.conf to limit sif files to trusted users, groups, and/or paths.  (The option `allow container extfs = no` disallows mounting extfs overlay files but does not disallow mounting of extfs overlay partitions inside SIF files, so it does not help work around the problem.)\n\n### References\nhttps://nvd.nist.gov/vuln/detail/CVE-2022-1184\nhttps://access.redhat.com/security/cve/cve-2022-1184\nhttps://security-tracker.debian.org/tracker/CVE-2022-1184\nhttps://ubuntu.com/security/CVE-2022-1184\nKernel patches for CVE-2022-1184:\nhttps://github.com/torvalds/linux/commit/65f8ea4cd57dbd46ea13b41dc8bac03176b04233\nhttps://github.com/torvalds/linux/commit/61a1d87a324ad5e3ed27c6699dfc93218fcf3201\n\n------\n\n## Addendum 30 May 2023\n\nNew information has become available: many ext4 filesytem vulnerabilities similar to the one in CVE-2022-1184 continue to be found, and most of them do not ever have a CVE assigned.  The way to locate them is to search for \"syzbot\" in linux kernel commit messages under fs/ext4.  \"syzbot\" is a public automated system for finding kernel bugs.  Especially when syzbot reports are labeled \"KASAN\" (Kernel Address Sanitizer) and especially if they involve memory corruption including \"use after free\", \"out of bounds\", or \"user-memory-access\", they are vulnerabilities that can potentially be turned into privilege escalation when an unprivileged user has write access to the underlying data.\n\nIn particular there are two such commits from this month, May 2023, referenced below.  They both have commit messages describing a situation of write access to the underlying data while the kernel has that data mounted as a filesystem.  These commits have been backported to currently maintained kernel lines in versions 4.19.293 and 5.4.243, but since they are considered moderate severity, most common OS distributions do not include them immediately.  For example since RHEL9.2 was recently announced, they are not likely to be available in RHEL9 until 9.3 is released in about another 6 months.  Therefore if system administrators want to be protected against these vulnerabilities while still allowing ext4 filesystem mounts through setuid-root apptainer, they should watch for these types of commits and whenever such commits are released the administrators should update to the latest currently maintained kernel version (bypassing their OS vendor's distribution) and reboot.\n\nhttps://github.com/torvalds/linux/commit/2220eaf90992c11d888fe771055d4de3303\nhttps://github.com/torvalds/linux/commit/4f04351888a83e595571de672e0a4a8b74f\nhttps://lwn.net/Articles/932137/\nhttps://lwn.net/Articles/932136/",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/apptainer/apptainer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.8"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/apptainer/apptainer/security/advisories/GHSA-j4rf-7357-f4cg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-1184"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-30549"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/apptainer/apptainer/commit/5a4964f5ba9c8d89a0e353b97f51fd607670a9f7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/torvalds/linux/commit/2220eaf90992c11d888fe771055d4de3303"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/torvalds/linux/commit/4f04351888a83e595571de672e0a4a8b74f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/torvalds/linux/commit/61a1d87a324ad5e3ed27c6699dfc93218fcf3201"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/torvalds/linux/commit/65f8ea4cd57dbd46ea13b41dc8bac03176b04233"
  }, {
    "type" : "WEB",
    "url" : "https://www.suse.com/security/cve/CVE-2022-1184.html"
  }, {
    "type" : "WEB",
    "url" : "https://ubuntu.com/security/CVE-2022-1184"
  }, {
    "type" : "WEB",
    "url" : "https://sylabs.io/2023/04/response-to-cve-2023-30549"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202311-13"
  }, {
    "type" : "WEB",
    "url" : "https://security-tracker.debian.org/tracker/CVE-2022-1184"
  }, {
    "type" : "WEB",
    "url" : "https://lwn.net/Articles/932137"
  }, {
    "type" : "WEB",
    "url" : "https://lwn.net/Articles/932136"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/apptainer/apptainer/releases/tag/v1.1.8"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/apptainer/apptainer"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/security/cve/cve-2022-1184"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-04-25T19:48:35Z",
    "nvd_published_at" : "2023-04-25T21:15:10Z"
  }
}