T09 · Insecure Skill Coding Practices
- Location
scripts/browser-use-agent.sh:7- Finding
Arbitrary Python Code Execution Through Unsafely Generated Source Code
- Content
View full analysis
/tmp/_bu_task.py << PYEOF import asyncio, os $LLM_IMPORT from browser_use import Agent async def run(): llm = $LLM_INIT agent = Agent(task="""$TASK""", llm=llm) result = await agent.run(max_steps=$MAX_STEPS) final = result.final_result() if final: print(final.extracted_content if hasattr(final, 'extracted_content') else str(final)) else: for r in result.all_results: if r.extracted_content: print(r.extracted_content) asyncio.run(run()) PYEOF xvfb-run "$VENV_DIR/bin/python3" /tmp/_bu_task.py ``` ### Technical Analysis The wrapper constructs a Python program by directly interpolating three caller-controlled values: - `TASK` is inserted inside a triple-quoted Python string. - `MODEL` is inserted inside a single-quoted Python string. - `MAX_STEPS` is inserted as an unrestricted Python expression. None of these values are escaped or validated for the context in which they are inserted. A crafted task can terminate the tripl ...[truncated 1851 chars]- Remediation
View remediation
