Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
42f2109
feat: add script for migrating encrypted data to a new secret key
ogabrielluiz Dec 11, 2025
aec0a5f
test: add unit tests for secret key migration script
ogabrielluiz Dec 11, 2025
df74c88
docs: update SECURITY.md to include secret key rotation process and m…
ogabrielluiz Dec 11, 2025
dbf1bd5
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 11, 2025
6f35e0b
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 11, 2025
261f880
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 11, 2025
954201e
update component index
ogabrielluiz Dec 11, 2025
640435e
update component index
ogabrielluiz Dec 11, 2025
d7f3e47
Merge branch 'main' into secret-key-rotation-script
ogabrielluiz Dec 11, 2025
70b8168
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 11, 2025
e547133
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 11, 2025
77fd47a
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 11, 2025
d437f0a
refactor: use atomic transaction for secret key migration
ogabrielluiz Dec 11, 2025
c0bc6c1
fix: print new key for both generated and provided cases
ogabrielluiz Dec 11, 2025
ddafcb3
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 11, 2025
fa8853c
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 11, 2025
6b8cb2c
fix: improve error handling and test coverage for secret key migration
ogabrielluiz Dec 11, 2025
fab224f
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 11, 2025
31eef48
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 11, 2025
1cf9923
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 11, 2025
cd55924
docs: improve docstrings for secret key migration script
ogabrielluiz Dec 11, 2025
101a809
Merge branch 'main' into secret-key-rotation-script
ogabrielluiz Dec 12, 2025
71acd8a
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
c49f7d8
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
d11222a
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 12, 2025
d08f296
fix: update .gitignore to include new data files and user-specific cache
ogabrielluiz Dec 12, 2025
98b6521
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 12, 2025
8348d82
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 12, 2025
bfea02e
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 12, 2025
ddc30d7
fix: update usage instructions to include 'uv run' for secret key mig…
ogabrielluiz Dec 18, 2025
fec629c
Merge branch 'main' into secret-key-rotation-script
ogabrielluiz Dec 18, 2025
c19f1cb
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 18, 2025
feb16ce
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 18, 2025
710c10c
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 18, 2025
420502a
feat: add migration verification functionality and corresponding tests
ogabrielluiz Dec 18, 2025
8a8da57
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 18, 2025
6d8d4ed
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Dec 18, 2025
4df4ee8
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Dec 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ src/frontend/temp

news-aggregated.json
CLAUDE.md

.claude
member_servers.json
# Component index cache (user-specific)
**/.cache/lfx/

# data files used for desktop registration
data/user
data/user
76 changes: 75 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ We appreciate your efforts in helping us maintain a secure platform and look for
Langflow versions `1.6.0` through `1.6.3` have a critical bug where environment variables from `.env` files are not being read. This affects all deployments using environment variables for configuration, including security settings.

**Potential security impact:**

- Environment variables from `.env` files are not read.
- Security configurations like `AUTO_LOGIN=false` may not be applied, potentially allowing users to log in as the default superuser.
- Database credentials, API keys, and other sensitive configuration may not be loaded.
Expand Down Expand Up @@ -91,10 +92,12 @@ The `langflow superuser` CLI command can present a privilege escalation risk if
#### Security Measures

1. **Authentication Required in Production**

- When `LANGFLOW_AUTO_LOGIN=false`, superuser creation requires authentication
- Use `--auth-token` parameter with a valid superuser API key or JWT token

2. **Disable CLI Superuser Creation**

- Set `LANGFLOW_ENABLE_SUPERUSER_CLI=false` to disable the command entirely
- Strongly recommended for production environments

Expand All @@ -112,4 +115,75 @@ export LANGFLOW_SUPERUSER="<your-superuser-username>"
export LANGFLOW_SUPERUSER_PASSWORD="<your-superuser-password>"
export LANGFLOW_DATABASE_URL="<your-production-database-url>" # e.g. "postgresql+psycopg://langflow:[email protected]:5432/langflow"
export LANGFLOW_SECRET_KEY="your-strong-random-secret-key"
```
```

## Secret Key Rotation

The `LANGFLOW_SECRET_KEY` is used for:

- **JWT signing**: Access tokens, refresh tokens
- **Fernet encryption**: Stored credentials, encrypted variables, MCP auth settings

User passwords use bcrypt and are **not affected** by key rotation.

### Running the Migration

```bash
# Stop Langflow first, then:

# Preview what will be migrated
uv run python scripts/migrate_secret_key.py --dry-run

# Run the migration
uv run python scripts/migrate_secret_key.py

# Start Langflow
```

The script will:

1. Read your current secret key from the config directory
2. Generate a new secret key
3. Re-encrypt all sensitive data in the database (atomic transaction)
4. Backup the old key to `<config-dir>/secret_key.backup.<timestamp>`
5. Save the new key to `<config-dir>/secret_key`

If the database migration fails, no changes are made - the transaction rolls back and the key files remain untouched.

### Config Directory Location

The default config directory varies by platform:

- **macOS**: `~/Library/Caches/langflow`
- **Linux**: `~/.cache/langflow`
- **Windows**: `C:\Users\<user>\AppData\Local\langflow\langflow\Cache`

Override with `LANGFLOW_CONFIG_DIR` environment variable or `--config-dir` flag.

### CLI Options

```
uv run python scripts/migrate_secret_key.py --help

Options:
--dry-run Preview changes without modifying anything
--config-dir PATH Langflow config directory (default: platform-specific)
--database-url URL Database connection URL (default: sqlite in config dir)
--old-key KEY Current secret key (default: read from config dir)
--new-key KEY New secret key (default: auto-generated)
```

### What Gets Migrated

| Location | Data | Notes |
| ---------------------- | -------------------------------- | ---------------- |
| `user.store_api_key` | Langflow Store API key | Fernet encrypted |
| `variable.value` | All variable values | Fernet encrypted |
| `folder.auth_settings` | MCP oauth_client_secret, api_key | Fernet encrypted |

### What Gets Invalidated

Even with migration, these cannot be preserved:

- **Active sessions**: Users must log in again (JWT tokens are invalidated)

Loading
Loading