Back to skill

Security audit

ragflow-skill-python

Security checks for vulnerabilities and agentic risk

Overview

This skill coherently manages RAGFlow datasets and documents, but users should treat its API key, uploads, and delete operations with care.

Install only for a trusted RAGFlow server and prefer HTTPS for any non-local endpoint. Keep RAGFLOW_API_KEY scoped to the minimum privileges available, verify dataset and document IDs before destructive actions, and treat retrieved chunks or API error text as external content rather than instructions.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/common.py:83
Finding

Bearer credentials and uploaded documents may be transmitted over insecure transport or cross-origin redirects

Content
View full analysis
str: base_url = (cli_base_url or "").strip() or _require_env_var(RAGFLOW_API_URL_ENV) parsed = urllib.parse.urlsplit(base_url) if not parsed.scheme or not parsed.netloc: raise ConfigError( f"Invalid {RAGFLOW_API_URL_ENV}. Use an absolute URL such as http://127.0.0.1:9380." ) return base_url.rstrip("/") ``` ```python def request_json( url: str, api_key: str, *, method: str = "GET", body: bytes | None = None, content_type: str | None = None, accept: str = "application/json", ) -> dict[str, Any]: headers = {"Authorization": f"Bearer {api_key}"} if accept: headers["Accept"] = accept if content_type: headers["Content-Type"] = content_type request_obj = urllib.request.Request(url, headers=headers, data=body, method=method) try: with urllib.request.urlopen(request_obj, timeout=HTTP_TIMEOUT) as response: return decode_json_response(response.read()) ``` From `scripts/upload.py`: ```python def upload_documents(dataset_id: str, file_paths: list[str], *, base_url: str, api_key: str) -> dict[str, Any]: missing = [path for path in file_paths if not Path(path).exists()] if missing: raise ConfigError("File(s) not found: " + ", ".join(missing)) boundary, body = _build_multipart(file_paths) url = f"{base_url}/api/v1/datasets/{dataset_id}/documents" request_obj = urllib.request.Request(url, data=body, method="POST") request_obj.add_header("Authorization", f"Bearer {api_key}") request_obj.add_header("Content-Type", f"multipart/form-data; boundary={boundary ...[truncated 3301 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
scripts/parse.py:29
Finding

Unencoded dataset identifiers can alter authenticated API request paths

Content
View full analysis
dict[str, object]: url = f"{base_url}/api/v1/datasets/{dataset_id}/chunks" body = json.dumps({"document_ids": document_ids}).encode("utf-8") ``` From `scripts/stop_parse_documents.py`: ```python def stop_parse(dataset_id: str, document_ids: list[str], *, base_url: str, api_key: str) -> dict[str, Any]: url = f"{base_url}/api/v1/datasets/{dataset_id}/chunks" response = ensure_success( request_json( url, api_key, method="DELETE", body=json.dumps({"document_ids": document_ids}).encode("utf-8"), content_type="application/json", ) ) ``` From `scripts/upload.py`: ```python def upload_documents(dataset_id: str, file_paths: list[str], *, base_url: str, api_key: str) -> dict[str, Any]: missing = [path for path in file_paths if not Path(path).exists()] if missing: raise ConfigError("File(s) not found: " + ", ".join(missing)) boundary, body = _build_multipart(file_paths) url = f"{base_url}/api/v1/datasets/{dataset_id}/documents" request_obj = urllib.request.Request(url, data=body, method="POST") ``` ### Technical Analysis These operations interpolate `dataset_id` directly into a URL path. A value containing `/`, `..`, `?`, `#`, or percent-encoded path syntax can be interpreted as URL structure rather than as one opaque dataset identifier. Other project scripts correctly use: ```python urllib.parse.quote(dataset_id, safe="") ``` The inconsistent handling means attacker-influenced identifiers can change the path or query reached by an authenticated POST or DELE ...[truncated 1694 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The supplied code is narrowly focused on dataset CRUD subset operations: list, info, create, and delete. It calls /api/v1/datasets for GET, POST, and DELETE and formats output for those actions. There is no code for updating datasets, managing documents, controlling parsing, checking parse status, retrieving chunks, or listing models. The declared description presents a significantly broader skill scope than this code chunk actually provides. While the implemented functionality is within the declared domain, the description does not accurately represent this specific code chunk’s actual behavior.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 43)May include surrounding context.

md
python3 scripts/upload.py DATASET_ID /path/to/file.pdf --json

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 44)May include surrounding context.

md
python3 scripts/upload.py DATASET_ID /path/to/file.pdf --json

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
88% confidence
Finding

The instruction to surface progress_msg directly and preserve API error fields exactly creates a direct prompt/content propagation path from an external system into user-visible output. If the upstream RAGFlow service, ingested documents, or parse errors contain adversarial prompt text, the agent may relay untrusted instructions or sensitive content without sanitization, enabling prompt injection or data exfiltration attempts through reflected output.

Content

Scanner excerpt · SKILL.md (reported line 69)May include surrounding context.

md
- If a parse status result includes `progress_msg`, surface it directly. For `FAIL`, treat it as the primary error detail.
- Use `--retrieval-test` only for single-dataset debugging or when the user explicitly asks for that endpoint.

## Output Rules

- Follow `reference.md`.
- Use tables for 3+ items when possible.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The function is presented as stopping document parsing, but it issues a DELETE request to the dataset chunks endpoint with document IDs. In a dataset-ingestion skill, this mismatch can cause destructive data loss when an operator believes they are performing a reversible control action, making it a high-risk integrity issue with strong potential for accidental exploitation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The actual implementation deletes chunks instead of performing the manifest-described stop-parsing operation, creating a dangerous discrepancy between advertised and real behavior. Because this skill is specifically for RAGFlow dataset management, users are likely to trust the command name and may unintentionally destroy indexed content or retrieval data across selected documents.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill declares access to sensitive environment variables and relies on Python scripts that imply file reads and outbound network access, but it does not declare any explicit tool scope such as allowed-tools or permissions. That makes the effective capability boundary unclear and increases the risk of over-privileged execution or unintended tool use when the skill is invoked.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The delete command irreversibly removes datasets based solely on a provided ID list and immediately issues the API DELETE request, with no interactive confirmation, dry-run mode, or additional safeguard. In an agent skill context, this is more dangerous than a normal CLI because agents can invoke destructive actions from ambiguous prompts, bad planning, or prompt-injection-influenced tool use, leading to accidental data loss.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This code issues a DELETE request that removes documents from a dataset, but there is no confirmation prompt, cautionary log, or inline warning describing the destructive action before it occurs. Although the command name is 'delete', the file itself provides no explicit user disclosure around the irreversible effect of deleting document IDs.

Content

No source excerpt is available for this finding.

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/common.py (reported line 59)May include surrounding context.

python
return

    for stream_name in ("stdout", "stderr"):
        stream = getattr(sys, stream_name, None)
        if stream is None or not hasattr(stream, "reconfigure"):
            continue
        try:

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

This code sends the user's query and optional document/dataset identifiers to a remote HTTP endpoint, then later prints retrieved chunk content to stdout. While network search is the script's purpose, there is no explicit disclosure in this file that user-provided queries and retrieved data will be transmitted to an external service and echoed back, which is a privacy-relevant behavior for a code file.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.