docs: add security best practices guide for CrewAI agents#4674
Conversation
|
Nice work on this — it's well-structured and covers the key controls. A few suggestions that might strengthen it: Section 5 (Human oversight): This is the only section without a code example. CrewAI has sensitive_task = Task(
description="Execute production database migration",
expected_output="Migration result confirmation",
human_input=True, # requires human approval before completion
)Minor addition: Consider mentioning Checklist: Maybe add a line about logging/observability (e.g., "Agent runs are logged for post-incident review") since the guide links to tracing docs at the bottom. Overall this fills a real gap — there's no security guidance in the CrewAI docs today. |
|
Thanks - good catches. I updated section 5 to include a concrete Pushed on the PR branch now. |
|
Great turnaround @pandego — the Worth noting: we ran a security scan against Quick thought — if these patterns exist in the official examples, they're almost certainly in community crews too. We'd be happy to run Inkog against any of your production or enterprise agent repos if that's useful. It takes about 30 seconds and maps everything to the controls in this guide. Longer term, it would be powerful if CrewAI users could validate their crews against these security patterns automatically — scan on |
|
Thanks - that’s a really useful data point. Seeing those exact classes of issues show up in The automated validation angle is interesting too. I think that likely belongs as a broader product or maintainer discussion rather than something to fold into this docs PR directly, but I can definitely see the value in giving users a way to catch these patterns earlier in the workflow. |
|
Appreciate it @pandego — and yeah, CI integration is a separate conversation from this PR. For what it's worth, these patterns aren't unique to CrewAI — we see the same kinds of issues (prompt injection, missing oversight, SSRF through tools) across LangChain, Google ADK, AutoGen, and most popular agent frameworks. It's a gap across the whole ecosystem right now, which is part of why guides like this one matter. If it'd be useful, happy to connect with whoever on the CrewAI side is thinking about agent security or working with enterprise customers on production deployments. We've been scanning across frameworks and would be glad to share what we're finding. Either way, solid work on this PR — looking forward to it getting merged. |
|
Thanks again for the thoughtful follow-up here. I agree the broader framework-wide security gap is real, and the examples you pointed to are exactly the kind of concrete signal that makes this guide worthwhile. I think the integration / scanning angle is still better handled as a separate maintainer or product discussion than inside this docs PR, so I am going to keep this PR scoped to the guide itself. But the extra context is useful, and I appreciate you surfacing it. |
|
This PR is stale because it has been open for 45 days with no activity. |
|
Hi @pandego - we are growing fast and gaining a lot of interest, do you think someone on CrewAI would be interested in a discussion with us around a potential partnership? Can be nice to secure the agents when developing them. |
|
Thanks for sharing this. I’ll leave partnership or integration discussions to the CrewAI maintainers and keep this PR focused on the docs guide. |
2d59644 to
e7a8f79
Compare
|
Rebased this onto current main and kept the PR scoped to the security best practices docs guide. Validation:
This is still a docs-only diff. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new "Security Best Practices for CrewAI Agents" advanced docs page and registers it in docs navigation; the guide explains execution bounding, least-privileged tool access, delegation trust boundaries, output constraints, human oversight, and an operational pre-rollout checklist. ChangesSecurity Best Practices Guide
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/en/guides/advanced/security-best-practices.mdx`:
- Around line 75-83: The example uses Agent(...) without importing it, which
will break copy/paste runs—add an import for the Agent symbol (e.g., add "from
crewai import Agent") at the top of the snippet so the Coordinator example can
execute; update the code surrounding the Agent instantiation (the Coordinator
example) to include this import.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ac414c2e-28bb-49d9-a265-68a8f4370130
📒 Files selected for processing (2)
docs/docs.jsondocs/en/guides/advanced/security-best-practices.mdx
fdeddea to
bb45316
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
bb45316 to
1163336
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
d965e7c to
7c7c64e
Compare
|
Rebased this branch onto the current Validation:
I also tried to run |
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
7c7c64e to
bec51b3
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
bec51b3 to
2453bc7
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
2453bc7 to
9291400
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
9291400 to
b6f2fe0
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
b6f2fe0 to
5e4b48f
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
5e4b48f to
23d272c
Compare
|
Rebased this branch onto the current Validation:
The PR should be back in a clean review state. |
23d272c to
2bc8439
Compare
Summary
max_rpm,max_iter,max_execution_time), tool least-privilege, delegation risks, output constraints, and human approval gatesCloses #4651.
Validation
uv run python -m json.tool docs/docs.jsondocs/en/guides/advanced/security-best-practices.mdxNote
Low Risk
Low risk documentation-only change that adds a new page and updates navigation; no runtime or API behavior is modified.
Overview
Adds a new Advanced guide,
security-best-practices.mdx, documenting CrewAI-native security controls for production agents (execution bounds, least-privilege tool access, delegation considerations, structured outputs, and human approval checkpoints).Updates
docs/docs.jsonto include the new guide in the English Guides → Advanced navigation.Written by Cursor Bugbot for commit 13e092e. This will update automatically on new commits. Configure here.
Summary by CodeRabbit