| タイトル | TOTOLINK CA1200-PoE 5.9c.3994_B20190326 Command Injection in recvUpgradeNewFw fwUrl |
|---|
| 説明 | 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/recvUpgradeNewFw receives an upgrade request with an fwUrl value and writes that value into the shell command echo %s > /tmp/DlFileUrl before running it as root through the vendor CsteSystem wrapper. The value is not length limited, filtered or quoted, so a semicolon starts a second command. 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/ap.so, function recvUpgradeNewFw at 0x64d8, parameter fwUrl.
- fwUrl read with websGetVar at 0x6534; newSvn read at 0x6554, acIp at 0x6574, tSecond at 0x6590, magicid at 0x65b0.
- Branch check: the running firmware SVN is the constant 3994, formatted at 0x65f4; strcmp with newSvn at 0x6608; get_cs_update_flag at 0x6638; atoi of tSecond at 0x6650.
- Command built with sprintf at 0x6678, format echo %s > /tmp/DlFileUrl.
- Sink CsteSystem at 0x668c. 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. recvUpgradeNewFw is registered by module_init in ap.so.
2. The handler reads fwUrl with websGetVar at 0x6534. websGetVar returns the JSON string value without a character filter. It compares newSvn with the running SVN at 0x6608; a different value takes the update branch. get_cs_update_flag at 0x6638 must not return 1; the flag file is absent on a fresh boot, so the branch is taken.
3. The handler formats echo %s > /tmp/DlFileUrl with fwUrl at 0x6678 and passes the result to CsteSystem at 0x668c. The value is placed directly in a shell string with no quoting. A semicolon in fwUrl ends the echo 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. After the echo the handler continues its upgrade work, including forceupg; the injected command has already run. The magicid parameter of the same handler reaches a second command through a different call (system at 0x66b8) and is reported separately. No extra service is needed and the handler is present in the default firmware.
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 the cste_sub binary so the handler executed in the real module. 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: <body length>
Connection: close
{"topicurl":"setting/recvUpgradeNewFw","fwUrl":"x;touch /tmp/pwned;","newSvn":"1","acIp":"<device>","tSecond":"0","magicid":"abcd"}
With this value the handler builds echo x;touch /tmp/pwned; > /tmp/DlFileUrl and passes it to CsteSystem. In the test run the touch target was a marker file in the test folder, and it was created. The subscriber log shows the echoed x, which the control log does not show, and then, as in the control run, that forceupg, which the handler goes on to call, is not installed in the emulation container. The CGI did not return within the test timeout, in the control run and the test run alike; the marker is created before that. 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 the same way.
CONTROL
The same request with fwUrl set to an ordinary URL and the same newSvn, acIp, tSecond and magicid values created no marker. By code reading, a newSvn equal to the running SVN takes the no-update branch and never reaches the echo command; that branch was not shown at run time.
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 ap.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 fwUrl. Parse it as a URL with an expected scheme and character set, reject semicolons and other shell metacharacters, and pass it to the download tool with a fixed argument vector. Apply the same check to the other fields used by this handler.
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-003 |
|---|
| ユーザー | traianturcu (UID 103053) |
|---|
| 送信 | 2026年11月15日 19:38 (19 日 ago) |
|---|
| モデレーション | 2026年12月04日 15:34 (19 days later) |
|---|
| ステータス | 承諾済み |
|---|
| VulDBエントリ | 449768 [TOTOLINK CA1200-PoE 5.9c.3994_B20190326 lib/cste_modules/ap.so recvUpgradeNewFw fwUrl/magicid 特権昇格] |
|---|
| ポイント | 20 |
|---|