Skip to content

    Type a page, a command such as keryn scan, or a rule id.

    rag-loader-ssrf-v1

    View as Markdown

    15 rules · Keryn Software Licence · rules 0.8.0 · all packs

    How to read a rule
    Severity
    How bad the finding is if it is real: error fails a default gate, warning and info do not.
    Confidence
    P0 exploitable as written; P1 dangerous in context; P2 a heuristic or a posture check: confirm by reading the code.
    False-positive risk
    low: an exact API or flag, so hits are almost always real; medium: the pattern is legitimate in many programs, so check each hit; high: it finds a lead to confirm, so expect benign hits.
    Edge
    The relationship the finding sits on. reaches: content or traffic gets to a thing; calls: one thing invokes another; reads: one thing reads from another; writes: one thing writes to another; sends: data leaves for another party; grants: authority is given or left unchecked; depends_on: something relies on a component it does not verify; trusts: one party believes another without evidence. The boundary it crosses, when there is one: user->prompt (untrusted input reaching a prompt); model->code (model output reaching code, a shell, a query or a page); secret->outside (a secret leaving the trusted side); supply-chain (code, models or prompts pulled in from outside).
    Taxonomy chips
    References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.

    seceng.ragloader.langchain-web-loader-ssrf

    Section titled “seceng.ragloader.langchain-web-loader-ssrf”

    error python data-flow rule langchain, flask, fastapi

    Request-controlled URL reaches a LangChain web loader (WebBaseLoader, AsyncHtmlLoader, SeleniumURLLoader). The server fetches it (and follows redirects), so a caller can reach cloud metadata (169.254.169.254), localhost admin ports and internal services, and the fetched text lands in your index. Validate scheme and host against an allow-list and block private/link-local addresses after DNS resolution.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM01 LLM02 ASI01 ASI02

    Fix: Parse the URL, require https and a hostname on an explicit allow-list, resolve it and reject loopback/private/link-local ranges (re-check after redirects), and fetch through an egress proxy. Do not let end users choose crawl roots.

    References: https://docs.langchain.com/oss/python/integrations/document_loaders

    Try it: a snippet that triggers this rule

    Written for this page, not taken from any project. Save it as rag/ingest_api.py and scan it with keryn scan rag --verbose; the finding below appears.

    rag/ingest_api.py
    from flask import Flask, request, jsonify
    from langchain_community.document_loaders import WebBaseLoader
    from langchain_text_splitters import RecursiveCharacterTextSplitter
    app = Flask(__name__)
    splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=80)
    @app.post("/ingest")
    def ingest():
    page_url = request.form["url"]
    docs = WebBaseLoader(page_url).load()
    chunks = splitter.split_documents(docs)
    return jsonify(chunks=len(chunks))

    Checked with Keryn’s browser engine when this page was built: it reports seceng.ragloader.langchain-web-loader-ssrf at line 12 (error, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.

    seceng.ragloader.recursive-url-loader-ssrf

    Section titled “seceng.ragloader.recursive-url-loader-ssrf”

    error python data-flow rule langchain, flask, fastapi

    Request-controlled URL reaches RecursiveUrlLoader, which also crawls every link it finds from that root. The server fetches it (and follows redirects), so a caller can reach cloud metadata (169.254.169.254), localhost admin ports and internal services, and the fetched text lands in your index. Validate scheme and host against an allow-list and block private/link-local addresses after DNS resolution.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM01 LLM02 ASI01 ASI02

    Fix: Parse the URL, require https and a hostname on an explicit allow-list, resolve it and reject loopback/private/link-local ranges (re-check after redirects), and fetch through an egress proxy. Do not let end users choose crawl roots.

    References: https://docs.langchain.com/oss/python/integrations/document_loaders

    seceng.ragloader.unstructured-url-loader-ssrf

    Section titled “seceng.ragloader.unstructured-url-loader-ssrf”

    error python data-flow rule langchain, unstructured, flask, fastapi

    Request-controlled URL reaches UnstructuredURLLoader. The server fetches it (and follows redirects), so a caller can reach cloud metadata (169.254.169.254), localhost admin ports and internal services, and the fetched text lands in your index. Validate scheme and host against an allow-list and block private/link-local addresses after DNS resolution.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM01 LLM02 ASI01 ASI02

    Fix: Parse the URL, require https and a hostname on an explicit allow-list, resolve it and reject loopback/private/link-local ranges (re-check after redirects), and fetch through an egress proxy. Do not let end users choose crawl roots.

    References: https://docs.langchain.com/oss/python/integrations/document_loaders

    seceng.ragloader.playwright-url-loader-ssrf

    Section titled “seceng.ragloader.playwright-url-loader-ssrf”

    error python data-flow rule langchain, playwright, flask, fastapi

    Request-controlled URL reaches a browser-driven loader (PlaywrightURLLoader), which also executes the page’s JavaScript. The server fetches it (and follows redirects), so a caller can reach cloud metadata (169.254.169.254), localhost admin ports and internal services, and the fetched text lands in your index. Validate scheme and host against an allow-list and block private/link-local addresses after DNS resolution.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM01 LLM02 ASI01 ASI02

    Fix: Parse the URL, require https and a hostname on an explicit allow-list, resolve it and reject loopback/private/link-local ranges (re-check after redirects), and fetch through an egress proxy. Do not let end users choose crawl roots.

    References: https://docs.langchain.com/oss/python/integrations/document_loaders

    seceng.ragloader.llamaindex-web-reader-ssrf

    Section titled “seceng.ragloader.llamaindex-web-reader-ssrf”

    error python data-flow rule llamaindex, flask, fastapi

    Request-controlled URL reaches a LlamaIndex web reader (SimpleWebPageReader, BeautifulSoupWebReader, loaders from download_loader). The server fetches it (and follows redirects), so a caller can reach cloud metadata (169.254.169.254), localhost admin ports and internal services, and the fetched text lands in your index. Validate scheme and host against an allow-list and block private/link-local addresses after DNS resolution.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM01 LLM02 ASI01 ASI02

    Fix: Parse the URL, require https and a hostname on an explicit allow-list, resolve it and reject loopback/private/link-local ranges (re-check after redirects), and fetch through an egress proxy. Do not let end users choose crawl roots.

    References: https://developers.llamaindex.ai/python/framework-api-reference/readers/web/

    seceng.ragloader.ingest-pipeline-fetch-user-url

    Section titled “seceng.ragloader.ingest-pipeline-fetch-user-url”

    error python data-flow rule rag, requests, httpx, flask, fastapi

    Ingestion code fetches a request-controlled URL with an HTTP client and then chunks/embeds/indexes the response. Callers can make the server read internal endpoints (SSRF) and plant arbitrary text in your vector store. Allow-list hosts and block private ranges before fetching.

    Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.

    Edge inspected: writes one thing writes to another.

    CWE-918 LLM01 LLM08 ASI01 ASI06

    Fix: Validate the URL (https, allow-listed hostname, resolved IP not private/loopback/link-local, redirects re-checked), fetch via an egress proxy with size and time limits, and record provenance for each indexed document.

    References: https://community.owasp.org/attacks/Server_Side_Request_Forgery

    seceng.ragloader.langchain-file-loader-path-traversal

    Section titled “seceng.ragloader.langchain-file-loader-path-traversal”

    error python data-flow rule langchain, flask, fastapi

    Request-controlled path reaches a LangChain file loader (PyPDFLoader, TextLoader, UnstructuredFileLoader, CSVLoader, …). A caller can read arbitrary files via ../ or absolute paths and have them indexed and returned through the model. Resolve against a fixed base directory and reject anything that escapes it.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reads one thing reads from another.

    CWE-22 CWE-73 LLM02 ASI02 ASI01

    Fix: Accept an identifier, not a path. Build the path with a fixed base (Path(BASE, name).resolve()), verify resolved.is_relative_to(BASE), use secure_filename for uploads, and exclude symlinks.

    References: https://docs.langchain.com/oss/python/integrations/document_loaders

    seceng.ragloader.directory-loader-path-traversal

    Section titled “seceng.ragloader.directory-loader-path-traversal”

    error python data-flow rule langchain, flask, fastapi

    Request-controlled path reaches DirectoryLoader, which globs and loads everything under that directory. A caller can read arbitrary files via ../ or absolute paths and have them indexed and returned through the model. Resolve against a fixed base directory and reject anything that escapes it.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reads one thing reads from another.

    CWE-22 CWE-73 LLM02 ASI02 ASI01

    Fix: Accept an identifier, not a path. Build the path with a fixed base (Path(BASE, name).resolve()), verify resolved.is_relative_to(BASE), use secure_filename for uploads, and exclude symlinks.

    References: https://docs.langchain.com/oss/python/integrations/document_loaders

    Try it: a snippet that triggers this rule

    Written for this page, not taken from any project. Save it as rag/folder_index.py and scan it with keryn scan rag --verbose; the finding below appears.

    rag/folder_index.py
    from flask import Flask, request, jsonify
    from langchain_community.document_loaders import DirectoryLoader
    app = Flask(__name__)
    @app.get("/index-folder")
    def index_folder():
    folder = request.args.get("folder", "docs")
    loader = DirectoryLoader(folder, glob="**/*.md")
    documents = loader.load()
    return jsonify(count=len(documents))

    Checked with Keryn’s browser engine when this page was built: it reports seceng.ragloader.directory-loader-path-traversal at line 10 (error, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.

    seceng.ragloader.simple-directory-reader-path-traversal

    Section titled “seceng.ragloader.simple-directory-reader-path-traversal”

    error python data-flow rule llamaindex, flask, fastapi

    Request-controlled path reaches LlamaIndex SimpleDirectoryReader (input_dir / input_files). A caller can read arbitrary files via ../ or absolute paths and have them indexed and returned through the model. Resolve against a fixed base directory and reject anything that escapes it.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reads one thing reads from another.

    CWE-22 CWE-73 LLM02 ASI02 ASI01

    Fix: Accept an identifier, not a path. Build the path with a fixed base (Path(BASE, name).resolve()), verify resolved.is_relative_to(BASE), use secure_filename for uploads, and exclude symlinks.

    References: https://developers.llamaindex.ai/python/framework/module_guides/loading/simpledirectoryreader/

    seceng.ragloader.retrieved-content-in-system-prompt

    Section titled “seceng.ragloader.retrieved-content-in-system-prompt”

    warning python data-flow rule langchain, rag, openai, anthropic

    Retrieved document text (page_content) is interpolated into the system/developer prompt with no delimiter or labeling. Any indexed page can then carry instructions with system-level authority (indirect prompt injection). Put retrieved text in a clearly delimited, labeled data block (or a user/tool message) and tell the model to treat it as untrusted.

    Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk high: it finds a lead to confirm, so expect benign hits.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-77 CWE-1427 LLM01 ASI01 ASI06

    Fix: Wrap retrieved chunks in explicit tags such as <documents><document source=…>…</document></documents>, state in the system prompt that their content is data and never instructions, strip or escape the closing tag inside chunks, and keep tool permissions independent of retrieved text.

    References: https://genai.owasp.org/llmrisk/llm01-prompt-injection/ · https://docs.langchain.com/oss/python/deepagents/rag

    seceng.ragloader.loaded-doc-metadata-as-retrieval-filter

    Section titled “seceng.ragloader.loaded-doc-metadata-as-retrieval-filter”

    warning python data-flow rule langchain, chroma, pinecone, rag

    Metadata taken from a loaded/retrieved document is used unchecked as a vector-store filter. Document metadata (source, author, tenant, tags) is attacker-influenced when documents come from the web or uploads, so it can widen retrieval across tenants or inject filter operators. Validate keys and values against a schema before filtering.

    Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk high: it finds a lead to confirm, so expect benign hits.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-943 CWE-20 LLM08 LLM01 ASI06 ASI01

    Fix: Build filters from a server-side allow-list of keys and a typed schema (e.g. pydantic) and enforce tenant filters server-side; never copy metadata dicts from documents into filter arguments.

    References: https://docs.langchain.com/oss/python/langchain/overview · https://docs.trychroma.com/docs/querying-collections/metadata-filtering

    seceng.ragloader.langchainjs-web-loader-ssrf

    Section titled “seceng.ragloader.langchainjs-web-loader-ssrf”

    error typescript, javascript data-flow rule langchain, express, nextjs

    Request-controlled URL reaches a LangChain.js web loader (CheerioWebBaseLoader, PuppeteerWebBaseLoader, PlaywrightWebBaseLoader, FireCrawlLoader). The server fetches it, so callers can reach cloud metadata and internal services. Validate scheme/host against an allow-list and block private ranges.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM01 LLM02 ASI01 ASI02

    Fix: Parse with new URL(), require https and an allow-listed hostname, resolve DNS and reject private/loopback/link-local addresses (re-check redirects), and crawl through an egress proxy.

    References: https://docs.langchain.com/oss/javascript/langchain/overview

    Try it: a snippet that triggers this rule

    Written for this page, not taken from any project. Save it as src/ingest.js and scan it with keryn scan src --verbose; the finding below appears.

    src/ingest.js
    import express from "express";
    import { CheerioWebBaseLoader } from "@langchain/community/document_loaders/web/cheerio";
    const app = express();
    app.use(express.json());
    app.post("/ingest", async (req, res) => {
    const loader = new CheerioWebBaseLoader(req.body.url);
    const docs = await loader.load();
    res.json({ pages: docs.length, firstChars: docs[0]?.pageContent.slice(0, 120) });
    });
    app.listen(3000);

    Checked with Keryn’s browser engine when this page was built: it reports seceng.ragloader.langchainjs-web-loader-ssrf at line 8 (error, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.

    seceng.ragloader.langchainjs-recursive-url-loader-ssrf

    Section titled “seceng.ragloader.langchainjs-recursive-url-loader-ssrf”

    error typescript, javascript data-flow rule langchain, express, nextjs

    Request-controlled URL is the crawl root for LangChain.js RecursiveUrlLoader, which follows every link it discovers. Callers can make the server crawl internal networks. Restrict roots to allow-listed hosts and cap depth.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM01 LLM02 ASI01 ASI02

    Fix: Allow-list crawl roots, set preventOutside: true and a small maxDepth, and block private address ranges after resolution.

    References: https://docs.langchain.com/oss/javascript/langchain/overview

    seceng.ragloader.langchainjs-file-loader-path-traversal

    Section titled “seceng.ragloader.langchainjs-file-loader-path-traversal”

    error typescript, javascript data-flow rule langchain, express, nextjs

    Request-controlled path reaches a LangChain.js file loader (PDFLoader, TextLoader, DirectoryLoader, CSVLoader, …). Callers can read arbitrary server files with ../ or absolute paths. Resolve under a fixed base directory and reject escapes.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: reads one thing reads from another.

    CWE-22 CWE-73 LLM02 ASI02 ASI01

    Fix: Take an id and map it to a file under a fixed base (path.resolve(BASE, name) then check startsWith(BASE + path.sep)), or use path.basename on upload names.

    References: https://docs.langchain.com/oss/javascript/langchain/overview

    seceng.ragloader.retrieved-content-in-system-prompt-ts

    Section titled “seceng.ragloader.retrieved-content-in-system-prompt-ts”

    warning typescript, javascript data-flow rule langchain, rag, openai, anthropic

    Retrieved document text (pageContent) is interpolated into the system/developer prompt with no delimiter or labeling, so any indexed page can carry instructions with system authority (indirect prompt injection). Put retrieved text in a delimited, labeled data block and tell the model it is untrusted.

    Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk high: it finds a lead to confirm, so expect benign hits.

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-77 CWE-1427 LLM01 ASI01 ASI06

    Fix: Wrap retrieved chunks in explicit tags such as <documents>…</documents>, state in the system prompt that they are data and never instructions, escape closing tags inside chunks, and keep tool permissions independent of retrieved text.

    References: https://genai.owasp.org/llmrisk/llm01-prompt-injection/ · https://docs.langchain.com/oss/javascript/langchain/overview