T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/run_task.py:46- Finding
Administrator Token Used with Caller-Controlled Repository Targets
- Content
View full analysis
list[dict]: errors = [] if task.get("protocol") != "research_kb_agent_task": errors.append({"code": "INVALID_PROTOCOL", "message": "protocol must be research_kb_agent_task"}) if task.get("taskType") not in {"kb_query", "kb_literature_review"}: errors.append({"code": "INVALID_TASK_TYPE", "message": "taskType must be kb_query or kb_literature_review"}) if not task.get("kbTargets"): errors.append({"code": "INVALID_KB_TARGETS", "message": "kbTargets is required"}) if not (task.get("payload") or {}).get("question"): errors.append({"code": "MISSING_QUESTION", "message": "payload.question is required"}) return errors ``` ```python def headers() -> dict[str, str]: return {"Authorization": f"token {GITEA_TOKEN}", "Accept": "application/json", "Content-Type": "application/json"} def gitea_api(method: str, path: str, *, json_body=None, ok=(200, 201, 204)) -> object: if not GITEA_URL or not GITEA_TOKEN: raise RuntimeError("GITEA_URL and GITEA_ADMIN_TOKEN are required") response = requests.request(method, f"{GITEA_URL}{path}", headers=headers(), json=json_body, timeout=60) ``` ```python def read_candidates(task: dict, topic: str) -> list[dict]: page_terms = terms(topic + " " + str((task.get("payload") or {}).get("question", ""))) candidates = [] for target in task.get("kbTargets") or []: owner = target["repoOwner"] repo = target["repoName"] ``` ```python def write_review(task: dict, title: str, md: str) -> str: target = (task.get("kbTarget ...[truncated 3586 chars]- Remediation
View remediation
