Files
seaweedfs/weed/command/scaffold/security.toml
T
397a156104 security: a fips.mode setting that Go checks against GODEBUG and the Rust binaries apply to TLS (#13029)
* util: refuse to start when fips.mode in security.toml disagrees with GODEBUG

security.toml gains [fips] mode = "off" | "on" | "strict", also settable
as WEED_FIPS_MODE: one setting that states the FIPS 140-3 mode of every
process in a deployment, so the Rust binaries, which do not run on the Go
runtime, can follow it. Go processes keep taking their behaviour from
GODEBUG=fips140 and now check it against the setting:
LoadSecurityConfiguration and `weed worker` exit when "off" runs without
fips140=off, "on" without fips140=on, or "strict" without fips140=only,
naming the setting and the GODEBUG value it needs. An unknown value is
refused; unset or empty changes nothing.

Refs #12839

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* rust: fips.mode with FIPS-mode TLS in weed-volume, weed-worker and weed-vector

seaweed-common gains a fips module: FipsMode resolved from fips.mode in
the security.toml a binary uses, with WEED_FIPS_MODE over it. Each binary
resolves it once at startup, logs it and installs the matching rustls
provider as the process default, refusing to start on an unknown value or
when another provider was installed first.

Under "on" and "strict" the provider is aws-lc-rs filtered to the lists
Go's crypto/tls applies in FIPS mode: TLS 1.3 AES-GCM suites and TLS 1.2
ECDHE AES-GCM suites (no ChaCha20-Poly1305), X25519MLKEM768,
SecP256r1MLKEM768, P-256 and P-384 (no plain X25519), Go's ten signature
schemes (no ML-DSA). Configurations SeaweedFS builds require the Extended
Master Secret in that mode, and the volume server refuses a non-FIPS suite
in tls.cipher_suites instead of falling back. sw-client installs the same
provider instead of ring. Unset or "off" keeps aws-lc-rs's default
provider unchanged.

This is behavioural parity only: the provider still runs on the
non-validated aws-lc-rs build.

Refs #12839

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* util: refuse a fips.mode that is not a string

viper's GetString turns an array or a table into "", so mode = ["strict"]
under [fips] skipped the GODEBUG check while the Rust binaries refused the
same file. RequireFipsMode now reads the raw value (ViperProxy.Get, under
its lock) and exits when it is not a string, naming its source; an absent
or empty value still means unset, and WEED_FIPS_MODE still wins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* rust: read fips.mode with the parser that reads the JWT keys

seaweed_common::fips::resolve parsed security.toml with the toml crate,
while the volume server reads the rest of the file with its own lenient
loader. A file with [fips] mode = "on" beside an unquoted value the loader
accepts resolved to off and logged "fips.mode unset", although the JWT
keys from the same file were applied. Each binary now reads fips.mode
with the loader it uses for everything else and hands the value to
resolve: the volume server through its line parser, the worker and vector
engine through their parsed Security table, which already refuses a file
that is not TOML. A security.toml the volume server finds but cannot read
stops startup. A missing setting is still off, and WEED_FIPS_MODE still
wins. seaweed-common no longer depends on toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* sw-client: offer only FIPS signature schemes with insecure_skip_verify

With https.client.insecure_skip_verify, reqwest installs its own verifier,
which advertises a fixed scheme list including SHA-1 and Ed448 whatever
the process provider allows. In FIPS mode the volume transport now builds
its rustls configuration itself on the process provider: the server
certificate and host name are not checked, as the setting asks, but
handshake signatures are verified with the provider's algorithms, only its
schemes are offered, and TLS 1.2 requires the Extended Master Secret.
Outside FIPS mode the reqwest path is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* seaweed-common: sign only with Go 1.27's FIPS schemes, allow ML-DSA

The FIPS provider kept aws-lc-rs's key provider, so a FIPS-mode listener
signed handshakes with whatever scheme its key and the peer agreed on,
outside the list the provider verifies with. Keys now load through a
provider that limits each key to the FIPS signature schemes and refuses a
key that can sign none of them, such as Ed448; the volume server and the
worker's gRPC TLS name the certificate and key files in that error.

The lists follow Go 1.27.4, which go.mod now requires: its
defaults_fips140.go allows ML-DSA-44, -65 and -87 as signature schemes and
ML-DSA certificate keys (for Go's native module only), so they are allowed
here as well. Go also allows MLKEM1024 but does not enable it by default,
so it stays out of the key exchange list as in Go's defaults. "off" keeps
the default key provider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: skip the truncate manifest test on freebsd like its fake filer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-11-27 12:47:44 -08:00

387 lines
18 KiB
TOML

# Put this file to one of the location, with descending priority
# ./security.toml
# $HOME/.seaweedfs/security.toml
# /etc/seaweedfs/security.toml
# this file is read by master, volume server, filer, and worker
# Any value below can also be supplied as an environment variable instead of
# living in this file: prefix the key with WEED_, upper-case it, and replace
# "." with "_". This is the recommended way to inject the secrets in here from
# a Kubernetes Secret (env valueFrom.secretKeyRef) rather than a ConfigMap.
# The JWT signing keys map to these env vars. When each component gets its own
# set, give it every key it signs or verifies with:
# WEED_JWT_SIGNING_KEY master, volume, filer, weed shell
# WEED_JWT_SIGNING_READ_KEY master, volume, and every process that
# reads chunks from volume servers: filer,
# s3, mount, webdav, sftp, filer.sync,
# filer.backup, workers, admin, weed shell
# WEED_JWT_FILER_SIGNING_KEY filer, s3, admin and workers (admin IAM and
# worker gRPC calls), and clients of the filer
# HTTP API
# WEED_JWT_FILER_SIGNING_READ_KEY filer, s3, and clients of the filer HTTP API
# WEED_JWT_FILER_SIGNING_SUBSCRIBE_KEY filer metadata subscriptions
# WEED_JWT_FILER_SIGNING_GRPC_KEY filer filesystem gRPC scope and assignment proofs
# WEED_JWT_FILER_SIGNING_GRPC_PREVIOUS_KEY
# previous gRPC scope and assignment-proof key during rotation
# A set env var wins over the file, so the file can stay empty (or absent).
# The FIPS 140-3 mode of every process that reads this file: "off", "on" or
# "strict" (WEED_FIPS_MODE). Unset leaves each process as it is. Go processes
# take the mode from GODEBUG and refuse to start when it differs: "off" needs
# fips140=off, "on" needs fips140=on, "strict" needs fips140=only. The Rust
# volume server, workers and vector engine take it from here: under "on" and
# "strict" their TLS offers and accepts only the FIPS 140-3 versions, cipher
# suites, key exchange groups and signature schemes Go allows in that mode.
# This restricts behaviour only; the Rust binaries do not yet use a validated
# cryptographic module.
[fips]
mode = ""
# comma separated origins allowed to make requests to the filer and s3 gateway.
# enter in this format: https://domain.com, or http://localhost:port
[cors.allowed_origins]
values = "*"
# this jwt signing key is used for write operations on volume servers:
# - the Master server generates the JWT, which can be used to write a certain file on a volume server
# - the Filer generates it for the chunk writes it proxies to volume servers,
# and weed shell for fs.merge_volumes and fs.distribute_chunks
# - the Volume server validates the JWT on writing
# the jwt defaults to expire after 10 seconds.
[jwt.signing]
key = ""
expires_after_seconds = 10 # seconds
# Optional. A key that is still accepted when verifying, but never used to
# sign, so keys can rotate without rejected requests: set the new key as
# previous_key everywhere, then swap key and previous_key everywhere, then,
# once tokens signed with the old key have expired, clear previous_key.
# Reload (SIGHUP) or restart after each step. [jwt.signing.read],
# [jwt.filer_signing] and [jwt.filer_signing.read] take previous_key the same way.
# Env: WEED_JWT_SIGNING_PREVIOUS_KEY, WEED_JWT_SIGNING_READ_PREVIOUS_KEY,
# WEED_JWT_FILER_SIGNING_PREVIOUS_KEY, WEED_JWT_FILER_SIGNING_READ_PREVIOUS_KEY
previous_key = ""
# by default, if the signing key above is set, the Volume UI over HTTP is disabled.
# by setting ui.access to true, you can re-enable the Volume UI. Despite
# some information leakage (as the UI is not authenticated), this should not
# pose a security risk.
[access]
ui = false
# by default the filer UI is enabled. This can be a security risk if the filer is exposed to the public
# and the JWT for reads is not set. If you don't want the public to have access to the objects in your
# storage, and you haven't set the JWT for reads it is wise to disable access to directory metadata.
# This disables access to the Filer UI, and will no longer return directory metadata in GET requests.
[filer.expose_directory_metadata]
enabled = true
# HTTP Basic Auth on the filer HTTP ports (-port and -port.readonly). Once the
# password is set, every request needs these credentials or a valid filer JWT
# (see [jwt.filer_signing]), and an access level without a JWT key is no longer
# open. /healthz and /readyz stay open. A browser request from another website
# (an Origin other than the filer's own host) can use these credentials only if
# its origin is listed in cors.allowed_origins. Components that call the filer HTTP
# port (mount, filer.sync and filer.backup with -filerProxy, sftp, volume.fsck)
# authenticate with the filer JWT, so set jwt.filer_signing.key, and
# jwt.filer_signing.read.key for their reads, if you run them.
# Env: WEED_FILER_BASIC_AUTH_USER, WEED_FILER_BASIC_AUTH_PASSWORD
[filer.basic_auth]
user = ""
password = ""
# HTTP Basic Auth on the WebDAV gateway (weed webdav, weed server -webdav,
# weed mini). Without a password, anyone who can reach the WebDAV port reads,
# writes and deletes everything under its -filer.path, and weed mini binds
# WebDAV to 127.0.0.1 unless -webdav.allowInsecureBind is set. Basic Auth
# sends the password in every request, so serve WebDAV over TLS
# (-webdav.cert.file, -webdav.key.file) on an untrusted network.
# Env: WEED_WEBDAV_BASIC_AUTH_USER, WEED_WEBDAV_BASIC_AUTH_PASSWORD
[webdav.basic_auth]
user = ""
password = ""
# this jwt signing key is used for read operations on volume servers:
# - the Master server generates the JWT, which can be used to read a certain file on a volume server
# - every process that reads chunks straight from volume servers generates its
# own: filer, s3, mount, webdav, sftp, filer.sync, filer.backup, workers,
# admin and weed shell. Without the key, their reads fail with "wrong jwt".
# - the Volume server validates the JWT on reading
[jwt.signing.read]
key = ""
expires_after_seconds = 10 # seconds
previous_key = ""
# If this JWT key is configured, Filer only accepts writes over HTTP if they are signed with this JWT:
# - f.e. the S3 API Shim generates the JWT
# - the Filer server validates the JWT on writing
# NOTE: This key is ALSO used as a fallback signing key for S3 STS if s3.iam.config does not specify a signingKey.
# NOTE: This key also gates the filer IAM gRPC service (CreateUser, PutPolicy,
# CreateAccessKey, ...). When set, every IAM RPC must carry a Bearer
# token signed with this key in its "authorization" gRPC metadata; mint
# such a token with security.GenJwtForFilerAdmin. When empty, the IAM
# gRPC service runs unauthenticated and refuses its OIDC provider and
# role RPCs. When set, set it on both filer and admin.
# The key does not protect the other filer gRPC RPCs, which can read and
# write the IAM store under /etc/iam; if the filer gRPC port is reachable
# beyond a trusted network, enable [grpc.filer] mTLS below.
# the jwt defaults to expire after 10 seconds.
# Filesystem gRPC callers may send authorization: Bearer <token> signed with
# this key. allowed_prefixes grant read/write paths; read_prefixes grant reads.
# allowed_methods optionally restricts gRPC method names. Scoped tokens require
# jti and exp, need assignment proofs for new chunk ids, and cannot call unruled
# methods. New inline content is allowed within the token's writable paths.
# Calls without a token retain their existing behavior. This is scope enforcement,
# not mandatory authentication; restrict network access to the filer as before.
# Rolling upgrades: enable scoped writers only after every filer runs this
# version or newer. Scope-only filers refuse new chunk ids even with a proof;
# older filers without scope enforcement treat scoped tokens as unscoped.
[jwt.filer_signing]
key = ""
expires_after_seconds = 10 # seconds
previous_key = ""
# Optional filesystem gRPC signing key; when unset, key above is used. Setting
# this alone enables gRPC scope checks without changing HTTP authentication.
# When grpc_key is set, grpc_previous_key is also accepted for gRPC scope
# tokens and assignment proofs. The HTTP previous_key remains excluded from
# this separate trust domain. Keep grpc_previous_key configured for at least
# assign_expires_after_seconds plus the scoped token lifetime after rotating.
# When grpc_key is unset, the shared HTTP current/previous pair is used.
# grpc_key = ""
# grpc_previous_key = ""
# Require every filesystem gRPC call to carry a valid bearer token. This also
# refuses verified mTLS peers that do not present a token. The setting is off
# by default for compatibility with existing tokenless callers.
# grpc_require_token = false
# AssignVolume returns a proof bound to the holder, chunk-ID range and resolved
# collection in assign_auth. Return it under the chunk's file id in chunk_auth
# when storing the entry. Auth remains the separate volume-upload credential.
# Proofs always expire: zero or negative lifetime uses the default of 86400 seconds.
# assign_expires_after_seconds = 86400
# Clock-skew allowance for scope and proof validation; negative means zero.
# clock_leeway_seconds = 30
# If this JWT key is configured, Filer only accepts reads over HTTP if they are signed with this JWT:
# - f.e. the S3 API Shim generates the JWT
# - the Filer server validates the JWT on reading
# the jwt defaults to expire after 10 seconds.
[jwt.filer_signing.read]
key = ""
expires_after_seconds = 10 # seconds
previous_key = ""
# Optional. If this key is set, the filer's SubscribeMetadata and
# SubscribeLocalMetadata gRPC calls require an mTLS-verified peer, an admin
# token signed with jwt.filer_signing.key, or a read-only token signed with this
# key. That token is an HS256 JWT with "exp", "allowed_methods" (a subset of
# SubscribeMetadata and SubscribeLocalMetadata) and "allowed_prefixes"
# (absolute paths); its holder only receives events whose paths are all under
# one of the prefixes. Mint one with "fs.meta.token" in weed shell. Without
# mTLS, set jwt.filer_signing.key and this key on every filer, S3 gateway,
# mount and filer.sync too, so they keep full access.
[jwt.filer_signing.subscribe]
key = ""
# gRPC mTLS configuration
# All gRPC TLS authentications are mutual (mTLS)
# The values for ca, cert, and key are paths to the certificate/key files
# The host name is not checked, so the certificate files can be shared.
# Set verify_server_host = true under [grpc] or a [grpc.<component>] section to
# require that a server certificate is valid for the host or IP that component
# dials, as the Rust volume server always does.
# Each [grpc.<component>] section also accepts optional client_cert/client_key,
# presented when that component dials other servers. Set them when your CA
# issues separate serverAuth-only and clientAuth-only certificates; when unset,
# the component reuses cert/key for both directions.
# If client and server certificates come from different issuing CAs, put both
# CA certificates in the ca PEM file.
# Once a component's cert/key are set, any error loading them or grpc.ca is
# fatal: the component never falls back to plaintext.
[grpc]
ca = ""
verify_server_host = false
# Set wildcard domain for enable TLS authentication by common names
allowed_wildcard_domain = "" # .mycompany.com
# Optional allowlist a client checks the dialed server's certificate against:
# the subject common name, a DNS SAN, or a URI SAN (e.g. a SPIFFE id) must be
# listed, or match allowed_server_wildcard_domain, else the handshake fails.
# With a per-workload CA, list the identities each server may present so one
# workload cannot impersonate another component. Unset accepts any CA-signed
# server certificate, as before. Any [grpc.<component>] section may set its own
# allowed_server_commonNames to override this list. Only the filer scopes it
# further per dialed target: [grpc.filer] master_, volume_ and
# s3_allowed_server_commonNames. Other components dial every server with one
# allowlist and refuse to start when per-target keys are their only allowlist.
allowed_server_commonNames = "" # comma-separated server identities
allowed_server_wildcard_domain = "" # .mycompany.com
# Volume server gRPC options (server-side)
# Enables mTLS for incoming gRPC connections to volume server
[grpc.volume]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
# Master server gRPC options (server-side)
# Enables mTLS for incoming gRPC connections to master server
[grpc.master]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
# Filer server gRPC options (server-side)
# Enables mTLS for incoming gRPC connections to filer server
[grpc.filer]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
# S3 server gRPC options (server-side)
# Enables mTLS for incoming gRPC connections to S3 server
[grpc.s3]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
[grpc.msg_broker]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
[grpc.msg_agent]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
[grpc.admin]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
[grpc.worker]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
[grpc.mq]
cert = ""
key = ""
client_cert = ""
client_key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
# weed-vector gRPC options (server-side)
# Enables mTLS for incoming gRPC connections to the vector engine; the S3
# gateway dials it with [grpc.client], and the engine dials the masters with
# [grpc.client] too. The files are re-read every WEED_TLS_CERT_REFRESH_INTERVAL
# (default 5h) and on SIGHUP.
[grpc.vector]
cert = ""
key = ""
allowed_commonNames = "" # comma-separated SSL certificate common names
# gRPC client configuration for outgoing gRPC connections
# Used by clients (S3, mount, backup, benchmark, filer.copy, filer.replicate, upload, etc.)
# when connecting to any gRPC server (master, volume, filer)
[grpc.client]
cert = ""
key = ""
# HTTPS client configuration for outgoing HTTP connections
# Used by S3, mount, filer.copy, backup, and other clients when communicating with master/volume/filer
# Set enabled=true to use HTTPS instead of HTTP for data operations (separate from gRPC)
# If [https.filer] or [https.volume] are enabled on servers, clients must have [https.client] enabled=true
[https.client]
enabled = false # Set to true to enable HTTPS for all outgoing HTTP client connections
cert = "" # Client certificate for mTLS (optional if server doesn't require client cert)
key = "" # Client key for mTLS (optional if server doesn't require client cert)
ca = "" # CA certificate to verify server certificates (required when enabled=true)
insecure_skip_verify = false # Skip TLS certificate verification (NOT recommended for production)
# Volume server HTTPS options (server-side)
# Enables HTTPS for incoming HTTP connections to volume server
[https.volume]
cert = ""
key = ""
ca = ""
# Master server HTTPS options (server-side)
# Enables HTTPS for incoming HTTP connections to master server (web UI, HTTP API)
[https.master]
cert = ""
key = ""
ca = ""
# Filer server HTTPS options (server-side)
# Enables HTTPS for incoming HTTP connections to filer server (web UI, HTTP API)
[https.filer]
cert = ""
key = ""
ca = ""
# disable_tls_verify_client_cert = true|false (default: false)
# Admin server HTTPS options (server-side)
# Enables HTTPS for incoming HTTP connections to admin server
[https.admin]
cert = ""
key = ""
ca = ""
# Admin server authentication
# If password is set, users must login to access the admin interface
# These can be overridden by environment variables with WEED_ prefix:
# WEED_ADMIN_USER, WEED_ADMIN_PASSWORD
# WEED_ADMIN_READONLY_USER, WEED_ADMIN_READONLY_PASSWORD
[admin]
user = ""
password = ""
[admin.readonly]
user = ""
password = ""
# SSE-S3 server-side encryption key management
# These settings configure the Key Encryption Key (KEK) for S3 SSE-S3 encryption.
# Set exactly one of kek or key. If neither is set, SSE-S3 is disabled.
# Can also be set via env vars: WEED_S3_SSE_KEK, WEED_S3_SSE_KEY
[s3.sse]
# hex-encoded 256-bit key, same format as the legacy /etc/s3/sse_kek filer file.
# Use this to migrate from a filer-stored KEK: copy the value from /etc/s3/sse_kek.
# Generate a new one with: openssl rand -hex 32
kek = ""
# any secret string; a 256-bit key is derived automatically via HKDF-SHA256.
# Cannot be used while /etc/s3/sse_kek exists on the filer — delete it first.
key = ""
# Trusted reverse proxies allowed to set forwarding headers on behalf of the
# real client: X-Forwarded-For / X-Real-Ip for aws:SourceIp condition
# evaluation in S3 bucket and IAM policies, and X-Forwarded-Prefix for SigV4
# signature verification of prefix-stripped paths. When the direct TCP peer is
# in this list, these headers are honored; otherwise they are ignored. A
# trusted proxy must overwrite or strip client-supplied values of these
# headers, since honoring them means trusting them. Leave empty to always use
# the direct peer, which is the safe default.
# Can also be set via env var: WEED_S3_TRUSTED_PROXIES_WHITE_LIST
[s3.trusted_proxies]
white_list = "" # comma separated; bare IPs or CIDRs, e.g. "10.10.10.0/24"
# white list. It's checking request ip address.
[guard]
white_list = ""