* fips140=only: refuse HMAC keys too short for FIPS mode where they are configured
Under GODEBUG=fips140=only, hmac.New panics on keys shorter than 112 bits
(14 bytes). A short JWT signing key starts fine and then kills weed server
on the first write (the master's Assign mints a volume JWT in an
unrecovered gRPC handler), and an S3 secret of 8 or 9 characters (the
SigV4 signing key is HMAC keyed with "AWS4"+secret) makes every request
from that identity panic in its handler.
Only under crypto/fips140.Enforced():
- security.toml: LoadSecurityConfiguration exits with an error naming the
setting when a jwt.signing / jwt.filer_signing key, read key or
previous key is under 14 bytes. LoadFilerJwtFromFile (filer.sync
-a.security/-b.security) returns the same error, and
Guard.UpdateSigningKeys keeps the keys in effect on a reload that
brings in a short key.
- S3: SigV4 (header, presigned, streaming seed and POST policy) answers
InvalidAccessKeyId, as for an inactive key, when the credential's
secret is under 10 characters, and logs the access key. Loading such a
credential logs a warning; it stays loaded and stored.
- IAM CreateAccessKey (IAM API, embedded IAM, admin UI) requires a
caller-supplied SecretAccessKey of at least 10 characters.
Refs #12839
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fips140=only: check jwt.filer_signing.subscribe.key and the imgproxy key too
The filer verifies metadata subscription tokens with
jwt.filer_signing.subscribe.key and `weed shell fs.meta.token` signs them
with it, so under GODEBUG=fips140=only a short value panics on first use;
LoadSecurityConfiguration now refuses it with the other JWT keys. `weed
image` signs imgproxy URLs with HMAC keyed with IMGPROXY_KEY;
gateway.New refuses a key under 14 bytes in that mode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: warn about JWT keys too short for fips140=only outside that mode
Outside GODEBUG=fips140=only a JWT signing key under 14 bytes works, so
LoadSecurityConfiguration (every weed command but fuse) and
LoadFilerJwtFromFile now log a warning naming the setting instead of saying
nothing: such a key is refused under fips140=only, and a future release may
refuse it in every mode, so the warning asks for a rotation to a longer key
with previous_key while it still works. A short previous_key holds the old
key during that rotation, so its warning only asks to clear it afterwards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: refuse a short secret under fips140=only with AccessDenied, not InvalidAccessKeyId
InvalidAccessKeyId says the access key does not exist, so a client refused
for a secret too short for fips140=only went looking for a missing key. The
new ErrFips140SecretTooShort answers AccessDenied (403) with "This access
key cannot be used while the server runs in FIPS 140 mode. Ask the
administrator for a new secret." The message leaves out the length rule:
the refusal comes before the request's signature is checked, so any caller
that knows the access key ID would learn the secret is short. The embedded
IAM API maps it to AccessDenied as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: log an S3 secret too short for fips140=only at error level
Under GODEBUG=fips140=only every request signed with such a key is refused,
so the identity is unusable; the load-time message is an error, not a
warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util, security: name every JWT key too short for fips140=only in one error
CheckFips140SigningKeys stopped at the first short key, so a cluster with
two short keys failed at startup, was fixed, and failed again on the next
one. CheckFips140HmacKeys checks every setting and names each short key
("jwt.signing.key is 10 bytes, jwt.filer_signing.key is 8 bytes; ..."); with
one short key the message is unchanged. Guard reloads use it as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fips140=only: say what happened, to what and what to do in the short-key messages
The messages about S3 secrets and JWT keys too short for FIPS 140 now start
from the process's mode, name the key, its owner or file, the limit, and the
fix:
- loading S3 identities: "this process runs with GODEBUG=fips140=only, and
refuses all S3 requests signed with access key ... (identity ...) because
its secret is shorter than the 10 characters FIPS 140 needs for SigV4
secrets; give that access key a new secret of at least 10 characters";
- a refused request logs its request ID, which the client gets back, its
client IP (as the audit log records it, s3err.RemoteIP) and the identity;
- the startup refusal names security.toml's path and every short key, and
links the wiki section on replacing them with or without downtime;
- the startup warning outside fips140=only says the server would not start
in that mode, and links the same section.
A short previous_key no longer gets a warning outside fips140=only: it holds
the old key while switching to a longer one, and under fips140=only the
startup refusal names it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: a reload under fips140=only drops short previous keys, not the new keys
UpdateSigningKeys refused the whole key set when a previous key was too short,
so a volume server kept its old keys while the filer's volume signer, which
gets no previous keys, took the new ones; proxied chunk reads then failed with
401. Short current keys still keep the keys in effect. A short previous key is
dropped with an error log instead: nothing under fips140=only can sign with it,
so no token is lost, and every server ends up with the same current keys.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: check only the filer keys filer.sync uses in its security files
LoadFilerJwtFromFile checked every JWT setting in a -a.security/-b.security
file, so under fips140=only filer.sync refused to start over a short volume or
previous key it never uses. It now checks jwt.filer_signing.key and its read
key, after the fallback to the process-wide configuration, which startup
checks already.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: answer a short secret under fips140=only with SignatureDoesNotMatch
A distinct answer before the signature is checked told anyone who knows an
access key ID that its secret is short. The refusal now runs where the
signature would be checked, after the permission, expiry and signed-header
checks, and answers the SignatureDoesNotMatch a wrong signature gets. The
server log keeps the cause, the request ID and the client. This drops
ErrFips140SecretTooShort and its IAM mapping.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security, filer: keep Basic Auth on a reload whose JWT keys are refused
When a reload under fips140=only refused the new filer JWT keys, the filer
still removed Basic Auth, so a configuration that switches from Basic Auth to
short JWT keys left the filer with neither. UpdateSigningKeys and
ReloadSigningKeys now report whether the new keys are in effect, and the
filer drops Basic Auth only when they are.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util/http: do not install a volume read key too short for fips140=only
A reload installed jwt.signing.read.key into the read-signing cache without a
length check, so under fips140=only a short key made later chunk reads panic
signing with it. loadJwtConfig now leaves the key in effect when the new one
is too short.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util/http: keep the volume read key when the volume guard would refuse the reload
Under GODEBUG=fips140=only a volume server's reload keeps its keys when
jwt.signing.key or jwt.signing.read.key is too short. The read-key cache
checked only the read key, so it could sign reads with a key the volume
servers had not taken. It now checks the same two keys.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: build the short-key list in one append in CheckFips140HmacKeys
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: keep the blank line before the permission check in verifyV4Signature
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: skip TestFIPS140OnlyShortSecret under real fips140=only enforcement
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>
* filer: assignment tokens and chunk proofs for scoped writes
* filer: tighten scoped chunk identities and write boundaries
* filer: apply gRPC key removal on config reload
* filer: prevent scoped chunk alias and remote append data loss
* filer: guard scoped writes across stored data representations
* filer: preserve lazy scoped admission lookups
* filer: avoid summing chunk counts for map capacity
* filer: keep a scoped assign in its path's collection
A scoped token could name another bucket's collection in AssignVolume and
upload chunks there, charging that bucket's quota and losing them when that
collection is deleted. A scoped caller now gets the collection its path
resolves to; naming a different one is refused before the master call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: rotate gRPC keys and bind chunk proofs to collections
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: path- and method-scoped tokens on the filesystem gRPC service
* filer: close scoped admission and compatibility gaps
* filer: test subscription key ambiguity and retained write success
* filer: assert verified peer chains survive subscription fallback
* filer: keep a hard link's count and chunks together under a scoped token
A scoped write may keep a hard link the target already has, but the link
count it sends was stored as is, and its chunks could stay on the name
with the link dropped. Either let a scoped token delete its own name and
take the chunks of a name outside its grants with it: the forged count
reaches zero, or the detached name owns the shared chunks.
The handler recheck now refuses a scoped write that changes a stored
link's count or keeps its chunks without the link. Dropping the link
together with the data, and appending to a linked file, are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: leave subscriptions with a non-scope bearer to the existing verifier
The stream interceptor refused a SubscribeMetadata or SubscribeLocalMetadata
call whose bearer does not verify under the filer key unless the bearer was
a subscription token, and it checked that token with the peer stripped. With
no subscription key, or on an mTLS peer, the existing verifier admits such a
call, so filer.sync sending another cluster's admin token stopped.
When the bearer is no filer scope, the subscription verifier now decides on
the original context, as before scoped tokens. A scoped token still reaches
the refusal for scoped subscriptions, and malformed metadata is still refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: refuse scoped writes that would make ancestors outside the grant
A scoped create, append or rename checked only its target. The filer then
creates the target's missing ancestors up to the first one it finds, and
turns that one into a directory if it is a file, dropping its ttl. A token
granted /data/proj/ws could so promote the file /data/proj, or create /q and
/q/r for a grant /q/r/ws.
The scope now walks the same ancestors before admitting the write and
refuses one outside the write grants that is missing or not a directory. A
create with skip_check_parent_directory makes no ancestors and is not
walked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: require write grants for scoped lock mutations
* filer: document scoped signatures and read-only token upgrades
* filer: enforce WORM retention for scoped mutations
* filer: refuse scoped writes through shared hard links
* filer: drop series notes from scope comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: refuse scoped subtree mutations across WORM rules
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* security: verify JWTs against an optional previous signing key
DecodeJwt, the admin token checks and the volume expiry classifier take
previous keys to try after the current one, and Guard keeps a previous
write and read key next to the current ones. Signing still uses only the
current key. Callers pass no previous key yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume, filer, s3, admin: accept tokens signed with jwt.*.previous_key
jwt.signing.previous_key, jwt.signing.read.previous_key,
jwt.filer_signing.previous_key and jwt.filer_signing.read.previous_key
(WEED_JWT_*_PREVIOUS_KEY from the environment) name a key the verifiers
still accept next to the current one, and SIGHUP reloads them. Keys can
then rotate without an error window: add the new key as previous
everywhere, swap current and previous, then remove previous.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* scaffold: document jwt previous_key for key rotation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): accept tokens signed with jwt.signing previous_key
Mirrors the Go volume server: [jwt.signing] and [jwt.signing.read] take
previous_key (WEED_JWT_SIGNING_PREVIOUS_KEY,
WEED_JWT_SIGNING_READ_PREVIOUS_KEY), the guard verifies against it after
the current key, and SIGHUP reloads it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume, filer, s3: drop a removed previous_key on SIGHUP
LoadConfiguration merges, so a previous_key line deleted from
security.toml kept verifying until a restart. Read the previous keys
without the merge on reload, as the Rust volume server already does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume, filer, s3: keep previous keys when a reload cannot read the file
A SIGHUP that found security.toml unreadable or malformed cleared the
previous keys while the merged current keys stayed. Fall back to the
merged configuration then, so the keys in effect stay in effect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: IAM and metadata subscription admin checks follow the filer guard
The IAM gRPC service checked the jwt.filer_signing keys read at startup,
and the metadata subscription read them from the merged configuration,
so adding or removing previous_key with SIGHUP did not reach them. Both
now read the filer guard that Reload updates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: reload jwt keys in one place, keeping the guard's previous keys
When security.toml could not be read, the reloads fell back to the merged
configuration, which still holds a previous_key an earlier reload removed.
Guard.ReloadSigningKeys keeps the previous keys the guard already has
instead, and the volume, filer and S3 reloads share it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: take reloaded current keys from the same read as previous keys
The current keys came from the merged configuration and the previous keys
from a second read of the file, so a file swapped between the two reads
could publish the same key as both. Take every key the fresh read sets
from it; a current key the file no longer sets keeps its merged value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: worker streams read the filer admin keys as security.toml sets them
Both worker stream handlers read jwt.filer_signing keys from the merged
configuration. Under weed mini a reload merges the file, which keeps a
previous_key the operator removed, so new streams still accepted it; a
standalone admin never picked up a rotation at all. Read the keys the file
sets now, falling back to the merged values.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* scaffold: wait for old-key tokens to expire before clearing previous_key
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): keep the keys in effect when SIGHUP cannot read security.toml
parse_security_config falls back to defaults when the file is missing or
unreadable, so a SIGHUP then cleared every key and turned JWT checks off.
Skip the key and whitelist update in that case, as the Go reload keeps
its merged configuration and the guard's previous keys.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: keep every key in effect when a reload cannot read security.toml
A failed read took the current keys from the merged configuration while
keeping the active previous keys, so after a swapped pair the guard could
publish the old key twice and reject tokens signed with the new one. The
reload now leaves the keys untouched, as the Rust volume server does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: filer admin keys fall back to the last pair read, not merged values
When security.toml stopped being readable, FilerAdminKeys returned the
merged configuration, which still holds a previous_key the file had
already dropped, so tokens signed with the retired key verified again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: STS store gates check the admin token against one key snapshot
The OIDC provider and role RPCs read the reloadable admin key twice, in
checkAdminAuth and in the store gate. A reload that set the key between
the two reads let a call without a token pass both. The gate now takes
one snapshot for the empty-key refusal and the token check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: read and cache filer admin keys under one lock
Concurrent callers could store their reads out of order, so an older
pair that still had previous_key could overwrite a newer one and come
back when a later read of security.toml failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: unlock the filer admin key mutex on every exit of its test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* operation: reassign an upload after a proven-expired volume JWT
* seaweed-volume: mark an expired write JWT refused before append
Mirror the Go volume server: a multipart POST whose write JWT is signed
with the current key, names this fid and fails only on exp gets
X-Seaweed-Write-Outcome: expired-jwt-before-append on its 401, so the
uploader reassigns instead of failing. Both checks use one guard
snapshot, so a key rotation between them cannot drop the marker.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* operation: keep same-FID retry for filer-proxy expiries, snapshot the write signing key, and make the RetryForever budget test fail fast
* operation: re-mint the filer credential before a proxy same-FID expiry retry
* operation: make a proxy marked-expiry terminal in the outer retry too, not only the inner same-FID loop
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* security: do not accept a path- or method-scoped filer token as admin
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: test that scoped filer tokens fail the admin token check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: sign proxied chunk I/O from the per-side security file
The -a.security / -b.security files were used for gRPC TLS and the
HTTPS client but not for jwt.filer_signing, so filer-proxied chunk
reads and writes carried a token signed with the process-wide key and
failed authorization whenever the two clusters' keys differ.
LoadFilerJwtFromFile returns a FilerJwtProvider for each side's file,
which FilerSource and FilerSink now accept for proxied chunk reads and
writes. With no keys in the file or no flag, both fall back to the
process-wide jwt.filer_signing configuration as before.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* replication: use the side filer read key for manifest downloads and fall back per access level
Manifest chunk resolution still signed proxied downloads with the
process-wide read key, so a source filer requiring its own key 401'd on
manifest-bearing files. A side security file that set only one access
level also produced empty tokens for the other instead of inheriting the
process-wide key, and the side file loader ignored the WEED_ environment
overrides the filer itself honors.
ResolveChunkManifest/ResolveOneChunkManifest keep their signatures;
FilerJwt-aware variants thread the provider down to fetchWholeChunk,
which prefers it on proxy URLs. The side loader now applies the same
environment precedence and falls back to the process-wide signer per
missing access level.
* security: verify the configured filer token lifetimes
* security: reject negative filer token lifetimes
A negative expires_after_seconds reached GenJwtForFilerServer and produced
a token with no expiration claim. Also synchronize the Authorization-header
capture in the proxy test and restore the prior viper key on cleanup.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---------
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* s3api: test that a session token must not reveal its credential
* sts: derive secret access key with HMAC keyed on the signing key
* s3api: stop accepting STS session tokens as bearer credentials
* security: reject STS session tokens on filer and admin gRPC auth
* test: sign s3/iam framework requests with the session credential
* s3api: exercise the real auth pipeline in the end-to-end harness
Introduce security.BearerPrefix ("Bearer ", RFC 6750) and use it
everywhere an "Authorization: Bearer <token>" header is constructed,
replacing the scattered "BEARER "/"Bearer " string literals. SeaweedFS
matches the scheme case-insensitively when parsing (security.GetJwt), so
behavior is unchanged; this removes the magic string and settles the
casing on the standard form. The parser's upper-case comparison stays as
is on purpose.
Every IAM RPC (CreateUser, PutPolicy, CreateAccessKey, ...) now requires
a Bearer token in the authorization metadata, signed with the filer
write-signing key. The service refuses to register on a filer that has
no jwt.filer_signing.key set, so the unauthenticated default is gone:
operators who use these RPCs must configure the key and attach a token
on every call.
Bearer scheme matching is case-insensitive (RFC 6750), every handler
nil-checks req before dereferencing it, and tests now cover the
expired-token path.
* Implement optional path-prefix and method scoping for Filer HTTP JWT
* Fix security vulnerability and improve test error handling
* Address PR feedback: replace debug logging and improve tests
* Use URL.Path in logs to avoid leaking query params
- one JWT for reading and one for writing, analogous to how the JWT
between Master and Volume Server works
- I did not implement IP `whiteList` parameter on the filer
Additionally, because http_util.DownloadFile now sets the JWT,
the `download` command should now work when `jwt.signing.read` is
configured. By looking at the code, I think this case did not work
before.
## Docs to be adjusted after a release
Page `Amazon-S3-API`:
```
# Authentication with Filer
You can use mTLS for the gRPC connection between S3-API-Proxy and the filer, as
explained in [Security-Configuration](Security-Configuration) -
controlled by the `grpc.*` configuration in `security.toml`.
Starting with version XX, it is also possible to authenticate the HTTP
operations between the S3-API-Proxy and the Filer (especially
uploading new files). This is configured by setting
`filer_jwt.signing.key` and `filer_jwt.signing.read.key` in
`security.toml`.
With both configurations (gRPC and JWT), it is possible to have Filer
and S3 communicate in fully authenticated fashion; so Filer will reject
any unauthenticated communication.
```
Page `Security Overview`:
```
The following items are not covered, yet:
- master server http REST services
Starting with version XX, the Filer HTTP REST services can be secured
with a JWT, by setting `filer_jwt.signing.key` and
`filer_jwt.signing.read.key` in `security.toml`.
...
Before version XX: "weed filer -disableHttp", disable http operations, only gRPC operations are allowed. This works with "weed mount" by FUSE. It does **not work** with the [S3 Gateway](Amazon S3 API), as this does HTTP calls to the Filer.
Starting with version XX: secured by JWT, by setting `filer_jwt.signing.key` and `filer_jwt.signing.read.key` in `security.toml`. **This now works with the [S3 Gateway](Amazon S3 API).**
...
# Securing Filer HTTP with JWT
To enable JWT-based access control for the Filer,
1. generate `security.toml` file by `weed scaffold -config=security`
2. set `filer_jwt.signing.key` to a secret string - and optionally filer_jwt.signing.read.key` as well to a secret string
3. copy the same `security.toml` file to the filers and all S3 proxies.
If `filer_jwt.signing.key` is configured: When sending upload/update/delete HTTP operations to a filer server, the request header `Authorization` should be the JWT string (`Authorization: Bearer [JwtToken]`). The operation is authorized after the filer validates the JWT with `filer_jwt.signing.key`.
If `filer_jwt.signing.read.key` is configured: When sending GET or HEAD requests to a filer server, the request header `Authorization` should be the JWT string (`Authorization: Bearer [JwtToken]`). The operation is authorized after the filer validates the JWT with `filer_jwt.signing.read.key`.
The S3 API Gateway reads the above JWT keys and sends authenticated
HTTP requests to the filer.
```
Page `Security Configuration`:
```
(update scaffold file)
...
[filer_jwt.signing]
key = "blahblahblahblah"
[filer_jwt.signing.read]
key = "blahblahblahblah"
```
Resolves: #158