A new vulnerability, identified as CVE-2023-21273, has been found in the SDP_AddAttribute function of sdp_db.cc, leading to a possible out of bounds write due to an incorrect bounds check. This flaw enables an attacker to execute remote (proximal/adjacent) code without requiring any additional privileges. Additionally, user interaction isn't necessary for exploitation. In this long-read post, we will delve into the details of this vulnerability, explore a code snippet displaying the issue, provide links to original references, and discuss its exploit and mitigation techniques.

Vulnerability Details

The problem at hand is rooted in the SDP_AddAttribute function of the sdp_db.cc file, which is responsible for adding attributes to the database. When implementing a bounds check, an error occurs, resulting in an out of bounds write vulnerability. An attacker exploiting this vulnerability can execute remote code with ease.

Original details of this vulnerability and its technical aspects can be found at

1. Official CVE Details
2. NIST National Vulnerability Database

Exploit Details

To exploit this vulnerability, an attacker needs to craft a malicious payload that triggers the incorrect bounds check. Subsequently, this allows the attacker to execute arbitrary code on the targeted system. To better understand the issue and exploit, consider the following code snippet:

void SDP_AddAttribute(sdp_db_t *db, const char *name, const char *value) {
    ASSERT(db != nullptr && name != nullptr && value != nullptr);
    size_t name_len = strlen(name);
    size_t value_len = strlen(value);

    // Check for an existing attribute with the same name
    sdp_attr_t *attr = FindExistingAttribute(db, name, name_len);
    if (attr != nullptr) {
        // Replace the value of the existing attribute
        attr->SetValue(value, value_len);

    // Incorrect bounds check, leading to out of bounds write vulnerability
    if (db->num_attrs + 1 >= kMaxAttributes) {
        LOG_ERROR("Exceeded maximum attribute count (%zu)", kMaxAttributes);

    // Add the new attribute
    db->attrs[db->num_attrs].SetName(name, name_len);
    db->attrs[db->num_attrs].SetValue(value, value_len);

In the code snippet above, the vulnerability stems from an incorrect bounds check in if (db->num_attrs + 1 >= kMaxAttributes). Due to this wrong implementation, if the value of kMaxAttributes is too high or the number of attributes stored (db->num_attrs) is too low, an out of bounds write can occur. This leaves room for remote code execution with no additional privileges needed.

Mitigation Strategies

Various mitigation techniques can be employed to patch this vulnerability. Some of them include the following:

1. Proper bounds check implementation: Rectify the incorrect bounds check in the SDP_AddAttribute function, ensuring that an out of bounds write does not occur.
2. Input validation: Implement strong input validation to prevent unauthorized access and properly handle user-supplied data.


CVE-2023-21273 sheds light on a critical vulnerability found in the SDP_AddAttribute function of sdp_db.cc. To defend against this exploitable flaw, it's crucial to invest time and effort into understanding the vulnerability, keeping software up to date, and implementing the appropriate mitigation strategies. Remember, an ounce of prevention is worth a pound of cure.


Published on: 08/14/2023 22:15:12 UTC
Last modified on: 08/18/2023 19:44:13 UTC