T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/sys_doctor.py:428- Finding
Selected Diagnostic Scope Is Bypassed and Causes Undocumented Network Activity
- Content
View full analysis
Vulnerability Details
File Location:
scripts/sys_doctor.py, lines 223-231 and 428-445
Vulnerability Type: Excessive data collection beyond the selected diagnostic scope
Risk Level: MediumVulnerable Code
python # DNS resolution test try: start = time.time() result = subprocess.run( ["getent", "hosts", "google.com"], capture_output=True, text=True, timeout=5 ) elapsed = time.time() - start if result.returncode == 0: results["dns_resolution_ms"] = f"{elapsed*1000:.0f}" except Exception: passpython check_map = { "disk": {"disk": check_disk()}, "memory": {"memory": check_memory()}, "cpu": {"cpu": check_cpu()}, "network": {"network": check_network()}, "services": {"services": check_services()}, "all": check_all(), } data = check_map.get(args.check, check_map["all"]) if args.check == "all": data = check_all()Technical Analysis
Python evaluates all dictionary values when the dictionary is constructed. The
check_mapvalues therefore invoke every diagnostic function immediately, rather than invoking only the function corresponding toargs.check.For example, running the script with
--check diskstill executes:check_memory()check_cpu()check_network()check_services()check_all()
check_all()additionally collects system information and logged-in-user information. As a result, all diagnostic categories can be collected even when the user explicitly requests only one category. Only the selected category is subsequently placed in the visible output, making the additional activity non-obvious.Execution of
check_network()also invokesgetent hosts google.com. This can issue a DNS query through the host's configured resolver. That behavior conflicts with the documentation inSKILL.md, which describes each--checkoption as checking only the selected category and states that the utility makes no external API calls ...[truncated 2019 chars]- Remediation
View remediation
Remediation Suggestions
Replace eagerly evaluated dictionary values with function references and invoke only the requested checker:
python check_map = { "disk": check_disk, "memory": check_memory, "cpu": check_cpu, "network": check_network, "services": check_services, } if args.check == "all": data = check_all() else: checker = check_map[args.check] data = {args.check: checker()}Additional hardening should include:
- Remove the DNS-resolution test from default execution.
- If connectivity testing is required, place it behind an explicit option such as
--test-dns. - Allow the target hostname to be configured rather than hardcoding
google.com. - Clearly document that the DNS test generates network traffic.
- Ensure
check_all()is invoked only once. - Add automated tests that mock each checker and verify that
--check disk,--check memory, and other scoped modes invoke exactly one diagnostic function. - Update the offline-operation claim if any network-dependent check remains enabled.
