Lukas Dolejs Posted 17 hours ago Report Posted 17 hours ago Hi, the “Agent update” task of our Windows resident agents never succeeded (agent logs go back 17 months). Uploading scan results to the same FTPS server with the same account works fine. We investigated it with packet captures and the server logs and found two problems in the update Downloader. Environment TNI: 6.9.0 Windows resident agent: 23.07.18.6380, 25.11.17.7218 (captured) and 26.08.20.7562 are all affected Server: IIS 10 FTP, implicit FTPS on port 990, SSL required on the control and data channels, port 21 closed Profile: “Auto-update the agent or settings from a network resource” uses an FTP data transfer method with host ftp.example, port 990, TLS implicit, directory Agent Resulting agent ini: update-url=ftps://ftp.example:990/Agent “Send scan results” uses the same host, port and TLS mode and works ([SendDataSettings]: Encrypt=ftpeImplicit, Port=990) How we investigated We ran pktmon on the agent PC for the whole window of the scheduled “Agent update” task (filters: TCP 990, TCP 21, DNS, all TCP SYN). At the same time we logged the TCP connection table of tniwinagent.exe every 200 ms. We compared the result with manual tests using curl.exe from the same PC and with the IIS FTP log on the server. Findings from the packet capture and connection table The Downloader never connects to port 990. Its only connection is to port 21 of the correct server IP (DNS resolves correctly, to the same IP that the upload uses): 21:28:18.3 .. 21:28:39.2 <client>:53443 -> <server>:21 SynSent The connection stays in SYN_SENT and gets no answer, because port 21 is closed. 2. The task fails about 21 seconds after it starts. That is the Windows default TCP connect timeout, not the timeout configured in the data transfer method (10000 ms). In 17 months of logs, every attempt failed this way, for example scheduled at xx:28:18 and failed at xx:28:39: [ERROR] Task 'Agent update' has finished with error: Operation error: Downloader. FTP login FAIL. Error connecting to ftp.example via FTPS: Connection timed out The IIS FTP log has no entry for any of these attempts. The connection never reaches the FTP service. Manual check from the same PC: curl.exe --ssl-reqd ftps://ftp.example:990/Agent/ with the same account works completely (login, PBSZ/PROT P, EPSV, LIST, download). The server, account, directory and ACLs are fine. Findings after opening port 21 (explicit FTPS) The agent now fails with: ... Error connecting to ftp.example via FTPS: error:0A00010B:SSL routines::wrong version number On port 21 the server sends the plaintext 220 banner (explicit mode). The OpenSSL error shows that the agent started an implicit TLS handshake instead. So the Downloader keeps the implicit TLS mode from ftps:// but uses the default port 21 instead of the port from the URL. Findings from the IIS log after forwarding TCP 21 → 990 Login now works, but the Downloader explicitly requests an unprotected data channel: PBSZ 0 200 PROT C 534 TYPE I 200 CWD /Agent/ 250 PASV 227 RETR tniwinagent_{GUID}.ini 534 The upload code of the same agent sends PROT P: 285 upload sessions in one day, all PROT P 200. Only the Downloader uses PROT C. This means: the download fails on any server that requires TLS on the data channel, if the server allows a clear data channel, tniwinagent.exe, which the agent then runs as LocalSystem, is transferred unencrypted. Expected behaviour The Downloader connects to the port given in the URL or in the data transfer method (990 here). The Downloader uses PROT P, like the upload code. Workaround we use now (it weakens the server configuration, so we would like to remove it once fixed) Windows portproxy on the server: TCP 21 → 990 (netsh interface portproxy) IIS ftpServer/security/dataChannelSecurity/matchClientAddressForPasv = false (needed because of the proxy, otherwise IIS rejects the data channel due to the client IP mismatch) IIS ftpServer/security/ssl/dataChannelPolicy = SslAllow (needed because of PROT C) With this in place, the update works: the agent downloads the ini and the exe, restarts and runs the new version (26.10.26.7641 in our case). We can provide the capture files and full logs, anonymized, if needed. Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.