Back to Langflow

Block custom components

docs/docs/Deployment/deployment-block-custom-components.mdx

1.12.0.dev03.7 KB
Original Source

Custom components and the component code editor allow Langflow users to create and execute Python code in the Langflow runtime. While this freedom is a feature of Langflow, in some deployments you might want to block the creation of custom Langflow components to prevent arbitrary code execution.

To block custom component creation on a Langflow server, set the following environment variable:

bash
LANGFLOW_ALLOW_CUSTOM_COMPONENTS=false

When set to false, Langflow blocks creating custom components and changing code in the visual editor.

When unset or true, Langflow allows custom code. Existing non-Docker installations keep the default true behavior until you opt in to this restriction.

As of Langflow 1.11.x, official Langflow Docker images set LANGFLOW_ALLOW_CUSTOM_COMPONENTS=false at image build time, along with related component hardening flags.

This environment variable is a beta feature, and should not be your only safeguard in production environments.

In the event that Langflow could execute untrusted or LLM-generated code, run Langflow in an isolated and containerized execution environment.

Restrict custom component creation to superusers{#restrict-custom-components-to-superusers}

To restrict custom component creation to superusers while keeping built-in components functional for users, set the following environment variable:

bash
LANGFLOW_CUSTOM_COMPONENT_ADMIN_ONLY=true

When set to true, non-superusers can still view and use custom components in flows, but they cannot create new custom components or edit custom component code.

Configure a custom component allow-list

LANGFLOW_ALLOW_CUSTOM_COMPONENTS works together with optional paths that define which component templates the server loads, and which code hashes are trusted.

Directories listed in the LANGFLOW_COMPONENTS_PATH environment variable are loaded as custom components and merged into the server’s template set. When LANGFLOW_ALLOW_CUSTOM_COMPONENTS is set to false, the components in the LANGFLOW_COMPONENTS_PATH directory remain allowed.

To allow some components while blocking others, include the allowed custom components directory in LANGFLOW_COMPONENTS_PATH and set LANGFLOW_ALLOW_CUSTOM_COMPONENTS to false.

LANGFLOW_COMPONENTS_INDEX_PATH points to a prebuilt component index JSON file at a local path or http:// / https:// URL. This environment variable replaces the default index bundled with the lfx package. It does not import Python modules from a directory on disk. To allow-list custom components, use the LANGFLOW_COMPONENTS_PATH environment variable.

If both environment variables are set, Langflow builds one combined set of components from the custom index and from LANGFLOW_COMPONENTS_PATH. If the same component category name exists in both, LANGFLOW_COMPONENTS_PATH replaces that whole category from the custom index.

Disable the allow-list bypass

The allow-list behavior above assumes the admin controls which env vars are set at startup. In deployments where that assumption doesn't hold, set:

bash
LANGFLOW_ALLOW_COMPONENTS_PATHS_OVERRIDE=false

When this is false and LANGFLOW_ALLOW_CUSTOM_COMPONENTS=false, components contributed by LANGFLOW_COMPONENTS_PATH and LANGFLOW_COMPONENTS_INDEX_PATH are ignored and no longer bypass the block.

Default is true, which preserves existing behavior. The setting has no effect while LANGFLOW_ALLOW_CUSTOM_COMPONENTS=true, since nothing is being bypassed.

For more information, see: