feat(langchain): add LC-009, LC-023 path safety rules - #59
Open
bradAGI wants to merge 1 commit into
Open
Conversation
LangChain had no path-safety rule; Claude SDK (CSDK-004/012), OpenAI (OAI-006), ADK (ADK-004), and MCP (MCP-005) all ship one. Ships the python/TypeScript pair this pack uses throughout. LC-009 (python): the args_schema does not close the gap — a Pydantic field typed str or Path validates cleanly while still carrying ../../etc/passwd, because the schema constrains the argument's type and not the region of the filesystem it points at. LangChain agents are also a common indirect injection target: a retrieved document or a page fetched mid-run can carry the path the model then passes in. LC-023 (typescript): mirrors CSDK-012, including its coarse-signal caveat — it flags any filesystem write rather than only unnormalized paths, because TS path-normalization analysis is not yet wired.
bradAGI
force-pushed
the
feat/langchain-path-safety
branch
from
August 24, 2026 18:49
29aab4a to
086a9d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LangChain had no path-safety rule. Claude SDK (CSDK-004/012), OpenAI (OAI-006), ADK (ADK-004), and MCP (MCP-005) all ship one. Ships the python/TypeScript pair this pack uses throughout (LC-003/011, LC-004/012, LC-005/013).
LC-009 (python). Two things make the framing LangChain's own rather than a copy of CSDK-004. The
args_schemalooks like it covers this and doesn't — a Pydantic field typedstrorPathvalidates cleanly while still carrying../../etc/passwd, because the schema constrains the argument's type, not the region of the filesystem it points at. And LangChain agents are a common indirect-injection target: a retrieved document or a page fetched mid-run can carry the path the model then passes here, so the argument is hostile even when the user isn't. The fix pushes the check onto theargs_schemafield as a validator so containment holds for every tool accepting that path.Uses the per-param
call_uses_unnormalized_path_paramwith the same callee set as CSDK-004, so a tool with two path params and one.resolve()still fires on the unresolved one.LC-023 (typescript). Mirrors CSDK-012, including its coarse-signal caveat, stated in the explanation so the finding is honest about itself: it flags any filesystem write, not only unnormalized paths, because TS path-normalization analysis isn't wired yet. Confidence 0.5 to match. The injection route here is the ordinary one in this framework rather than an exotic case — a retrieval chain feeds fetched documents into the same context the model plans from, so text in a page or a knowledge-base record can supply the filename. The Zod schema has the same blind spot as the Python
args_schema: it constrains the argument's type, not where it points.Verification — engine built at
main:open(note_path)on a raw paramLC-009, LC-201Path(...).resolve()+is_relative_toroot checkLC-201writeFileSync(notePath, body)LC-023, LC-201LC-201(LC-201 is the pre-existing missing-AGENTS.md repo rule.)
No new predicates, so no
schema_versionbump.Updated from the original single-rule version: I'd drafted LC-023 as a separate PR, then folded it in here — both rules create
langchain/path_safety.yaml, so as two PRs they'd have been an add/add conflict, and "LangChain path safety" is the same atomic unit either way.