{
  "hunt": {
    "meta": {
      "tlp": "clear",
      "hunt": {
        "handoff": "promote-to-detection",
        "trigger": "intel-report",
        "methodology": "model-assisted",
        "applicability": "campaign-specific",
        "justification": "Langflow RCEs are unauthenticated and offer immediate access to the compute context. Given the frequent use of Langflow in cloud-native AI pipelines, these hosts often have powerful identity tokens that can be used to move laterally into the cloud control plane."
      },
      "name": "Langflow RCE and Cloud Metadata Discovery",
      "type": "investigation",
      "labels": [
        "hunt",
        "attack.t1190",
        "attack.t1552.005",
        "credential access",
        "execution",
        "initial access",
        "lateral movement",
        "persistence"
      ],
      "series": {
        "slug": "metasploit-wrap-up-langflow-mongodb-and-more",
        "index": 1,
        "title": "Metasploit Wrap Up: Langflow, MongoDB, and More",
        "total": 2
      },
      "related": [
        {
          "hunt": "langflow-post-exploitation-python-behavior",
          "reason": "This hunt focuses on the network-level initial access and discovery; the internal execution of Python and child processes is handled in a separate execution-focused hunt.",
          "relation": "out-of-scope-alternative"
        }
      ],
      "targets": {
        "web": {
          "name": "Web server / proxy logs",
          "category": "siem",
          "telemetry": [
            "network"
          ]
        },
        "hunter": {
          "name": "Hunt agent",
          "agent": true
        },
        "analyst": {
          "name": "Tier-2 analyst",
          "role": "analyst"
        },
        "endpoint": {
          "name": "Endpoint telemetry (hb_ surfaces)",
          "category": "endpoint",
          "telemetry": [
            "endpoint"
          ]
        }
      },
      "analysis": "A simple detection rule might trigger on any metadata access, but this hunt correlates the presence of vulnerable AI software with specific unauthenticated HTTP paths and applies a baseline to ignore frequent internal scanners.",
      "coverage": [
        {
          "stage": "initial-access-langflow-exploit",
          "steps": [
            "identify-langflow-installations",
            "detect-suspicious-api-calls"
          ],
          "status": "covered"
        },
        {
          "stage": "lateral-movement-cloud-metadata",
          "steps": [
            "detect-metadata-access"
          ],
          "status": "covered"
        },
        {
          "stage": "execution-python-rce",
          "reason": "Belongs to another part of the 'Metasploit Wrap Up: Langflow, MongoDB, and More' series.",
          "status": "out_of_scope"
        },
        {
          "stage": "credential-access-secrets-theft",
          "reason": "Belongs to another part of the 'Metasploit Wrap Up: Langflow, MongoDB, and More' series.",
          "status": "out_of_scope"
        },
        {
          "stage": "persistence-database-modification",
          "reason": "Belongs to another part of the 'Metasploit Wrap Up: Langflow, MongoDB, and More' series.",
          "status": "out_of_scope"
        }
      ],
      "scenario": {
        "stages": [
          {
            "name": "Exploitation of Langflow Endpoints",
            "slug": "initial-access-langflow-exploit",
            "tactic": "initial-access",
            "techniques": [
              "T1190"
            ],
            "observables": [
              "/api/v1/build/",
              "/api/v1/validate",
              "eval_custom_component_code"
            ]
          },
          {
            "name": "Python Remote Code Execution",
            "slug": "execution-python-rce",
            "tactic": "execution",
            "techniques": [
              "T1059.006"
            ],
            "observables": [
              "Python child processes spawning shells",
              "langflow process executing arbitrary Python strings",
              "Meterpreter python payload execution"
            ]
          },
          {
            "name": "Credential and Secret Access",
            "slug": "credential-access-secrets-theft",
            "tactic": "credential-access",
            "techniques": [
              "T1552.001",
              "T1555"
            ],
            "observables": [
              "Accessing Langflow database files",
              "Reading application secrets from database tables",
              "Retrieval of SSO email addresses and phone numbers"
            ]
          },
          {
            "name": "Cloud Metadata Service Abuse",
            "slug": "lateral-movement-cloud-metadata",
            "tactic": "lateral-movement",
            "techniques": [
              "T1552.005"
            ],
            "observables": [
              "HTTP requests to 169.254.169.254",
              "Abuse of cloud metadata endpoints for tenant lateral movement"
            ]
          },
          {
            "name": "Persistence via Database Modification",
            "slug": "persistence-database-modification",
            "tactic": "persistence",
            "techniques": [
              "T1505.003"
            ],
            "observables": [
              "Modification of tool_code in the Langflow database",
              "SQL updates to public flows to re-execute attacker code"
            ]
          }
        ],
        "summary": "This article describes multiple Metasploit modules targeting vulnerabilities in Langflow and OpenCTI, providing unauthenticated remote code execution capabilities. In Langflow environments, successful exploitation allows attackers to execute arbitrary Python code, access application secrets, pivot to cloud metadata services, and maintain persistence by injecting malicious code into the application's database."
      },
      "severity": "high",
      "rationale": "Begin by searching the software inventory for Langflow. If the inventory is stale, run the HTTP queries across all application server subnets.",
      "guardrails": {
        "claims": "no_unsupported",
        "evidence": "citation_required",
        "telemetry": "untrusted",
        "missing_data": "not_benign"
      },
      "hypothesis": "An attacker is exploiting unauthenticated remote code execution vulnerabilities in Langflow AI endpoints and subsequently querying the cloud metadata service to harvest identity tokens for lateral movement.",
      "parameters": {
        "metadata_ip": {
          "type": "ip",
          "default": "169.254.169.254",
          "description": "The common cloud metadata service IP address."
        },
        "scope_hosts": {
          "type": "list[host]",
          "default": [],
          "description": "Optional list of hosts to narrow the hunt; leave empty to scan the full estate."
        },
        "lookback_days": {
          "type": "number",
          "default": "14",
          "description": "Days of historical HTTP activity to examine."
        }
      },
      "provenance": {
        "authors": [
          {
            "org": "huntbase.io",
            "name": "Huntbase hunt generation"
          }
        ],
        "generated": {
          "by": "huntbase-hunt-generation",
          "from": "https://www.rapid7.com/blog/post/pt-metasploit-wrap-up-langflow-mongodb-and-more",
          "gates": [
            "dry-run",
            "lint",
            "critic"
          ],
          "model": "hb_google/gemini-3-flash-preview"
        }
      },
      "references": [
        {
          "url": "https://www.rapid7.com/blog/post/pt-metasploit-wrap-up-langflow-mongodb-and-more",
          "name": "Rapid7 \u2014 Metasploit Wrap Up: Langflow, MongoDB, and More"
        }
      ],
      "blind_spots": [
        {
          "id": "http-payload-visibility",
          "risk": "An analyst can see that the endpoint was called but cannot distinguish between a legitimate workflow build and a malicious RCE payload without the body content.",
          "stage": "initial-access-langflow-exploit",
          "question": "What Python code was submitted to the validate or build endpoints?",
          "requires": "TLS decryption at the proxy or application-level logging of HTTP request bodies"
        },
        {
          "id": "metadata-response-status",
          "risk": "A request to 169.254.169.254 might be blocked by IMDSv2 or local firewall rules, but hb_http_activity may only show the attempt.",
          "stage": "lateral-movement-cloud-metadata",
          "question": "Was the metadata request successful and were credentials actually exfiltrated?",
          "requires": "Cloud provider instance audit logs or IMDSv2 configuration state"
        }
      ]
    },
    "name": "Langflow RCE and Cloud Metadata Discovery",
    "description": "This hunt identifies Langflow installations within the estate and monitors for exploitation attempts against the build and validate API endpoints. It correlates these suspicious HTTP requests with outbound traffic to the cloud metadata service (169.254.169.254), a common post-exploitation step used to pivot from a compromised container or instance into the cloud control plane. The hunt uses a stack-counting baseline to isolate rare external actors hitting these sensitive AI orchestration paths."
  },
  "nodes": [
    {
      "id": "hypothesis",
      "type": "hypothesis",
      "label": "Hypothesis",
      "config": {
        "tags": [],
        "series": {
          "slug": "metasploit-wrap-up-langflow-mongodb-and-more",
          "index": 1,
          "title": "Metasploit Wrap Up: Langflow, MongoDB, and More",
          "total": 2
        },
        "coverage": [
          {
            "stage": "initial-access-langflow-exploit",
            "steps": [
              "identify-langflow-installations",
              "detect-suspicious-api-calls"
            ],
            "status": "covered"
          },
          {
            "stage": "lateral-movement-cloud-metadata",
            "steps": [
              "detect-metadata-access"
            ],
            "status": "covered"
          },
          {
            "stage": "execution-python-rce",
            "reason": "Belongs to another part of the 'Metasploit Wrap Up: Langflow, MongoDB, and More' series.",
            "status": "out_of_scope"
          },
          {
            "stage": "credential-access-secrets-theft",
            "reason": "Belongs to another part of the 'Metasploit Wrap Up: Langflow, MongoDB, and More' series.",
            "status": "out_of_scope"
          },
          {
            "stage": "persistence-database-modification",
            "reason": "Belongs to another part of the 'Metasploit Wrap Up: Langflow, MongoDB, and More' series.",
            "status": "out_of_scope"
          }
        ],
        "rationale": "An attacker is exploiting unauthenticated remote code execution vulnerabilities in Langflow AI endpoints and subsequently querying the cloud metadata service to harvest identity tokens for lateral movement.",
        "blind_spots": [
          {
            "id": "http-payload-visibility",
            "risk": "An analyst can see that the endpoint was called but cannot distinguish between a legitimate workflow build and a malicious RCE payload without the body content.",
            "stage": "initial-access-langflow-exploit",
            "question": "What Python code was submitted to the validate or build endpoints?",
            "requires": "TLS decryption at the proxy or application-level logging of HTTP request bodies"
          },
          {
            "id": "metadata-response-status",
            "risk": "A request to 169.254.169.254 might be blocked by IMDSv2 or local firewall rules, but hb_http_activity may only show the attempt.",
            "stage": "lateral-movement-cloud-metadata",
            "question": "Was the metadata request successful and were credentials actually exfiltrated?",
            "requires": "Cloud provider instance audit logs or IMDSv2 configuration state"
          }
        ],
        "scoping_notes": "Begin by searching the software inventory for Langflow. If the inventory is stale, run the HTTP queries across all application server subnets.",
        "beyond_detection": "A simple detection rule might trigger on any metadata access, but this hunt correlates the presence of vulnerable AI software with specific unauthenticated HTTP paths and applies a baseline to ignore frequent internal scanners."
      }
    },
    {
      "id": "identify-langflow-installations",
      "type": "query",
      "label": "Identify Langflow Installations",
      "config": {
        "dsl": "sqlite",
        "role": "scoping",
        "source": "endpoint",
        "content": "SELECT device_hostname, package_name, package_version, install_path FROM hb_software_inventory WHERE LOWER(package_name) LIKE '%langflow%'",
        "surface": "hb_software_inventory",
        "description": "Locate hosts running Langflow to establish the hunt scope.",
        "expected_signal": "A list of hosts and their Langflow versions. Silence means the product is not recorded in the package inventory."
      },
      "parents": [
        {
          "id": "hypothesis"
        }
      ],
      "primitive_config": {
        "dsl": "sqlite",
        "role": "scoping",
        "label": "Identify Langflow Installations",
        "reads": [
          "device_hostname",
          "install_path",
          "package_name",
          "package_version"
        ],
        "source": "hb_software_inventory",
        "target": "endpoint",
        "content": "SELECT device_hostname, package_name, package_version, install_path FROM hb_software_inventory WHERE LOWER(package_name) LIKE '%langflow%'",
        "silence": "not_evidence_of_absence",
        "expected": "A list of hosts and their Langflow versions. Silence means the product is not recorded in the package inventory.",
        "verified": "dry-run",
        "verified_at": "2026-11-18"
      }
    },
    {
      "id": "detect-suspicious-api-calls",
      "type": "query",
      "label": "Detect Suspicious API Calls",
      "config": {
        "dsl": "sqlite",
        "role": "detection-candidate",
        "source": "web",
        "content": "SELECT device_hostname, src_endpoint_ip, url_path, status_code, user_agent, time FROM hb_http_activity WHERE (LOWER(url_path) LIKE '%/api/v1/build%' OR LOWER(url_path) LIKE '%/api/v1/validate%' OR LOWER(url_path) LIKE '%eval_custom_component_code%') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days')",
        "surface": "hb_http_activity",
        "description": "Find HTTP requests to the Langflow endpoints targeted by the Metasploit modules.",
        "expected_signal": "Requests to sensitive build or validate endpoints. Frequent 200 OK responses from unusual source IPs indicate potential successful exploitation."
      },
      "parents": [
        {
          "id": "identify-langflow-installations"
        }
      ],
      "primitive_config": {
        "dsl": "sqlite",
        "role": "detection-candidate",
        "label": "Detect Suspicious API Calls",
        "reads": [
          "device_hostname",
          "src_endpoint_ip",
          "status_code",
          "time",
          "url_path",
          "user_agent"
        ],
        "source": "hb_http_activity",
        "target": "web",
        "content": "SELECT device_hostname, src_endpoint_ip, url_path, status_code, user_agent, time FROM hb_http_activity WHERE (LOWER(url_path) LIKE '%/api/v1/build%' OR LOWER(url_path) LIKE '%/api/v1/validate%' OR LOWER(url_path) LIKE '%eval_custom_component_code%') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days')",
        "silence": "not_evidence_of_absence",
        "expected": "Requests to sensitive build or validate endpoints. Frequent 200 OK responses from unusual source IPs indicate potential successful exploitation.",
        "verified": "dry-run",
        "verified_at": "2026-11-18"
      }
    },
    {
      "id": "detect-metadata-access",
      "type": "query",
      "label": "Detect Metadata Access",
      "config": {
        "dsl": "sqlite",
        "role": "enrichment",
        "source": "web",
        "content": "SELECT device_hostname, src_endpoint_ip, url_full, user_agent, time FROM hb_http_activity WHERE (url_hostname = '{{metadata_ip}}' OR dst_endpoint_ip = '{{metadata_ip}}') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days')",
        "surface": "hb_http_activity",
        "description": "Identify attempts to reach the cloud metadata service from the same hosts.",
        "expected_signal": "Outbound HTTP requests to the metadata service. This is anomalous for standard AI workflow builder operations and suggests credential theft."
      },
      "parents": [
        {
          "id": "identify-langflow-installations"
        }
      ],
      "primitive_config": {
        "dsl": "sqlite",
        "role": "enrichment",
        "label": "Detect Metadata Access",
        "reads": [
          "device_hostname",
          "dst_endpoint_ip",
          "src_endpoint_ip",
          "time",
          "url_full",
          "url_hostname",
          "user_agent"
        ],
        "source": "hb_http_activity",
        "target": "web",
        "content": "SELECT device_hostname, src_endpoint_ip, url_full, user_agent, time FROM hb_http_activity WHERE (url_hostname = '{{metadata_ip}}' OR dst_endpoint_ip = '{{metadata_ip}}') AND ('{{scope_hosts}}' = '' OR instr(',' || '{{scope_hosts}}' || ',', ',' || device_hostname || ',') > 0) AND time >= datetime('now', '-{{lookback_days}} days')",
        "silence": "not_evidence_of_absence",
        "expected": "Outbound HTTP requests to the metadata service. This is anomalous for standard AI workflow builder operations and suggests credential theft.",
        "verified": "dry-run",
        "verified_at": "2026-11-18"
      }
    },
    {
      "id": "baseline-external-traffic",
      "type": "query",
      "label": "Baseline External Traffic",
      "config": {
        "dsl": "sqlite",
        "role": "baseline",
        "source": "web",
        "content": "SELECT src_endpoint_ip, COUNT(DISTINCT device_hostname) AS host_count, COUNT(*) AS request_count, MIN(time) AS first_seen FROM hb_http_activity WHERE (LOWER(url_path) LIKE '%/api/v1/build%' OR LOWER(url_path) LIKE '%/api/v1/validate%') AND time >= datetime('now', '-{{lookback_days}} days') GROUP BY src_endpoint_ip HAVING host_count <= 3 ORDER BY host_count ASC",
        "surface": "hb_http_activity",
        "description": "Stack-count source IPs to isolate rare external actors hitting Langflow endpoints.",
        "expected_signal": "A list of source IPs hitting Langflow on 3 or fewer hosts. High-volume, fleet-wide traffic usually indicates internal health checks or automated scanners."
      },
      "parents": [
        {
          "id": "identify-langflow-installations"
        }
      ],
      "primitive_config": {
        "dsl": "sqlite",
        "role": "baseline",
        "label": "Baseline External Traffic",
        "reads": [
          "device_hostname",
          "src_endpoint_ip",
          "time",
          "url_path"
        ],
        "source": "hb_http_activity",
        "target": "web",
        "content": "SELECT src_endpoint_ip, COUNT(DISTINCT device_hostname) AS host_count, COUNT(*) AS request_count, MIN(time) AS first_seen FROM hb_http_activity WHERE (LOWER(url_path) LIKE '%/api/v1/build%' OR LOWER(url_path) LIKE '%/api/v1/validate%') AND time >= datetime('now', '-{{lookback_days}} days') GROUP BY src_endpoint_ip HAVING host_count <= 3 ORDER BY host_count ASC",
        "silence": "not_evidence_of_absence",
        "baseline": {
          "window": "{{lookback_days}}d",
          "compare": "first_seen"
        },
        "expected": "A list of source IPs hitting Langflow on 3 or fewer hosts. High-volume, fleet-wide traffic usually indicates internal health checks or automated scanners.",
        "verified": "dry-run",
        "prevalence": {
          "by": "device_hostname",
          "key": [
            "src_endpoint_ip"
          ],
          "rare_below": 3
        },
        "verified_at": "2026-11-18"
      }
    },
    {
      "id": "triage-langflow-intrusion",
      "type": "analytic",
      "label": "Triage Langflow Intrusion",
      "config": {
        "cite": "required",
        "tools": [
          "endpoint",
          "web"
        ],
        "context": [
          "identify-langflow-installations",
          "detect-suspicious-api-calls",
          "detect-metadata-access",
          "baseline-external-traffic"
        ],
        "objective": "Determine if any Langflow host is being actively exploited and whether the actor is attempting to steal cloud credentials through the metadata service.",
        "description": "Analyze the HTTP traffic patterns to determine if an intrusion has occurred.",
        "max_iterations": 5,
        "expected_signal": "A per-host verdict of malicious, suspicious, or benign.",
        "success_criteria": "A per-host verdict citing rows from both the API and metadata queries."
      },
      "parents": [
        {
          "id": "detect-suspicious-api-calls",
          "kind": "merge"
        },
        {
          "id": "detect-metadata-access",
          "kind": "merge"
        },
        {
          "id": "baseline-external-traffic",
          "kind": "merge"
        }
      ]
    },
    {
      "id": "route-on-verdict",
      "type": "checkpoint",
      "label": "Route on Verdict",
      "config": {
        "fuzzy": true,
        "judge": "hunter",
        "question": "the triage-langflow-intrusion verdict is malicious for at least one host",
        "condition": "the triage-langflow-intrusion verdict is malicious for at least one host",
        "blind_spot": "http-payload-visibility",
        "confidence": "high",
        "description": "Direct the hunt based on the agent's confidence in the detected activity.",
        "checkpoint_type": "mandatory"
      },
      "parents": [
        {
          "id": "triage-langflow-intrusion"
        }
      ]
    },
    {
      "id": "isolate-host",
      "type": "action",
      "label": "Isolate Host",
      "config": {
        "target": "endpoint",
        "description": "Prevent further credential exfiltration by containing the compromised host.",
        "instructions": "Isolate the compromised Langflow endpoint from the network and revoke any cloud session tokens associated with its instance identity.",
        "action_approval": "required"
      },
      "parents": [
        {
          "id": "route-on-verdict",
          "branch": "on_supports"
        }
      ]
    },
    {
      "id": "analyst-remediation",
      "type": "task",
      "label": "Analyst Remediation",
      "config": {
        "assignee": "analyst",
        "description": "Verify the extent of the breach and identify any stolen secrets.",
        "instructions": "Review the full HTTP transaction logs if available. Check the cloud provider audit logs for unusual API calls using the identity of the isolated instance. Rotate any credentials stored in Langflow's environment variables."
      },
      "parents": [
        {
          "id": "route-on-verdict",
          "branch": "default"
        },
        {
          "id": "route-on-verdict",
          "branch": "on_unavailable"
        },
        {
          "id": "isolate-host"
        }
      ]
    },
    {
      "id": "close-out",
      "type": "task",
      "label": "Close-out",
      "config": {
        "assignee": "analyst",
        "description": "Record the hunt results and finalize documentation.",
        "instructions": "Document the number of Langflow instances identified and the status of their patches. Record any successful exploitation chains for future detection tuning."
      },
      "parents": [
        {
          "id": "route-on-verdict",
          "branch": "on_refutes"
        },
        {
          "id": "analyst-remediation"
        }
      ]
    }
  ]
}