T08 · Insecure Dependencies
- Location
scripts/name_wuge.py:53- Finding
Unverified Download from a Mutable Upstream Source
- Content
View full analysis
Vulnerability Details
File Location:
scripts/name_wuge.py:53-61, 256-273
Vulnerability Type: Unpinned and integrity-unverified remote dependency
Risk Level: MediumVulnerable Code
python # Full Kangxi dictionary CSV download URLs (primary + fallback mirror) _CSV_URLS = [ # Primary: jsDelivr CDN (master branch) "https://cdn.jsdelivr.net/gh/breezyreeds/kangxi-strokecount@master/kangxi-strokecount.csv", # Fallback: GitHub Raw (master branch) "https://raw.githubusercontent.com/breezyreeds/kangxi-strokecount/master/kangxi-strokecount.csv", ] # CSV SHA-256 checksum (verification is skipped when empty) _CSV_SHA256 = ""python with urllib.request.urlopen(req, timeout=_DOWNLOAD_TIMEOUT) as resp: data = resp.read() tmp = dest.with_suffix(".tmp") tmp.write_bytes(data) if _CSV_SHA256: actual = hashlib.sha256(data).hexdigest() if actual != _CSV_SHA256: print(f" [kangxi] SHA256 mismatch, skipping this source") tmp.unlink(missing_ok=True) break tmp.rename(dest)Technical Analysis
The Kangxi stroke-count dataset is downloaded from URLs referencing the mutable
masterbranch. The_CSV_SHA256value is empty, so the conditional integrity check is never performed. As a result, the application trusts whichever dataset is currently returned by the upstream repository or CDN.HTTPS provides transport protection and server authentication, but it does not guarantee that upstream content remains identical to the version reviewed by the Skill author. A compromised upstream repository, CDN, maintainer account, or release process could modify the CSV after publication.
The downloaded file is parsed as CSV and converted to a persistent JSON cache. The reviewed parser only extracts character and integer fields; it does not execute the downloaded content. Therefore, this issue enables data and result manipulation rather than arbitrary code execution.
Attack Path
- An attacker compromi ...[truncated 1315 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace
masterin both download URLs with a specific immutable commit hash or a cryptographically verified release artifact. - Populate
_CSV_SHA256with the expected SHA-256 digest and make verification mandatory. An absent digest should cause a fail-closed response rather than silently disabling verification. - Verify the digest before moving the temporary download into its final cache location or parsing any records.
- Validate the CSV schema, expected row count, permitted character format, and reasonable stroke-count bounds before accepting the dataset.
- Store the verified source commit and digest alongside the JSON cache. Revalidate cached data before loading it, or authenticate it using a trusted manifest.
- Use a unique temporary filename created securely, then perform an atomic replacement only after all integrity and schema checks pass.
- Provide a safe offline fallback to the built-in dictionary when verification fails, and report the failure without consuming untrusted data.
- Replace
