T09 · Insecure Skill Coding Practices
- Location
scripts/ftp_drive_tools.py:157- Finding
FTPS Certificate and Hostname Validation Disabled
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ftp_drive_tools.py, lines 157-163
Vulnerability Type: Improper TLS certificate validation
Risk Level: Highpython def _create_context(self) -> ssl.SSLContext: context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) if hasattr(ssl, 'TLSVersion'): context.minimum_version = ssl.TLSVersion.TLSv1_2 context.maximum_version = ssl.TLSVersion.TLSv1_2 context.check_hostname = False context.verify_mode = ssl.CERT_NONE return contextTechnical Analysis
The FTPS client explicitly disables both certificate-chain validation and hostname verification. Although the resulting connection is encrypted, it does not authenticate the remote FTP server. Any certificate, including a self-signed or attacker-controlled certificate, will be accepted.
This permits an active network attacker to impersonate the configured FTP server. The attacker can terminate the TLS session, establish a separate connection to the real server, and proxy or modify authentication and file-transfer traffic.
Attack Path
- A user configures and invokes the client with FTPS enabled.
- An attacker obtains a network position capable of intercepting or redirecting the connection, such as through a compromised gateway, DNS poisoning, or a hostile wireless network.
- The attacker presents an arbitrary TLS certificate for the FTP endpoint.
- The client accepts the certificate because
CERT_NONEand disabled hostname checking prevent authentication failures. - The client submits the FTP username and password through the attacker-controlled TLS endpoint.
- The attacker captures credentials and can inspect, replace, or modify uploaded and downloaded files.
Impact Assessment
A successful attack can expose reusable FTP credentials and all data transferred during affected sessions. The attacker may obtain the same remote file privileges granted to the compromised FTP account, including listing, readin ...[truncated 59 chars]
- Remediation
View remediation
Remediation Suggestions
- Construct the context with
ssl.create_default_context()so trusted certificate authorities and hostname validation are enabled by default. - Retain
ssl.CERT_REQUIREDandcheck_hostname = True. - Allow users of private certificate authorities to configure a CA bundle through
SSLContext.load_verify_locations(). - Do not provide an automatic fallback that disables certificate validation.
- If certificate pinning is supported, validate a configured certificate or public-key fingerprint and fail closed on mismatch.
- Report certificate failures clearly without exposing credentials or retrying over a weaker connection.
- Construct the context with
