T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/search.py:38
- Finding
- Sensitive Search Query Disclosed Through Standard Output Logging## Vulnerability Details **File Location**: `scripts/search.py`, line 38 **Vulnerability Type**: Plaintext disclosure of potentially sensitive user input **Risk Level**: Medium **Complete Code Snippet**: ```python query = sys.argv[1] parse_data = {} try: parse_data = json.loads(query) print(f"success parse request body: {parse_data}") except json.JSONDecodeError as e: print(f"JSON parse error: {e}") ``` ### Technical Analysis After parsing the command-line JSON request, the script writes the complete request object to standard output. This includes the `query` value and any additional supplied fields. Search queries can contain confidential names, internal URLs, proprietary terms, incident details, credentials pasted by mistake, or other sensitive information. Standard output is commonly captured by agent transcripts, CI/CD systems, process supervisors, centralized logging services, and automation platforms. Consequently, data intended only for the Baidu search request may be retained or exposed to additional parties. This logging is unnecessary for the declared search functionality and exceeds the minimum data handling needed to perform a search. The issue is limited to disclosure of data supplied in the request; the code does not print the `BAIDU_API_KEY`. ### Attack Path 1. An attacker persuades a user or agent to include confidential information in a search query. 2. The caller invokes `search.py` with that query in the JSON argument. 3. The script parses the request and prints the complete `parse_data` object. 4. The execution environment captures standard output in a transcript or log. 5. An attacker or unauthorized operator with access to those logs retrieves the sensitive query. Exploitation requires the victim to submit sensitive content and the attacker to have, or later gain, access to captured output. ### Impact Assessment The vulnerability can disclose the complete search request to parties with access to execution logs or ag ...[truncated 438 chars]
- Remediation
- ## Remediation Suggestions Remove the statement that prints the parsed request: ```python parse_data = json.loads(query) ``` If diagnostic logging is required: 1. Enable it only through an explicit debug option that is disabled by default. 2. Log a fixed message such as `Request parsed successfully` rather than the request contents. 3. Redact or omit the `query` field and any future fields that may contain secrets or personal data. 4. Ensure production environments do not retain sensitive debugging output. 5. Document that search queries are transmitted to the declared Baidu API so users can avoid submitting inappropriate confidential data. 6. Add tests verifying that neither normal nor error output contains the query or `BAIDU_API_KEY`.
