T09 · Insecure Skill Coding Practices
- Location
assets/templates/openclaw_autopilot.py:381- Finding
GitHub Token Disclosure to an Arbitrary HTTPS Host
- Content
View full analysis
str: if not repo_url.startswith("https://"): raise ValueError("Only https:// GitHub URLs are supported for token auth.") safe_token = quote(token, safe="") return repo_url.replace("https://", f"https://x-access-token:{safe_token}@", 1) ``` The resulting credential-bearing URL is used for Git operations: ```python def ensure_repo_synced(cfg: RuntimeConfig, token: str, logger: EventLogger) -> Tuple[bool, Path, str]: cfg.working_root.mkdir(parents=True, exist_ok=True) repo_dir = cfg.working_root / repo_name_from_url(cfg.repo_url) auth_url = inject_token_to_https_url(cfg.repo_url, token) if not (repo_dir / ".git").exists(): code, out = run_cmd(["git", "clone", auth_url, str(repo_dir)], timeout=600) logger.log("repo.clone", ok=(code == 0), output=out[-800:]) if code != 0: return False, repo_dir, "clone_failed" # Remove token from local git config remote. run_cmd(["git", "remote", "set-url", "origin", cfg.repo_url], cwd=repo_dir) ``` It is also used when pushing changes: ```python def commit_and_push( repo_dir: Path, cfg: RuntimeConfig, token: str, audit: AuditResult, logger: EventLogger, ) -> Tuple[bool, str, Optional[str]]: auth_url = inject_token_to_https_url(cfg.repo_url, token) # ... code, out = run_cmd(["git", "push", auth_url, f"{cfg.branch}:{cfg.branch}"], cwd=repo_dir, timeout=300) logger.log("git.push", ok=(code == 0), output=out[-1000:]) ``` Runtime startup only rejects placeholder v ...[truncated 2618 chars]- Remediation
View remediation
