T09 · Insecure Skill Coding Practices
- Location
scripts/import_presets_aws.py:227- Finding
Sensitive configuration values are exposed through stdout diff output
- Content
View full analysis
list[dict[str, Any]]: """Compare each key present in package config against the matching local path.""" out: list[dict[str, Any]] = [] for k, nv in new.items(): path = f"{prefix}.{k}" if prefix else k if k not in old: continue ov = old[k] if isinstance(nv, dict) and isinstance(ov, dict): out.extend(_config_diff(ov, nv, path)) elif nv != ov: out.append({"key": path, "old": ov, "new": nv}) return out def _print_config_diff_json(diffs: list[dict[str, Any]]) -> None: print(json.dumps(diffs, ensure_ascii=False, indent=2)) ``` The vulnerable functions are invoked without excluding secret fields: ```python else: old_map = _load_yaml_mapping(config_dest, "Local config.yaml") diffs = _config_diff(old_map, new_map) _print_config_diff_json(diffs) _info( f"config differences: {len(diffs)} entries were written to stdout" ) _write_aws_env_incremental(repo, new_map, args.dry_run) ``` ### Technical Analysis The imported `config.yaml` is explicitly permitted to contain sensitive values, including: - `wechat_appsecret` - `writing_model.api_key` - `image_model.api_key` - `wechat_appid` When a local configuration already exists, `_config_diff` recursively compares the local and package configurations. For every changed leaf, it places both the original value and the package-supplied value into a JSON object. `_print_config_diff_json` then prints the complete object to stdout without redaction. Consequently, differences involving credentials expose both the existing local secret and the newly imported secret. Although the separate `aws.env` update path intentionall ...[truncated 1489 chars]- Remediation
View remediation
Any: if path in SENSITIVE_CONFIG_PATHS: return "[REDACTED]" return value # When recording a difference: out.append({ "key": path, "old": _redacted_diff_value(path, ov), "new": _redacted_diff_value(path, nv), }) ``` A safer design is to omit `old` and `new` entirely for sensitive paths: ```python if path in SENSITIVE_CONFIG_PATHS: out.append({"key": path, "changed": True, "sensitive": True}) else: out.append({"key": path, "old": ov, "new": nv}) ``` ]]>
