T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:121
- Finding
- Authorization Check Permits Out-of-Scope Targets## Vulnerability Details **File Location**: `SKILL.md`, lines 121-128 **Vulnerability Type**: Authorization boundary bypass caused by unsafe suffix matching **Risk Level**: High **Vulnerable Code:** ```python # ALWAYS check before scanning def is_authorized(target): with open("authorized_targets.txt") as f: authorized = [line.strip() for line in f] return any(target.endswith(auth) or target == auth for auth in authorized) # FAIL SAFE if not is_authorized(target): raise ValueError(f"UNAUTHORIZED: {target} not in authorized_targets.txt") ``` ### Technical Analysis The authorization function uses unrestricted string suffix matching. If `example.com` is authorized, an unrelated hostname such as `attacker-example.com` also satisfies `target.endswith("example.com")`. The documented wildcard syntax is also not implemented correctly. An entry such as `*.example.com` is treated as a literal suffix rather than as a controlled wildcard expression. The function additionally does not show hostname parsing, canonicalization, internationalized-domain-name handling, trailing-dot normalization, or rejection of URLs containing user information, ports, and paths. The check therefore fails to establish a proper DNS label boundary between the requested target and an authorized base domain. ### Attack Path 1. Add `example.com` to `authorized_targets.txt`. 2. Request a scan of an unrelated hostname such as `attacker-example.com`. 3. The expression `target.endswith("example.com")` evaluates to true. 4. The fail-safe exception is not raised. 5. The scanner proceeds against a target outside the intended authorization scope. ### Impact Assessment An operator or attacker able to supply the scan target can cause subdomain enumeration, endpoint probing, JavaScript analysis, and vulnerability scanning against unauthorized infrastructure. This does not directly grant local operating-system privileges, but it bypa ...[truncated 131 chars]
- Remediation
- ## Remediation Suggestions - Parse input as a hostname instead of comparing arbitrary strings or complete URLs. - Convert hostnames to lowercase, remove a single trailing dot, and normalize internationalized domain names consistently. - Reject credentials, paths, query strings, fragments, malformed labels, and unexpected ports before authorization. - For a base domain, require either exact equality or a dot-delimited subdomain boundary: ```python target == authorized_domain or target.endswith("." + authorized_domain) ``` - Parse wildcard entries explicitly. Permit only a documented form such as `*.example.com`, and translate it into a label-aware comparison. - Ignore blank lines and comments in the authorization file. - Log the normalized target, matched scope entry, authorization decision, and current authorization expiry. - Add negative tests for `attacker-example.com`, `example.com.attacker.net`, trailing-dot variants, mixed case, and malformed URLs.
