| Título | D-Link DIR-505 1.10B02 Stack-based Buffer Overflow |
|---|
| Descripción | Summary:
D-Link DIR-505 A1 firmware 1.10B02 exposes SharePort Web File Access on TCP/8181
(/usr/bin/webfile_cgi.cgi, running as root). Its get_input_entries() form parser writes
POST body bytes into main()'s stack frame with a fixed 0x425 stride and no bounds check.
An unauthenticated POST to /dws/api/ListRoot overwrites main()'s $ra with the fixed
.system PLT address 0x40d180, so a crafted form body executes arbitrary commands as root.
No Cookie, session, HNAP credential, or admin password is required.
Technical details:
- Entry: POST /dws/api/ListRoot on TCP/8181 (any mapped /dws/api/* route reaches the same
parser).
- get_input_entries() reads CONTENT_LENGTH bytes from stdin and stores:
buf[offset + field * 0x425] for a name byte
buf[offset + field * 0x425 + 0x24] for a value byte
field is incremented by '&'; offset is reset by '&' and '='. Neither is bounds-checked.
- main() passes a stack buffer of 0xcf3a bytes at local_cf68 + 0x14. The write reaches
main()'s saved registers and $ra.
- Payload: 49 '&' separators place the next field at index 49; the following 1051-byte
value is:
0x00 + "A"*1026 + 5 * p32(0) + p32(0x40d180)
- 0x40d180 is the .system PLT stub in the non-PIE webfile_cgi.cgi 1.10B02.
- On main() return, the uClibc strcmp delay-slot effect leaves $a0 pointing to
field0_value + 1; field0 is "0<cmd>", so $a0 points to <cmd> and system(<cmd>) runs.
- ASLR is irrelevant: the return address and PLT are fixed, and the command pointer is
derived from the stack-relative buffer.
Authentication:
The parser runs before any Cookie/session check. The request needs no Cookie, no session,
no HNAP Basic credential, and no admin password. The HTTP response can be 200 or 500
because the CGI stack frame is corrupted; the command still executes.
Verified impact:
On a real DIR-505 A1 (192.168.0.1, firmware 1.10B02), the PoC returned:
Uid: 0 0 0 0
Gid: 0 0 0 0
CapEff: fffffffffffffeff
It also ran uname -a and ls successfully. Output is written under /www/webfile_access and
retrieved from TCP/8181; TCP/80 is not used.
Classification:
CWE-121 (Stack-based Buffer Overflow), CWE-78 (OS Command Injection).
CVSS 3.1: AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (9.8 Critical).
Prior art / duplicate note:
The same get_input_entries root cause was publicly analyzed in 2019 for my_cgi.cgi on
TCP/80 (storage_path, offset 477472, ROP 0x405B1C, firmware 1.08B10). This report is for a
different binary, port, route, offset, and firmware:
webfile_cgi.cgi / TCP 8181 / /dws/api/ListRoot / $ra=0x40d180 / firmware 1.10B02.
It is not CVE-2014-3936 (HNAP Content-Length overflow) and not CVE-2016-5681 (SharePort
cookie overflow).
Affected product:
- D-Link DIR-505 A1 firmware 1.10B02.
Remediation:
Restrict TCP/8181 to the LAN, disable SharePort Web File Access, add field/offset bounds
checks in get_input_entries, enforce a maximum CONTENT_LENGTH, and authenticate
/dws/api/*. DIR-505 is EOL; replace the device. |
|---|
| Usuario | Walnut1337 (UID 100856) |
|---|
| Sumisión | 2026-11-12 03:59 (hace 22 días) |
|---|
| Moderación | 2026-12-04 12:27 (22 days later) |
|---|
| Estado | Aceptado |
|---|
| Entrada de VulDB | 449687 [D-Link DIR-505 1.10B02 Web UI webfile_cgi.cgi get_input_entries desbordamiento de búfer] |
|---|
| Puntos | 20 |
|---|