T09 · Insecure Skill Coding Practices
- Location
get_true_top_500.py:64- Finding
NASDAQ Symbol Data Retrieved over Unauthenticated FTP
- Content
View full analysis
Vulnerability Details
File Location:
get_true_top_500.py, line 64
Vulnerability Type: Unauthenticated and unencrypted network transport
Risk Level: MediumVulnerable Code
python def download_nasdaq_symbols(): """Download all US-traded symbols from the NASDAQ FTP directory.""" print("1. Downloading all US traded symbols from NASDAQ FTP...") url = "ftp://ftp.nasdaqtrader.com/symboldirectory/nasdaqtraded.txt" try: response = urllib.request.urlopen(url) data = response.read().decode("utf-8") df_sym = pd.read_csv(io.StringIO(data), sep="|") except Exception as e: print(f"Failed to download or parse NASDAQ directory: {e}") exit(1)Technical Analysis
The application retrieves the symbol universe through plaintext FTP. FTP does not provide transport encryption or authenticated server identity. An attacker capable of intercepting or modifying traffic—such as a malicious network operator, compromised gateway, or hostile local-network participant—could replace the symbol-directory response.
The downloaded content is parsed directly as a pipe-delimited data frame without cryptographic integrity verification. Basic filtering does not establish that the records originated from NASDAQ. Because these symbols define the input universe for subsequent Yahoo Finance queries, modified data can silently influence the generated rankings and CSV output.
This path does not directly evaluate the response as executable code, so no arbitrary code execution or privilege escalation was identified.
Attack Path
- A user runs
get_true_top_500.pyon a network observed or controlled by an attacker. - The script requests
nasdaqtraded.txtthrough plaintext FTP. - The attacker intercepts the FTP response and substitutes a syntactically valid, maliciously modified symbol directory.
- The script parses the substituted records and applies on ...[truncated 786 chars]
- A user runs
- Remediation
View remediation
Remediation Suggestions
- Replace the FTP endpoint with an official HTTPS endpoint that provides authenticated TLS.
- Require certificate validation and fail closed on TLS or hostname verification errors.
- If NASDAQ publishes checksums or signed artifacts, verify them before parsing the response.
- Validate the downloaded schema, required columns, expected footer, record count bounds, symbol syntax, and allowed field values.
- Apply response-size and network-timeout limits to reduce resource-exhaustion risks.
- Record the source URL, retrieval timestamp, and integrity digest with generated results for reproducibility.
- For high-integrity financial research, cross-check the symbol universe against an independent authenticated source.
