Skip to content

Commit 19579ab

Browse files
authored
docs: security hardening for untrusted multitenancy deployments (#14061)
* docs: workflow api schema breaking change * docs: docker image defaults changes for security * docs: untrusted multitenant settings * docs: lessen code font padding * docs: fix traces link * docs: identify typo * docs: peer review
1 parent 4323f16 commit 19579ab

9 files changed

Lines changed: 212 additions & 95 deletions

File tree

docker_example/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Running LangFlow with Docker
1+
# Run Langflow with Docker
22

3-
This guide will help you get LangFlow up and running using Docker and Docker Compose.
3+
This guide will help you get Langflow up and running using Docker and Docker Compose.
44

55
## Prerequisites
66

@@ -9,7 +9,7 @@ This guide will help you get LangFlow up and running using Docker and Docker Com
99

1010
## Steps
1111

12-
1. Clone the LangFlow repository:
12+
1. Clone the Langflow repository:
1313

1414
```sh
1515
git clone https://github.com/langflow-ai/langflow.git
@@ -21,12 +21,13 @@ This guide will help you get LangFlow up and running using Docker and Docker Com
2121
cd langflow/docker_example
2222
```
2323

24-
3. Create a `.env` file with the LangFlow admin password:
24+
3. Create a `.env` file with the Langflow admin password set:
2525

2626
```sh
27-
LANGFLOW_SUPERUSER_PASSWORD=replace-with-a-strong-password
27+
LANGFLOW_SUPERUSER_PASSWORD=SUPERUSER_PASSWORD
2828
```
2929

30+
Replace `SUPERUSER_PASSWORD` with a strong password for the Langflow superuser.
3031
The default admin username is `langflow`.
3132

3233
4. Run the Docker Compose file:
@@ -35,27 +36,27 @@ This guide will help you get LangFlow up and running using Docker and Docker Com
3536
docker compose up
3637
```
3738

38-
LangFlow will now be accessible at [http://localhost:7860/](http://localhost:7860/).
39+
Langflow will now be accessible at [http://localhost:7860/](http://localhost:7860/).
3940

40-
## Docker Compose Configuration
41+
## Configure Docker Compose
4142

4243
The Docker Compose configuration spins up two services: `langflow` and `postgres`.
4344

44-
### LangFlow Service
45+
### Langflow service
4546

4647
The `langflow` service uses the `langflowai/langflow:latest` Docker image and exposes port 7860. It depends on the `postgres` service.
4748

4849
Environment variables:
4950

5051
- `LANGFLOW_DATABASE_URL`: The connection string for the PostgreSQL database.
5152
- `LANGFLOW_SUPERUSER_PASSWORD`: The initial admin password. This value is required in `.env`.
52-
- `LANGFLOW_CONFIG_DIR`: The directory where LangFlow stores logs, file storage, monitor data, and secret keys.
53+
- `LANGFLOW_CONFIG_DIR`: The directory where Langflow stores logs, file storage, monitor data, and secret keys.
5354

5455
Volumes:
5556

5657
- `langflow-data`: This volume is mapped to `/app/langflow` in the container.
5758

58-
### PostgreSQL Service
59+
### PostgreSQL service
5960

6061
The `postgres` service uses the `postgres:16-trixie` Docker image and exposes port 5432. The image is pinned to a specific Debian base (`trixie`, Debian 13) so the `postgres:16` tag cannot silently roll its underlying OS, which would otherwise produce a glibc collation version mismatch warning on existing data volumes.
6162

@@ -89,6 +90,6 @@ docker compose exec postgres \
8990

9091
Fresh installs are unaffected.
9192

92-
## Switching to a Specific LangFlow Version
93+
## Switching to a specific Langflow version
9394

94-
If you want to use a specific version of LangFlow, you can modify the `image` field under the `langflow` service in the Docker Compose file. For example, to use version 1.0-alpha, change `langflowai/langflow:latest` to `langflowai/langflow:1.0-alpha`.
95+
If you want to use a specific version of Langflow, you can modify the `image` field under the `langflow` service in the Docker Compose file. For example, to use version 1.0-alpha, change `langflowai/langflow:latest` to `langflowai/langflow:1.0-alpha`.

docs/css/tokens.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--ifm-navbar-padding-vertical: 0;
55
--ifm-global-radius: 10px;
66
--ifm-code-border-radius: 4px;
7-
--ifm-code-padding-horizontal: 0.4em;
7+
--ifm-code-padding-horizontal: 0.2em;
88
--ifm-navbar-item-padding-vertical: 0;
99
--ifm-font-family-base: "Geist", Inter, -apple-system, BlinkMacSystemFont,
1010
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI emoji";

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ LANGFLOW_ALLOW_CUSTOM_COMPONENTS=false
1515
When set to `false`, Langflow blocks creating custom components and changing code in the visual editor.
1616

1717
When unset or `true`, Langflow allows custom code.
18-
Existing Langflow installations will keep the default `true` behavior until you opt in to this restriction.
18+
Existing non-Docker installations keep the default `true` behavior until you opt in to this restriction.
19+
20+
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](/api-keys-and-authentication#multi-tenant-component-hardening) flags.
1921

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

docs/docs/Deployment/deployment-docker.mdx

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,25 @@ This guide demonstrates several ways to run Langflow with [Docker](https://docs.
1313

1414
* [Quickstart](#quickstart): Start a Langflow container with default values.
1515
* [Use Docker Compose](#docker-compose): Run Langflow with a persistent PostgreSQL database and configurable environment variables.
16-
* [Customize the Docker image](#customize): Package a flow or add your own code into a custom image built on top of the official Langflow image.
16+
* [Customize the Docker Compose file](#customize): Package a flow or add your own code into a custom image built on top of the official Langflow image.
1717
* [Build and run the Docker image from source](#build-from-source): Build a Docker image from a local clone of the repo, or start a full development environment with hot reload on both frontend and backend.
1818
* [Upgrade the Langflow Docker image](#upgrade-the-langflow-docker-image): Upgrade to a newer image without losing your database or flows.
19+
* [Docker image security defaults](#docker-image-security-defaults): Hardened environment variables baked into published images, and how to override them for local use.
1920

2021
## Quickstart {#quickstart}
2122

2223
With Docker installed and running on your system, run the following command:
2324

2425
```shell
25-
docker run -p 7860:7860 -e LANGFLOW_AUTO_LOGIN=true langflowai/langflow:latest
26+
docker run -p 7860:7860 \
27+
-e LANGFLOW_AUTO_LOGIN=true \
28+
-e LANGFLOW_SUPERUSER_PASSWORD=SUPERUSER_PASSWORD \
29+
langflowai/langflow:latest
2630
```
2731

32+
Replace `SUPERUSER_PASSWORD` with a strong password for the Langflow superuser.
33+
As of Langflow 1.11.x, images include [security defaults](#docker-image-security-defaults) that you may need to override for local workflows.
34+
2835
Then, access Langflow at `http://localhost:7860/`.
2936

3037
This starts a pre-built Docker image with automatic login enabled for local development.
@@ -75,9 +82,11 @@ Configure a container's database credentials using a `.env` file.
7582
# Langflow configuration
7683
LANGFLOW_DATABASE_URL=postgresql://myuser:mypassword@postgres:5432/langflow
7784
LANGFLOW_CONFIG_DIR=/app/langflow
78-
LANGFLOW_SUPERUSER_PASSWORD=replace-with-a-strong-password
85+
LANGFLOW_SUPERUSER_PASSWORD=SUPERUSER_PASSWORD
7986
```
8087

88+
Replace `SUPERUSER_PASSWORD` with a strong password for the Langflow superuser.
89+
8190
2. Edit `docker-compose.yml` to replace the hardcoded values with variable references for both the `langflow` and `postgres` services:
8291

8392
```yaml
@@ -189,7 +198,6 @@ This example replaces the built-in **Message History** component, but the same p
189198
docker run -p 7860:7860 -e LANGFLOW_AUTO_LOGIN=true myuser/langflow-custom:1.0.0
190199
```
191200

192-
193201
## Build and run the Docker image from source {#build-from-source}
194202

195203
:::tip
@@ -212,10 +220,17 @@ This builds `docker/build_and_push.Dockerfile` and tags the result `langflow:<ve
212220
To run the image after building, run:
213221

214222
```shell
215-
docker run -p 7860:7860 langflow:<version>
223+
docker run -p 7860:7860 \
224+
-e LANGFLOW_SUPERUSER_PASSWORD=SUPERUSER_PASSWORD \
225+
langflow:VERSION
216226
```
217227

218-
Replace `<version>` with the version in `pyproject.toml` at the repo root.
228+
Replace the following:
229+
230+
* `SUPERUSER_PASSWORD`: a strong password for the Langflow superuser
231+
* `VERSION`: the version in `pyproject.toml` at the repo root
232+
233+
The image sets `LANGFLOW_AUTO_LOGIN=false` and the [component hardening defaults](#docker-image-security-defaults), so a superuser password is required unless you set `LANGFLOW_AUTO_LOGIN=true`.
219234

220235
To build only the LFX executor CLI image instead of the full Langflow application, run:
221236

@@ -349,12 +364,50 @@ For example, this Docker Compose file uses a bind mount for Langflow data (`./la
349364
With `docker run`, use the same volume mount and the new image tag:
350365

351366
```bash
352-
docker run -p 7860:7860 -v langflow-data:/app/langflow -e LANGFLOW_SUPERUSER_PASSWORD=replace-with-a-strong-password langflowai/langflow:1.11.0
367+
docker run -p 7860:7860 \
368+
-v langflow-data:/app/langflow \
369+
-e LANGFLOW_SUPERUSER_PASSWORD=SUPERUSER_PASSWORD \
370+
langflowai/langflow:1.11.0
353371
```
354372

373+
Replace `SUPERUSER_PASSWORD` with a strong password for the Langflow superuser.
374+
355375
This approach keeps the persistent volumes separate from the Langflow container, so you can upgrade the Langflow application without losing data.
356376

357377
If you need to upgrade to a custom image based on a Langflow release, such as to add `uv` in `1.8.0`, first build a derived image from the official image, and then follow the same steps above.
358378
Set the custom image in your compose file or `docker run`, and then pull and restart.
359379

360380
For a minimal Dockerfile that adds `uv` to the 1.8.0 image, see the [release notes](/release-notes) ("Docker image no longer includes uv or uvx").
381+
382+
## Docker image security defaults {#docker-image-security-defaults}
383+
384+
As of Langflow 1.11.x, official Langflow Docker images set `LANGFLOW_ALLOW_CUSTOM_COMPONENTS=false` at image build time, and include stricter defaults for the following environment variables:
385+
386+
| Variable | Image value | Application default (pip / local) |
387+
|----------|-------------|-----------------------------------|
388+
| `LANGFLOW_AUTO_LOGIN` | `false` | `true` |
389+
| `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` | `false` | `true` |
390+
| `LANGFLOW_BLOCK_CODE_INTERPRETER_COMPONENTS` | `true` | `false` |
391+
| `LANGFLOW_RESTRICT_LOCAL_FILE_ACCESS` | `true` | `false` |
392+
| `LANGFLOW_MCP_SERVER_DOCKER_HARDENING` | `true` (main `langflowai/langflow` image only) | `false` |
393+
394+
These image values match the [component hardening for untrusted users](/api-keys-and-authentication#multi-tenant-component-hardening) recommendation.
395+
They apply whether you use `docker run`, Docker Compose, or Kubernetes with the published image, unless you override them.
396+
397+
The image sets `LANGFLOW_AUTO_LOGIN=false`, so you must set `LANGFLOW_SUPERUSER_PASSWORD` (and optionally, `LANGFLOW_SUPERUSER`) unless you explicitly set `LANGFLOW_AUTO_LOGIN=true`.
398+
399+
To disable the stricter defaults and use custom components, built-in code-execution components, or absolute local file paths, override the image defaults:
400+
401+
```bash
402+
docker run -p 7860:7860 \
403+
-e LANGFLOW_AUTO_LOGIN=true \
404+
-e LANGFLOW_ALLOW_CUSTOM_COMPONENTS=true \
405+
-e LANGFLOW_BLOCK_CODE_INTERPRETER_COMPONENTS=false \
406+
-e LANGFLOW_RESTRICT_LOCAL_FILE_ACCESS=false \
407+
-e LANGFLOW_MCP_SERVER_DOCKER_HARDENING=false \
408+
langflowai/langflow:latest
409+
```
410+
411+
In Docker Compose, add the same keys under `services.langflow.environment`.
412+
413+
For more information, see [Component hardening for untrusted users](/api-keys-and-authentication#multi-tenant-component-hardening) and [Block custom components](/deployment-block-custom-components).

0 commit comments

Comments
 (0)