VAITP Dataset

← Back to the dataset

CVE-2022-28657

Apport fails to disable Python crash handler prior to chroot execution.

  • CVSS 7.8
  • CWE-400
  • Configuration Issues
  • Local

Apport does not disable python crash handler before entering chroot

CVSS base score
7.8
Published
2024-06-04
OWASP
A06 Security Misconfiguration
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Configuration Issues
Subcategory
Security Misconfigurations
Accessibility scope
Local
Impact
Privilege Escalation
Affected component
Apport

Solution

Upgrade to Apport version 2.20.1-0ubuntu2.3 or later, which disables the Python crash handler before entering chroot.

Vulnerable code sample

import os

def enter_chroot(new_root):
    os.chroot(new_root)
    os.chdir('/')

if __name__ == "__main__":
    new_root = "/path/to/new/root"
    enter_chroot(new_root)

Patched code sample

import os
import sys
import signal

def disable_crash_handler():
    signal.signal(signal.SIGSEGV, signal.SIG_DFL)

def enter_chroot(new_root):
    disable_crash_handler()
    
    os.chroot(new_root)
    os.chdir('/')

if __name__ == "__main__":
    new_root = "/path/to/new/root"
    enter_chroot(new_root)

Payload

import os
import ctypes

# Example payload to trigger a segmentation fault
def trigger_segmentation_fault():
    ctypes.string_at(0)  # Attempt to access an invalid memory address

# Enter chroot before triggering the fault
def enter_chroot(new_root):
    os.chroot(new_root)
    os.chdir('/')

# Example usage
if __name__ == "__main__":
    new_root = "/path/to/new/root"
    enter_chroot(new_root)
    trigger_segmentation_fault()

Cite this entry

@misc{vaitp:cve202228657,
  title        = {{Apport fails to disable Python crash handler prior to chroot execution.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2022-28657},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-28657/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::