T09 · Insecure Skill Coding Practices
- Location
src/cli.py:168- Finding
Hard-Coded API Credential and Authorization Header Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
src/datajud_client.py:15-27,src/cli.py:168-174,README.md:133-136, andSKILL.md:108-110
Vulnerability Type: Hard-coded credential and sensitive header exposure
Risk Level: MediumEvidence
src/datajud_client.py:15-27:python BASE_URL = "https://api-publica.datajud.cnj.jus.br" DEFAULT_API_KEY = "cDZHYzlZa0JadVREZDJCendQbXY6SkJlTzNjLV9TRENyQk1RdnFKZGRQdw==" class DataJudClient: def __init__(self, api_key: Optional[str] = None): self.api_key = api_key or os.environ.get("DATAJUD_API_KEY", DEFAULT_API_KEY) self.last_request_time = 0 self.min_interval = 0.5 # 2 req/s max def _headers(self) -> dict: return { "Authorization": f"APIKey {self.api_key}", "Content-Type": "application/json" }src/cli.py:168-174:python url = f"https://api-publica.datajud.cnj.jus.br/api_publica_{tribunal}/_search" query = {"query": {"match": {"numeroProcesso": numero}}, "size": 10} print("=== DRY RUN ===") print(f"URL: {url}") print(f"Headers: {client._headers()}") print(f"Payload: {query}") sys.exit(0)README.md:133-136:markdown The public API key is embedded by default. Optionally, set via environment variable: ```bash export DATAJUD_API_KEY="cDZHYzlZa0JadVREZDJCendQbXY6SkJlTzNjLV9TRENyQk1RvnFKZGRQdw=="text `SKILL.md:108-110`: ```markdown A API Key pública do DataJud já está configurada por padrão. Opcionalmente, pode-se definir via variável de ambiente:DATAJUD_API_KEY=cDZHYzlZa0JadVREZDJCendQbXY6SkJlTzNjLV9TRENyQk1RvnFKZGRQdw==
text Technical Analysis
The DataJud API credential is embedded directly in the source code and duplicated in project documentation. Any user with access to the repository can extract and reuse it. Although the documentation describes this as a public API key, embedding credentials ...[truncated 2020 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove
DEFAULT_API_KEYfrom the source and requireDATAJUD_API_KEYto be supplied through the runtime environment or an approved secret manager. -
Fail safely with a clear configuration error when no credential is available.
-
Never print the complete authorization header. Redact it in dry-run output, for example:
python safe_headers = client._headers().copy() if "Authorization" in safe_headers: safe_headers["Authorization"] = "APIKey ****" print(f"Headers: {safe_headers}") -
Replace credentials in
README.mdandSKILL.mdwith placeholders such as:bash export DATAJUD_API_KEY="YOUR_DATAJUD_API_KEY" -
Rotate the exposed credential if it is not deliberately public, and review service logs for unexpected use.
-
Keep one authoritative configuration method to prevent mismatches between source code and documentation.
-
Add automated secret scanning and a test asserting that dry-run output never contains the configured credential.
-
