filehost: refuse to sign upload tokens when filehost_jwt_secret is unset/empty/"changeme" — the default fell open, signing with a world-known key so anyone could forge a server-trusted upload authorization; now it fails closed and tells the user to fix the config

This commit is contained in:
Jean Chevronnet 2026-08-19 00:42:10 +00:00
parent a09dfc74df
commit d9d5bd069b

View file

@ -201,10 +201,20 @@ impl Command for FileHostCmd {
} }
}; };
let secret = s // Fail closed: signing upload tokens with a missing/placeholder secret
.conf("filehost_jwt_secret") // would let anyone forge a server-trusted upload authorization.
.unwrap_or("changeme") let secret = match s.conf("filehost_jwt_secret") {
.to_string(); Some(sec) if !sec.is_empty() && sec != "changeme" => sec.to_string(),
_ => {
note(
s,
uid,
"FILEHOST: file hosting is misconfigured (no upload secret set). \
Please tell an operator.",
);
return CmdResult::Fail;
}
};
let issuer = s let issuer = s
.conf("filehost_jwt_issuer") .conf("filehost_jwt_issuer")
.unwrap_or("FILEHOST") .unwrap_or("FILEHOST")