T09 · Insecure Skill Coding Practices
Error
- Location
- utils/ticktick_api.py:11
- Finding
- Configurable TickTick API Base Can Exfiltrate Bearer Tokens and Task Data<![CDATA[ ## Vulnerability Details **File Location**: `sync.py:92`; `utils/ticktick_api.py:11-12, 28-38` **Vulnerability Type**: Unvalidated credential-bearing network destination **Risk Level**: High ### Vulnerable Code ```python # sync.py:92 self.ticktick = TickTickAPI( self.cfg["ticktick_token"], self.cfg["ticktick_api_base"], ) ``` ```python # utils/ticktick_api.py:11-12, 28-38 def __init__(self, token_path, api_base): self.api_base = api_base self.token = self._load_token(token_path) def _request(self, endpoint, method="GET", data=None): if not self.token: return None headers = { "Authorization": f"Bearer {self.token}", "Content-Type": "application/json", } url = f"{self.api_base}{endpoint}" try: resp = requests.request( method, url, headers=headers, json=data if data else None, timeout=30, ) ``` ### Technical Analysis The API base URL is read directly from `config.json` and used as the destination for requests carrying the TickTick bearer token. The code does not enforce HTTPS, validate the hostname, or restrict the destination to the official TickTick API. Although configurability may help testing, allowing arbitrary credential-bearing destinations exceeds what is necessary for the declared synchronization functionality. If the configuration is modified accidentally or maliciously, the application sends the bearer token and synchronized task data to the configured server. ### Attack Path 1. An attacker, compromised installer, or another process with access to the project configuration modifies `ticktick_api_base`. 2. The value is changed to an attacker-controlled HTTP or HTTPS endpoint. 3. The user runs `python sync.py` manually or through the documented cron configuration. 4. `TickTickAPI._request()` adds the TickTick bearer token to the `Authorization` header. 5. The request is delivered to the attacker-controlled server. 6. The attacker reuses t ...[truncated 497 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Pin the production API base to `https://api.ticktick.com/open/v1`. - If configurability is required, parse the URL and enforce: - The `https` scheme. - An exact hostname allowlist such as `api.ticktick.com`. - The expected API path prefix. - No embedded user information, fragments, or unexpected ports. - Reject redirects for requests containing authorization headers, or verify that redirects remain on the approved origin. - Separate test and production clients so test endpoints cannot receive production credentials. - Fail before constructing a credential-bearing request when destination validation fails. ]]>
