T09 · Insecure Skill Coding Practices
- Location
main.py:1131- Finding
Unfiltered User Input Is Disclosed to Third-Party APIs
- Content
View full analysis
Vulnerability Details
File Location:
main.py:93-100,main.py:378-394, andmain.py:1131-1150
Vulnerability Type: Excessive disclosure of user-supplied data to external services
Risk Level: MediumThe Skill requires outbound API access for its declared due-diligence functionality. However, it treats the complete
QUERY_INPUT, command-line argument string, or standard-input value as the company name. It then transmits that value to Wikidata and USPTO PatentsView without extracting or validating a minimal company identifier.Vulnerable Code
Input acquisition and propagation:
python input_text = os.environ.get("QUERY_INPUT", "") if not input_text: input_text = " ".join(sys.argv[1:]) if not input_text: print("OPC Chain Due Diligence Enhanced") print("=" * 40) print("Enter the target company name:") input_text = sys.stdin.readline().strip() if not input_text: print("Please provide a company name") return json.dumps({"error": "Company name is required"}, ensure_ascii=False) company_name = input_text.strip() scanner_a = EnterpriseInfoScanner(company_name)Wikidata transmission:
python params = { "action": "wbsearchentities", "search": self.company_name, "language": "zh", "format": "json", "limit": 5, } try: resp = requests.get(WIKIDATA_SEARCH_URL, params=params, timeout=15)USPTO PatentsView transmission:
python query = { "q": { "_and": [ {"assignee_organization": {"_like": self.company_name}} ] }, "f": [ "patent_number", "patent_title", "patent_abstract", "patent_date", "patent_issue_date", "patent_kind", "patent_type", "cpc_subsection_id", "cited_patent_count", "citedby_patent_count", "patent_year" ], "o": {"per_page": limit, "page": 1} } try: resp = r ...[truncated 2943 chars]- Remediation
View remediation
Remediation Suggestions
-
Use structured input. Accept a dedicated
company_nameor registration-code field rather than treating the complete natural-language request as an identifier. -
Extract the minimum necessary value. If natural-language input must be supported, parse the company identifier locally and present it to the user for confirmation before making network requests.
-
Validate the identifier. Enforce a reasonable length limit and allow only characters expected in company names or registration codes. Reject multiline values and requests containing unrelated contextual text.
-
Disclose external destinations. Inform the user that the extracted identifier will be sent to Wikidata and USPTO PatentsView. Obtain confirmation when input may contain confidential information.
-
Separate sensitive context from query data. Keep due-diligence purpose, internal notes, and allegations in local variables that are never inserted into API parameters or request bodies.
-
Minimize API fields. Request only patent fields used by the implemented analysis. Remove patent titles and abstracts unless a documented analysis step requires them.
-
Avoid logging raw input. Log a redacted or hashed identifier where operational logging is necessary, and ensure exception messages do not reproduce full request data.
-
Add automated tests. Verify that a request such as
Review Example Corp for confidential Project Falcontransmits onlyExample Corp, or is rejected as ambiguous, rather than forwarding the complete sentence.
-
