T09 · Insecure Skill Coding Practices
- Location
- bark_push/config_manager.py:205
- Finding
- Unrestricted Bark Endpoint Allows Plaintext Disclosure of Device Credentials and Notification Data<![CDATA[ ## Vulnerability Details **File Location**: `bark_push/config_manager.py:205`, `bark_push/command_handler.py:36`, `bark_push/command_handler.py:236-240`, `bark_push/bark_api.py:19-28` **Vulnerability Type**: Unvalidated outbound endpoint and insecure transport **Risk Level**: Medium ### Vulnerable Code ```python # bark_push/config_manager.py:205 default_push_url = _require_str( raw, "default_push_url", "https://api.day.app", ) or "https://api.day.app" ``` ```python # bark_push/command_handler.py:36 self._api = BarkClient( base_url=self._config_mgr.config.default_push_url ) ``` ```python # bark_push/command_handler.py:236-240 for alias, device_key in zip(users.aliases, users.device_keys): single_payload = dict(payload) single_payload["device_key"] = device_key single_payload["_use_push_path"] = True resp = self._api.push_json(single_payload) ``` ```python # bark_push/bark_api.py:19-28 def __init__(self, base_url: str) -> None: self._base_url = base_url.rstrip("/") def push_json( self, payload: dict[str, Any], timeout_s: float = 10.0, ) -> BarkResponse: url = self._resolve_url(payload) body_bytes = json.dumps( payload, ensure_ascii=False, ).encode("utf-8") req = Request(url, data=body_bytes, method="POST") req.add_header("Content-Type", "application/json; charset=utf-8") try: with urlopen(req, timeout=timeout_s) as resp: ``` ### Technical Analysis The `default_push_url` configuration value is only checked for being a string. The implementation does not parse or validate its scheme, hostname, port, embedded credentials, or destination. The configured value is passed directly to `BarkClient`. During a push, the client adds the recipient's Bark `device_key` to the JSON payload and transmits the payload to that endpoint. The payload can also contain notification content, clipboard data, actions, and ciphertext-related parameters. Consequently, a config ...[truncated 2188 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse `default_push_url` with `urllib.parse.urlparse` before constructing `BarkClient`. 2. Require the `https` scheme for production endpoints. 3. If local development over HTTP is necessary, permit it only for explicit loopback addresses such as `127.0.0.1` and `::1`, and require a dedicated development option. 4. Reject malformed URLs, missing hostnames, embedded user credentials, fragments, and schemes other than HTTPS. 5. Consider using an allowlist containing `api.day.app` and explicitly approved custom Bark servers. 6. Require a clear confirmation when the configured host differs from the official endpoint. 7. Document that custom servers receive device keys and complete notification payloads. 8. Add tests confirming that cleartext remote URLs, unsupported schemes, and malformed endpoints are rejected. ]]>
