T09 · Insecure Skill Coding Practices
- Location
scripts/search.py:38- Finding
Sensitive Search Query Disclosed Through Standard Output Logging
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search.py, line 38
Vulnerability Type: Plaintext disclosure of potentially sensitive user input
Risk Level: MediumComplete 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
queryvalue 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
- An attacker persuades a user or agent to include confidential information in a search query.
- The caller invokes
search.pywith that query in the JSON argument. - The script parses the request and prints the complete
parse_dataobject. - The execution environment captures standard output in a transcript or log.
- 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
View remediation
Remediation Suggestions
Remove the statement that prints the parsed request:
python parse_data = json.loads(query)If diagnostic logging is required:
- Enable it only through an explicit debug option that is disabled by default.
- Log a fixed message such as
Request parsed successfullyrather than the request contents. - Redact or omit the
queryfield and any future fields that may contain secrets or personal data. - Ensure production environments do not retain sensitive debugging output.
- Document that search queries are transmitted to the declared Baidu API so users can avoid submitting inappropriate confidential data.
- Add tests verifying that neither normal nor error output contains the query or
BAIDU_API_KEY.
