langchain - 💡(How to fix) Fix feat(community): Add Sensitivity Ratchet callback handler for irreversible permission narrowing [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#36508Fetched 2026-04-08 02:43:59
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
closed ×1commented ×1labeled ×1

I'd like to add a SensitivityRatchetCallbackHandler to langchain_community/callbacks/ that enforces irreversible permission narrowing for AI agents.

Root Cause

AI agents with read:* + write:* scopes can silently exfiltrate sensitive data — an agent reads a CONFIDENTIAL HR record, then writes a summary to a public Slack channel. Standard RBAC doesn't prevent this because permissions are static for the session.

RAW_BUFFERClick to expand / collapse

Description

I'd like to add a SensitivityRatchetCallbackHandler to langchain_community/callbacks/ that enforces irreversible permission narrowing for AI agents.

The Problem

AI agents with read:* + write:* scopes can silently exfiltrate sensitive data — an agent reads a CONFIDENTIAL HR record, then writes a summary to a public Slack channel. Standard RBAC doesn't prevent this because permissions are static for the session.

This is a real attack pattern with CVEs:

  • EchoLeak (CVE-2025-32711, CVSS 9.3) — Microsoft 365 Copilot data exfiltration
  • ForcedLeak (CVSS 9.4) — Salesforce AgentForce CRM data leak

The Solution

The Sensitivity Ratchet enforces a monotonic narrowing rule: once an agent accesses data at a given sensitivity level, its permission scope is permanently reduced. Two mathematical invariants hold:

  • HW(t) ≥ HW(t-1) — high-water mark only increases
  • P(t) ⊆ P(t-1) — permission set only shrinks

Implementation

The callback handler intercepts on_tool_start, classifies each tool by sensitivity, and fires on_narrowed / on_blocked callbacks. The existing PyPI package (agent-iam-ratchet) already includes a working LangChain integration.

I'm happy to submit a PR adding this to libs/community/langchain_community/callbacks/sensitivity_ratchet.py with tests.

extent analysis

TL;DR

Implement the SensitivityRatchetCallbackHandler in langchain_community/callbacks/ to enforce irreversible permission narrowing for AI agents, preventing sensitive data exfiltration.

Guidance

  • Review the agent-iam-ratchet PyPI package and its LangChain integration to understand the existing implementation.
  • Consider the mathematical invariants (HW(t) ≥ HW(t-1) and P(t) ⊆ P(t-1)) when designing the SensitivityRatchetCallbackHandler.
  • Evaluate the callback handler's interception of on_tool_start and firing of on_narrowed / on_blocked callbacks to ensure correct permission scope reduction.
  • Test the implementation thoroughly to prevent potential security vulnerabilities.

Example

No explicit code example is provided, but the agent-iam-ratchet package and its documentation can serve as a reference for implementing the SensitivityRatchetCallbackHandler.

Notes

The implementation should carefully consider the trade-offs between security and functionality, as the irreversible permission narrowing may impact the usability of AI agents.

Recommendation

Apply the workaround by implementing the SensitivityRatchetCallbackHandler to mitigate the sensitive data exfiltration vulnerability, as demonstrated by the EchoLeak and ForcedLeak attack patterns.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING