T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_stock.py:111- Finding
Plaintext HTTP Transport Allows Manipulation of Financial Market Data
- Content
View full analysis
dict: """抓取单只股票行情""" prefix, clean_code = get_market_prefix(code) symbol = f"{prefix}{clean_code}" url = f"http://hq.sinajs.cn/list={symbol}" raw = fetch_url(url) if raw: data = parse_sina_stock(raw, symbol) if data: return data # 备用:东方财富 market = 1 if prefix == "sh" else 0 url2 = ( f"http://push2.eastmoney.com/api/qt/stock/get" f"?secid={market}.{clean_code}" f"&fields=f43,f44,f45,f46,f47,f48,f57,f58,f60,f107,f169,f170,f171" ) ``` The index lookup also uses plaintext HTTP: ```python url = f"http://hq.sinajs.cn/list={symbols}" raw = fetch_url(url) ``` The sector-ranking lookup likewise uses plaintext HTTP: ```python url = ( "http://push2.eastmoney.com/api/qt/clist/get" "?pn=1&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281" "&fltt=2&invt=2&fid=f3" "&fs=m:90+t:2+f:!50" "&fields=f2,f3,f4,f12,f14,f20,f128,f136,f207,f208,f209" ) ``` ### Technical Analysis All implemented requests to Sina Finance and East Money use unencrypted HTTP. Consequently, `urllib.request.urlopen()` cannot authenticate the remote server or protect the integrity and confidentiality of the responses. An attacker positioned on the network path—such as an operator of a malicious Wi-Fi access point, a compromised router, an ISP-level interceptor, or another man-in-the-middle actor—can observe requested stock symbols and replace legitimate responses with forged but syntactically valid market data. The parsers trust externally returned stock names, prices, price changes, volume figures, index values ...[truncated 2126 chars]- Remediation
View remediation
