| الوصف | 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 a magicid value and writes that value into the shell command echo %s > /tmp/ActionMd5 before running it as root with the standard C library system function. 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 magicid.
- magicid read with websGetVar at 0x65b0; newSvn read at 0x6554, fwUrl at 0x6534, acIp at 0x6574, tSecond at 0x6590.
- 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 0x66a8, format echo %s > /tmp/ActionMd5.
- Sink system at 0x66b8, the standard C library system call.
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 magicid with websGetVar at 0x65b0. websGetVar returns the JSON string value without a character filter. The handler reads the other fields and compares newSvn with the running firmware SVN at 0x6608. A value different from the running SVN takes the update branch. get_cs_update_flag at 0x6638 must not return 1; it reads a flag file that is absent on a fresh boot, so the branch is taken.
3. The handler formats echo %s > /tmp/ActionMd5 with magicid at 0x66a8 and calls system at 0x66b8. The value is placed directly in a shell string with no quoting. A semicolon in magicid 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. The fwUrl field in the request is a normal value in this proof. After the echo the handler continues its upgrade work; the injected command has already run. 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":"<url>","newSvn":"1","acIp":"<device>","tSecond":"0","magicid":"x;touch /tmp/pwned;"}
The fwUrl value in this request is deliberately an ordinary URL. The handler runs the fwUrl command first, through a different call (CsteSystem at 0x668c), and the magicid command second, so the injected value arrives in the second command; the fwUrl parameter is reported separately. With this magicid value the handler builds echo x;touch /tmp/pwned; > /tmp/ActionMd5 and passes it to system. 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 magicid set to a normal value and the same fwUrl, newSvn, acIp and tSecond values 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 stubs affect configuration reads only, not the command path. 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 magicid. Validate it against a fixed format such as a bounded set of hexadecimal characters, reject shell metacharacters, and write the value with a direct file write.
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) |
|---|