T09 · Insecure Skill Coding Practices
Error
- Location
- agento_skill(1).py:105
- Finding
- IRC Credentials Transmitted Over an Unencrypted Connection<![CDATA[ ## Vulnerability Details **File Location**: `agento_skill(1).py:42-43`, `agento_skill(1).py:105-107`; related documentation at `SKILL.md:7-9` and `DEPLOY.md:106-121` **Vulnerability Type**: Plaintext transmission of authentication credentials **Risk Level**: High ### Vulnerable Code ```python # ── Agento Network Config ── AGENTO_SERVER = 'irc.agento.ca' AGENTO_PORT = 6667 AGENTO_NETWORK = 'Agento' X_SERVICE = 'X@services.agento.ca' ``` ```python # Authenticate with X (ChanServ) log.info(f'Authenticating as {self.x_username}...') conn.privmsg(X_SERVICE, f'login {self.x_username} {self.x_password}') ``` The documented TLS example also fails to connect the created TLS factory to the bot: ```python ssl_factory = irc.connection.Factory(wrapper=ssl.wrap_socket) bot = AgentoSkill( nick="MyBot", username="MyBot", password="pass", ... ) # Override the server with SSL port bot.server_list = [("irc.agento.ca", 6697)] bot._connect() # uses SSL ``` ### Technical Analysis The implementation connects to IRC on plaintext TCP port 6667 by default. It then sends the account username and password as an IRC private message. IRC private messages are private only at the application level; without TLS, their contents remain visible in transit. Consequently, anyone able to monitor or alter the network path may read the authentication command. This includes an attacker on an untrusted Wi-Fi network, a compromised gateway, a malicious network intermediary, or an operator with access to unencrypted traffic. Although `DEPLOY.md` presents an SSL alternative, the example constructs `ssl_factory` without assigning it to the bot's connection configuration. Merely changing the port does not prove that TLS is being used. The example also uses the deprecated `ssl.wrap_socket` interface instead of an `SSLContext` configured for certificate and hostname verification. ### Attack Path 1. A user starts the Skill with the default server configuration. 2. The bot ...[truncated 984 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make TLS on port 6697 the mandatory default and remove plaintext credential authentication. 2. Supply a correctly configured TLS connection factory when initializing `SingleServerIRCBot`. 3. Use `ssl.create_default_context()` so certificate-chain and hostname verification are enabled. 4. Reject configurations that attempt to authenticate over a non-TLS transport. 5. Do not silently fall back from TLS to plaintext after a connection failure. 6. Replace the deployment example with a tested implementation, such as: ```python import ssl import irc.connection tls_context = ssl.create_default_context() tls_factory = irc.connection.Factory(wrapper=tls_context.wrap_socket) super().__init__( [(AGENTO_SERVER, 6697)], nick, nick, connect_factory=tls_factory, ) ``` 7. Confirm the exact constructor parameters supported by the pinned `irc` package version and add an integration test that verifies an active TLS session before credentials are sent. 8. Rotate any account credentials that may previously have been used over port 6667. ]]>
