| 제목 | TOTOLINK CA1200-PoE 5.9c.3994_B20190326 Command Injection in setUpgradeFW FileName |
|---|
| 설명 | SUMMARY
TOTOLINK CA1200-PoE is a ceiling access point. Its web interface sends form actions to /cgi-bin/cstecgi.cgi as JSON with a topicurl field. The handler setting/setUpgradeFW receives a firmware upgrade request with a FileName value. On every error path, including a request whose file is missing or invalid, the handler formats the shell command rm -f %s 1>/dev/null 2>&1 with FileName and runs it as root through the vendor CsteSystem wrapper. The value is not length limited, filtered or quoted, so a semicolon starts a second command. The handler returns its normal invalid-file response while the injected command runs. A client with a session can run commands as root on the access point.
CLASS: Command Injection (CWE-78)
AFFECTED: TOTOLINK CA1200-PoE, firmware 5.9c.3994_B20190326, the latest public image. Image file TOTOLINK_C8B180A-1G_CA1200-POE_AP0167_8197F_SPI_8M128M_V5.9c.3994_B20190326_ALL.web, sha256 32e7da327263979568ccbe98c23acd530a5387667e18e6bc888613b249cd1c4e.
AFFECTED FILES AND PARAMETERS:
- lib/cste_modules/upgrade.so, function setUpgradeFW at 0x3d00, parameter FileName.
- Flags read with websGetVar at 0x3d88; FileName read at 0x3da8; ContentLength read at 0x3dc8.
- Error exits at 0x3e38, 0x3e9c, 0x3f9c and 0x46e4 converge on the cleanup block at 0x4624.
- Command built with sprintf at 0x4688, format rm -f %s 1>/dev/null 2>&1 at file offset 0x5000.
- Sink CsteSystem at 0x469c. CsteSystem is lib/libcstelib.so 0x78dc and executes /bin/sh with a -c argument.
CVSS: CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (8.8). The web interface listens on the LAN side; a session is obtainable with no password (reported separately); by code reading the session check runs after the CGI; the result is root command execution on the access point.
DETAILS
1. The web pages post JSON to /cgi-bin/cstecgi.cgi with a topicurl field. cstecgi.cgi passes it to lib/libmosquitto.so, which publishes it to the local broker. /bin/cste_sub loads /lib/cste_modules/*.so, calls each module_init, and dispatches to the handler whose name matches the last topic segment. setUpgradeFW is registered by module_init in upgrade.so.
2. The handler reads FileName with websGetVar at 0x3da8 and keeps the string in a register. websGetVar returns the JSON string value without a character filter. The handler then attempts the upgrade. Every failure path converges on the cleanup block at 0x4624.
3. The cleanup block formats rm -f %s 1>/dev/null 2>&1 with FileName at 0x4688 and passes the result to CsteSystem at 0x469c. The value is placed directly in a shell string with no quoting. A semicolon in FileName ends the rm command and starts the attacker's command under the same root shell. On the device the web chain runs as root; both accounts the image defines, root and nobody, have user ID 0.
4. The cleanup runs before the error response, so a request with an invalid or absent image still reaches the injection. The response was HTTP 200 with upgradeERR: MM_FwFileInvalid, the normal response for a rejected image. No valid image or upload is needed.
LOGIN REQUIREMENT
A session can be obtained with no password through formLoginAuth, reported separately. With the vendor lighttpd binary under a minimal test configuration (not the vendor configuration file), a POST to /cgi-bin/cstecgi.cgi with no cookie was handed to the CGI module with no redirect, and the CGI start then failed under emulation (status 500). The same request with a session cookie gave the same result, and a protected page with no cookie was redirected. The start attempt is observed; by code reading the session check runs after the CGI: lighttpd userloginAuth is called from http_response_write_header at 0x408a88, after the CGI has run. The vendor configuration file loads mod_auth, but every auth directive in it is commented out. The end-to-end side effect through the web server was not shown, so this proof covers the CGI and handler half with the same request a client sends. I do not claim the pre-authentication path as proven end to end.
PROOF
I extracted the public image, ran cstecgi.cgi under QEMU user-mode with the CGI environment and the JSON body on standard input, and ran the local broker and cste_sub so the real module handled the request. The equivalent HTTP request is:
POST /cgi-bin/cstecgi.cgi HTTP/1.1
Host: <device>
Cookie: SESSION_ID=<session>
Content-Type: application/json
Content-Length: 103
Connection: close
{"topicurl":"setting/setUpgradeFW","FileName":"x;touch /tmp/pwned;#","Flags":"0","ContentLength":"100"}
With this value the handler builds rm -f x;touch /tmp/pwned;# 1>/dev/null 2>&1 and passes it to CsteSystem. In the test run the touch target was a marker file in the test folder; it was created, and the CGI returned 200 with upgradeERR: MM_FwFileInvalid. The command string reached the shell unchanged. The shell observed in emulation was the container's shell; the firmware's /bin/sh is busybox and treats the semicolon and comment character the same way.
CONTROL
The same request with FileName set to firmware.bin and the same Flags and ContentLength values returned the same upgradeERR response and created no marker.
TEST ENVIRONMENT
Tested with the vendor's own binaries taken from the public firmware image TOTOLINK_C8B180A-1G_CA1200-POE_AP0167_8197F_SPI_8M128M_V5.9c.3994_B20190326_ALL.web (sha256 32e7da327263979568ccbe98c23acd530a5387667e18e6bc888613b249cd1c4e), run under QEMU user-mode emulation. The configuration library libapmib.so was stubbed because the emulation container has no flash device. The web server and the CGI could not be run together in emulation, so this proof covers the CGI and handler half: cstecgi.cgi, the local broker and subscriber, and the real upgrade.so handler. The lighttpd-to-CGI spawn was not shown. The device was not tested.
IMPACT
A root command runs on the access point. The attacker can read stored administrator and Wi-Fi credentials, change the wireless configuration and the admin password, use the device as a LAN foothold, and persist through the configuration store. The access point is the network edge, so control of it exposes the traffic and the internal network.
FIX
Do not build a shell command from FileName. Use a fixed path for the temporary firmware file, or accept only a file name without path separators or shell metacharacters, and remove the file with a direct unlink call. The cleanup should use the same server-chosen path that the upload handler wrote.
VENDOR CONTACT
The vendor was notified by email on 2026-11-15, before this submission. No CVE has been assigned or requested elsewhere.
FINDER: Traian Turcu (App Attic) |
|---|
| 원천 | ⚠️ https://www.appattic.com/cyber/advisories/aa-2026-005 |
|---|
| 사용자 | traianturcu (UID 103053) |
|---|
| 제출 | 2026. 11. 15. PM 07:42 (19 날 ago) |
|---|
| 모더레이션 | 2026. 12. 04. PM 03:35 (19 days later) |
|---|
| 상태 | 수락 |
|---|
| VulDB 항목 | 449769 [TOTOLINK CA1200-PoE 5.9c.3994_B20190326 Web Management Interface upgrade.so setUpgradeFW FileName 권한 상승] |
|---|
| 포인트들 | 20 |
|---|