T09 · Insecure Skill Coding Practices
- Location
scripts/send_bark_notification.py:93- Finding
Custom Bark endpoint permits plaintext transmission and credential redirection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/send_bark_notification.py, lines 93-123
Vulnerability Type: Unvalidated notification endpoint and potentially insecure transport
Risk Level: Mediumpython base_url = os.environ.get("CODEX_BARK_BASE_URL", "https://api.day.app") if not machine_name: sys.stderr.write("Missing CODEX_MACHINE_NAME.\n") return 1 if not bark_key: sys.stderr.write("Missing CODEX_BARK_KEY.\n") return 1 task_title = args.task_title.strip() status = args.status.strip() summary = args.summary.strip() if not task_title: sys.stderr.write("--task-title must be non-empty.\n") return 1 if not summary: sys.stderr.write("--summary must be non-empty.\n") return 1 project_name = args.project_name or _get_project_name(Path.cwd()) body = "\n".join( [ f"Device: {machine_name}", f"Project: {project_name}", f"Status: {status}", f"Summary: {summary}", ] ) url = f"{base_url.rstrip('/')}/{parse.quote(bark_key)}" payload = parse.urlencode({"title": task_title, "body": body}).encode("utf-8") if args.dry_run: print("POST", url) print("title:", task_title) print("body:", body) return 0 req = request.Request(url, data=payload, method="POST") try: with request.urlopen(req, timeout=args.timeout) as resp:Technical Analysis
The
CODEX_BARK_BASE_URLenvironment variable is used directly to construct the destination URL. The implementation does not parse or validate its scheme, hostname, port, embedded credentials, or destination.Consequently, an
http://value can cause the Bark key, machine name, project name, status, title, and task summary to be transmitted without transport encryption. An attacker who can influence the process environment can also replace the legitimate Bark service with an attacker-controlled endpoint. Percent-encodingbark_keyonly ...[truncated 1310 chars]- Remediation
View remediation
Remediation Suggestions
Parse
CODEX_BARK_BASE_URLwithurllib.parse.urlsplitand enforce the following controls before constructing the request:- Require the
httpsscheme and reject plaintext HTTP. - Reject URLs containing embedded usernames or passwords.
- Require a non-empty hostname and reject malformed URLs.
- Allowlist
api.day.appby default. If self-hosted Bark servers are supported, require users to explicitly configure trusted HTTPS hostnames. - Consider rejecting fragments, unexpected query parameters, and nonstandard ports.
- Document that the task title and summary leave the local system and must not contain secrets.
- Where feasible, keep certificate verification enabled and provide no option to disable it.
A hardened implementation should construct the final URL only after successful validation and should fail closed with a clear error message when the endpoint is not trusted.
- Require the
