T09 · Insecure Skill Coding Practices
- Location
scripts/core/api/meida/chunks.py:96- Finding
Authentication Credentials Are Written to Persistent Log Files
- Content
View full analysis
Vulnerability Details
File Location:
scripts/core/api/meida/chunks.py:96-107, with persistent logging configured inscripts/core/__init__.py:53-63
Vulnerability Type: Sensitive credential exposure through logging
Risk Level: HighVulnerable Code
python def request(self, action: str, service: str, body: dict = None, extra_query: dict = None) -> dict: extra_query = extra_query or {} body_bytes = json.dumps(body or {}, ensure_ascii=False).encode() payload_hash = HashUtils.hash_sha256(body_bytes).hex() url = self.build_url(self.host, action, extra_query) query_string = urlparse(url).query headers = self.build_headers( service, self.host, query_string, payload_hash, is_binary=False ) logging.info( f"[http] <<< {headers} " f"{json.dumps(body or {}, ensure_ascii=False)}" ) resp = requests.post(url, data=body_bytes, headers=headers, timeout=30) logging.info(f"[http] <<< {resp.headers} {resp.text}")The logged headers contain one of the following authorization values:
python headers["Authorization"] = f"Bearer {self.token}"or:
python authorization = ( f"HMAC-SHA256 Credential={self.ak}/{credential_scope}," f" SignedHeaders={';'.join(signed_headers)}," f" Signature={signature}" ) headers["Authorization"] = authorizationLogging is persistently directed to a predictable file:
python log_dir = "/tmp/openclaw/byted-kickart-viral-replicator/logs" os.makedirs(log_dir, exist_ok=True) logging.basicConfig( level=logging.INFO, filename=f'{log_dir}/info.{time.strftime("%Y%m%d", time.localtime())}.log', format="%(asctime)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S", )Technical Analysis
Every non-binary API request logs the complete HTTP header dictionary before transmission. In bearer-token mode, this exposes the complete
ARK_SKILL_API_KEY. In AK/SK mode, it exposes the Access Key ID, credential scope ...[truncated 1855 chars]- Remediation
View remediation
Remediation Suggestions
- Remove authorization headers from all logs.
- Introduce a centralized redaction function that masks at least:
AuthorizationARK_SKILL_API_KEYACCESS_KEY_IDSECRET_ACCESS_KEY- Signed URLs and session identifiers
- Do not log complete request or response bodies at
INFOlevel. Log only action names, status codes, request IDs, durations, and redacted error summaries. - If diagnostic payload logging is indispensable, require an explicit debug opt-in and recursively redact sensitive fields.
- Create the log directory and files with restrictive permissions, such as directory mode
0700and file mode0600. - Add rotation, short retention, and secure deletion.
- Revoke and rotate any credentials used while vulnerable logging was enabled.
- Add automated tests asserting that tokens and authorization headers never appear in captured logs.
