T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_market_data.py:64- Finding
Plaintext HTTP Enables Sector Market Data Manipulation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/fetch_market_data.py, lines 64–68
Vulnerability Type: Plaintext HTTP transport for externally sourced market data
Risk Level: MediumVulnerable Code
python def fetch_sector_rankings(): """获取行业板块排名(同花顺)""" url = "http://q.10jqka.com.cn/thshy/" data = fetch_url(url)Technical Analysis
The sector-ranking endpoint is accessed over unencrypted HTTP. HTTP provides neither transport confidentiality nor server authenticity, allowing an attacker with a network position—such as a malicious Wi-Fi operator, compromised proxy, ISP-level attacker, or local network adversary—to intercept and modify the response.
The application subsequently parses names and percentage values from the untrusted HTML without authenticating the response. Parsed sector names are returned through JSON or printed directly to a terminal. Consequently, a modified response can introduce false financial data or control characters into terminal output. The generic downloader also reads the complete response without a maximum size, while the parser applies broad regular expressions to the supplied HTML, increasing exposure to resource-consumption attacks.
Attack Path
- A user invokes
fetch_market_data.py. - The script requests
http://q.10jqka.com.cn/thshy/over plaintext HTTP. - A network-positioned attacker intercepts the request or response.
- The attacker substitutes crafted HTML containing manipulated sector names and valid numeric percentage fields.
- The regular-expression parser accepts the forged table data.
- The script returns the falsified rankings in JSON or prints attacker-controlled sector names to the terminal.
- If terminal control sequences or an oversized response are supplied, the attacker may additionally manipulate terminal presentation or cause excessive memory and CPU consumption.
Impact Assessment
Exploitation does not di ...[truncated 552 chars]
- A user invokes
- Remediation
View remediation
Remediation Suggestions
- Replace the plaintext endpoint with the provider's verified HTTPS endpoint.
- Reject redirects that downgrade an HTTPS request to HTTP.
- Retain standard TLS certificate and hostname verification; do not introduce an unverified SSL context.
- Enforce a maximum response size before loading the complete body into memory.
- Validate the response content type and expected document structure before parsing.
- Replace broad regular-expression HTML parsing with a bounded, maintained HTML parser.
- Restrict sector names to an expected length and character policy.
- Remove ASCII control characters and terminal escape sequences before printing externally sourced strings.
- Where stronger integrity guarantees are required, obtain data from an authenticated API or validate responses using a provider-supported signature or trusted secondary source.
