LangChain RBAC silently breaks when linter 'safely' rewrites type annotations
Developers at KubeIntellect discovered that a standard Ruff linter autofix could silently disable role-based access control in LangChain-powered tools. The issue stems from LangChain's config injection mechanism, which uses a strict identity check against the RunnableConfig class — meaning annotating the parameter as RunnableConfig | None causes injection to fail without any error or warning. When the config is not injected, it defaults to None, and a common fallback pattern then assigns every caller the 'admin' role, effectively making read-only API keys fully privileged. The dangerous rewrite is classified by Ruff as a 'safe' fix, meaning it can be applied automatically via a routine ruff check --fix command without developer review. The team resolved this by adding a CI-level test that scans source files and fails if any InjectedToolArg-annotated config parameter deviates from the bare RunnableConfig annotation.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in