T09 · Insecure Skill Coding Practices
- Location
scripts/credibility.py:15- Finding
Trusted domains are validated using unsafe substring matching
- Content
View full analysis
- Remediation
View remediation
bool: host = host.rstrip(".").lower() trusted_domain = trusted_domain.rstrip(".").lower() return host == trusted_domain or host.endswith("." + trusted_domain) def score(url: str) -> dict: parsed = urlparse(url) if parsed.scheme not in {"http", "https"} or not parsed.hostname: raise ValueError("A valid HTTP or HTTPS URL is required") domain = parsed.hostname.encode("idna").decode("ascii").rstrip(".").lower() high_domains = { "wikipedia.org", "arxiv.org", "nature.com", "sciencedirect.com", } if any(is_domain_or_subdomain(domain, trusted) for trusted in high_domains): tier = "high" ``` This accepts legitimate hosts such as `en.wikipedia.org` while rejecting deceptive hosts such as `wikipedia.org.attacker.example` and `fake-wikipedia.org`. ]]>
