T09 · Insecure Skill Coding Practices
Error
- Location
- security_report.py:15
- Finding
- Hard-Coded XDR API Credential<![CDATA[ ## Vulnerability Details **File Location**: `security_report.py:15-20` **Vulnerability Type**: Hard-coded authentication secret **Risk Level**: High ```python API_URL = "https://10.50.86.28/xdr/openapi/v1.0/risk/listDetail" API_KEY = "7445a03b544484ff3ab552fd81d1f2b7" HEADERS = { "apikey": API_KEY, "accept": "*/*" } ``` ### Technical Analysis A reusable XDR API key is embedded directly in the source code and included in every request through the `apikey` HTTP header. Any person or process able to read the skill package can recover the credential without invoking the skill. Source-code permissions and package distribution controls are not suitable secret-management mechanisms. The credential may also remain recoverable from repository history, archived packages, logs, backups, and previously distributed copies after it is removed from the current source. ### Attack Path 1. An attacker obtains read access to the skill package, an archive, a repository clone, or a backup containing `security_report.py`. 2. The attacker reads the `API_URL` and `API_KEY` constants. 3. From a network location that can reach the private XDR endpoint, the attacker sends requests with the extracted key in the `apikey` header. 4. The attacker accesses any operations and data authorized to that key until the credential is revoked or rotated. ### Impact Assessment The exposed credential may permit unauthorized access to the internal XDR API and its security-event information. The exact privileges depend on the server-side permissions assigned to the key, which are not defined in the reviewed files. At minimum, the source demonstrates intended access to detailed XDR risk data. Exposure could therefore disclose internal IP addresses, affected assets, event classifications, threat severity, and operational security information. If the key has permissions beyond the demonstrated read operation, the impact could extend to other API capabilities available to that cred ...[truncated 13 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed API key immediately; removing it from the current file is insufficient. 2. Review XDR access logs for suspicious use of the exposed credential. 3. Remove the secret from all repository history, package archives, build artifacts, logs, and backups where feasible. 4. Obtain the credential at runtime from a protected secret manager or a narrowly scoped environment variable. 5. Fail closed with a clear error when the credential is unavailable; do not provide a fallback key. 6. Assign a dedicated, read-only, least-privilege credential restricted to the required endpoint. 7. Restrict the credential by source network, workload identity, expiration time, and request scope where supported. 8. Add automated secret scanning to source-control and packaging workflows. ]]>
