T09 · Insecure Skill Coding Practices
- Location
lib/attio_enhanced.py:105- Finding
Verbatim API Error Responses May Expose Sensitive CRM Data in Logs
- Content
View full analysis
Vulnerability Details
File Location:
lib/attio_enhanced.py:105-117andlib/attio_enhanced.py:172-185
Vulnerability Type: Sensitive information exposure through logging
Risk Level: MediumVulnerable code — synchronous request path:
python if response.status_code >= 400: error_text = response.text self.logger.error(f"Error response: {error_text}") # Create enhanced HTTPError with error body error = requests.exceptions.HTTPError( f"{response.status_code} {response.reason} | {error_text}", response=response ) error.error_body = error_text raise errorVulnerable code — asynchronous request path:
python if response.status >= 400: self.logger.error(f"Error response: {response_text}") # Create custom error with full details in the message error = aiohttp.ClientResponseError( request_info=response.request_info, history=response.history, status=response.status, message=f"{response.reason} | {response_text}" ) # Store error text as attribute for easier checking error.error_body = response_text raise errorTechnical Analysis
Both request implementations write the complete Attio API response body to the application logger whenever an HTTP error occurs. The same unredacted body is also inserted into exception messages and retained in the custom
error_bodyattribute.Error responses from a CRM API may include rejected field values, email addresses, names, company information, record identifiers, validation context, or other business data. Logging these responses verbatim can copy sensitive information into console logs, CI output, centralized monitoring platforms, or long-retention log archives.
This behavior also conflicts with the assertion in
README.mdthat sensitive data is not logged. Although the authorization header itself is not ...[truncated 1443 chars]- Remediation
View remediation
Remediation Suggestions
- Do not log complete response bodies by default. Log only the HTTP status, request correlation ID, and a sanitized API error code.
- Remove
error_textfrom exception messages. Expose detailed response content only through an explicitly enabled diagnostic mode. - Implement a centralized redaction function that removes authorization values, email addresses, CRM field values, tokens, and sensitive identifiers before any response is logged.
- If
error_bodymust remain available programmatically, document it as sensitive and ensure upstream handlers do not serialize or log it automatically. - Limit diagnostic response size to prevent excessive or attacker-controlled log content.
- Configure production logs with least-privilege access, encryption, retention limits, and audit controls.
- Add tests confirming that representative personal data and token-like values never appear in log output or exception strings.
- Correct the security documentation so that its logging claims accurately reflect the implementation.
