Skip to content

Commit 10748e7

Browse files
docs: fix formatting and spacing in Section 9
Cleaned up Markdown formatting in Section 9 to satisfy CI requirements. Specifically addressed MD009 trailing spaces on bullet points and MD031/MD022 spacing around headings and Python code blocks.
1 parent 4635666 commit 10748e7

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

cheatsheets/AI_Agent_Security_Cheat_Sheet.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -662,34 +662,31 @@ class SecureContextBuilder:
662662
```
663663
### 9. Identity Propagation & Context
664664

665-
- Enforce User Context Propagation:
666-
Require agents to pass the user's original authentication token (e.g., JWT) to any backend tool or API.
667-
- Validate at the Source:
668-
Ensure backend services validate the user's identity and permissions, preventing the agent from acting as a privileged "super-user".
669-
- Maintain Audit Trails:
670-
Log all agent actions with the associated user identity to ensure non-repudiation and clear accountability.
665+
- Enforce User Context Propagation: Require agents to pass the user's original authentication token (e.g., JWT) to any backend tool or API.
666+
- Validate at the Source: Ensure backend services validate the user's identity and permissions, preventing the agent from acting as a privileged "super-user".
667+
- Maintain Audit Trails: Log all agent actions with the associated user identity to ensure non-repudiation and clear accountability.
671668
- To ensure the agent only has the same permissions as the user (no "Super-User" powers).
672669
- Telling the database: This request is coming from User, only show him his own data.
673-
- Prevent Privilege Escalation: Ensure the agent only possesses the same permissions as the active user by acting as a passthrough for the user's authenticated identity.
670+
- Prevent Privilege Escalation:Ensure the agent only possesses the same permissions as the active user by acting as a passthrough for the users authenticated identity.
671+
672+
### Implementation: Passing User Identity to AI Tools
673+
674674

675-
Implementation: Passing User Identity to AI Tools (Python/FastAPI)
676675
```Python
677676
from fastapi import Header, HTTPException
677+
678678
async def secure_ai_tool(data: dict, authorization: str = Header(None)):
679679
"""
680680
Ensures the AI Agent acts as a passthrough for the user's identity.
681681
"""
682682
# 1. Extract and validate the HUMAN user's identity from the bearer token
683-
user = verify_jwt(authorization)
683+
user = verify_jwt(authorization)
684684
if not user:
685685
raise HTTPException(status_code=401, detail="Valid user context required")
686686
# 2. Perform the action using the specific human user's permissions
687687
return await db.execute_action(user_id=user.id, **data)
688688
```
689-
690-
691689
## Do's and Don'ts
692-
693690
**Do:**
694691

695692
- Apply least privilege to all agent tools and permissions.

0 commit comments

Comments
 (0)