T09 · Insecure Skill Coding Practices
- Location
mcp-server/server.py:257- Finding
Unrestricted Endpoint Registration Enables Server-Side Request Forgery
- Content
View full analysis
dict: """Register a new external colony.""" TYPE_MAP = { "hive": "🏠 Another hive", "flower_field": "🌼 Data source", "manuka_grove": "🌿 Professional knowledge", "river": "🌊 Streaming information", } if colony_type not in TYPE_MAP: return {"error": f"Invalid type {colony_type}, choices: {list(TYPE_MAP.keys())}"} db = get_db() now = datetime.now(timezone.utc).isoformat() try: meta = json.loads(metadata) except json.JSONDecodeError: meta = {} db.execute( "INSERT OR REPLACE INTO colonies " "(name, type, endpoint, status, last_poll, metadata) " "VALUES (?, ?, ?, 'registered', ?, ?)", (name, colony_type, endpoint, now, json.dumps(meta, ensure_ascii=False)) ) db.commit() db.close() return { "registered": name, "type": colony_type, "endpoint": endpoint, } @mcp.tool() def colony_poll(name: str) -> dict: """Probe an external colony endpoint.""" db = get_db() row = db.execute( "SELECT * FROM colonies WHERE name = ?", (name,) ).fetchone() if not row: db.close() return {"error": f"Colony {name} is not registered"} now = datetime.now(timezone.utc).isoformat() status = "unknown" if row["endpoint"]: try: import httpx resp = httpx.get(row["endpoint"], timeout=5.0) status = "alive" if resp.status_code < 500 else "degraded" except Exception as e: status = f"unreachable: {type(e).__name__}" else: status = "no_endpoint" db.execute( "UPDATE colonies SET sta ...[truncated 2663 chars]- Remediation
View remediation
