T09 · Insecure Skill Coding Practices
Error
- Location
- govb_fetcher/fetcher.py:32
- Finding
- Authentication Credentials Transmitted over Plaintext HTTP## Vulnerability Details **File Location**: `govb_fetcher/fetcher.py:32-64`, `govb_fetcher/fetcher.py:100-104` **Vulnerability Type**: Cleartext transmission of sensitive authentication data **Risk Level**: High ### Vulnerable Code ```python BASE_URL = 'http://zbcg-bjzc.zhongcy.com/gt-jy-toubiao/api' DETAIL_BASE = 'http://zbcg-bjzc.zhongcy.com/bjczj-jy-toubiao/index.html' HNZC_LIST_URL = 'http://www.ccgp-hunan.gov.cn/mvc/getNoticeList4Web.do' HNZC_DETAIL_URL = 'http://www.ccgp-hunan.gov.cn/mvc/viewNoticeContent.do' HNZC_PAGE_URL = 'http://www.ccgp-hunan.gov.cn/page/notice/notice.jsp' def _build_session() -> requests.Session: session = requests.Session() proxies = get_proxies() if proxies: session.proxies.update(proxies) session.cookies.update({ 'YGCG_TBSESSION': get_bjzc_tbsession(), 'JSESSIONID': get_bjzc_jsessionid(), 'jcloud_alb_route': get_bjzc_alb_route(), }) session.headers.update({ 'Accept': 'application/json, text/plain, */*', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Authorization': f'Bearer {get_bjzc_bearer_token()}', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded', 'Origin': 'http://zbcg-bjzc.zhongcy.com', 'Pragma': 'no-cache', 'Referer': 'http://zbcg-bjzc.zhongcy.com/bjczj-jy-toubiao/index.html', 'User-Agent': ( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/146.0.0.0 Safari/537.36' ), 'contentType': 'formType', }) return session ``` ```python def _fetch_bjzc_page(session: requests.Session, page: int, rows: int = 100) -> dict: url = f'{BASE_URL}/cggg/gonggao/queryZBGongGaoList.do' data = { 'ggName' ...[truncated 2173 chars]
- Remediation
- ## Remediation Suggestions 1. Replace all authenticated Beijing API and page endpoints with verified `https://` endpoints. 2. Confirm that the upstream service presents a valid certificate for the expected hostname and retain certificate verification. 3. Explicitly reject redirects from HTTPS to HTTP before credentials can be forwarded. 4. Avoid placing the authorization header on a broadly reusable session if it could contact another origin. Add credentials only to requests whose scheme and hostname exactly match an allowlist. 5. If the upstream service genuinely offers no HTTPS support, do not send reusable credentials directly over the public network. Require an authenticated, trusted tunnel or a secure gateway under the user's control and display a clear security warning. 6. Rotate the Bearer token and session cookies after deploying the fix, because previously transmitted credentials may have been observed.
