T09 · Insecure Skill Coding Practices
- Location
scripts/deregister.py:33- Finding
Consul ACL Token Can Be Sent to Arbitrary Destinations over Plaintext HTTP
- Content
View full analysis
str: if not agent.startswith("http"): agent = "http://" + agent return agent.rstrip("/") + CONSUL_DEREGISTER_PATH + service_id def deregister(agent: str, service_id: str, token: str = None, dry_run: bool = False) -> dict: url = build_url(agent, service_id) if dry_run: return {"agent": agent, "service_id": service_id, "url": url, "status": "DRY_RUN", "ok": True} try: req = urllib.request.Request(url, method="PUT") if token: req.add_header("X-Consul-Token", token) with urllib.request.urlopen(req, timeout=10) as resp: status = resp.status ok = status == 200 return {"agent": agent, "service_id": service_id, "url": url, "status": status, "ok": ok} ``` The affected destinations and token are accepted from user-controlled command-line inputs: ```python parser.add_argument("--agents-file", help="File with one agent address per line") parser.add_argument("--from-curl", help="Raw curl command(s) to parse and replay") parser.add_argument("--token", help="Consul ACL token (X-Consul-Token header)") ``` ```python if args.from_curl: parsed = parse_curl_commands(args.from_curl) if not parsed: print("❌ No valid consul deregister curl commands found in input.", file=sys.stderr) sys.exit(1) tasks = [(p["agent"], p["service_id"]) for p in parsed] else: if not args.service_id: parser.error("--service-id is required unless using --from-curl") agents = list(args.agents or []) if args.agents_file: ...[truncated 3111 chars]- Remediation
View remediation
