mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Harden the gateway against abuse (review S1-S3, S5-S7, S9)
- /ws: optional ALLOWED_ORIGINS allowlist, connection limits per IP and in total, 34 MiB maxPayload (uploads capped at 24 MiB client-side) - connect: reject malformed host/nickname before spawning a connector; args passed as --flag=value, secrets via env instead of argv - connector: 25 MiB download cap, 512 KiB for auto-fetched icons, friendly error for blocked private targets (tsclientlib: ALLOW_PRIVATE_TARGETS) - feedback: contact e-mail never goes into the public GitHub issue; mentions/links in the issue body are neutralized; form says so - rate limits: TRUST_PROXY-aware client IP, expiring limiter maps - security headers (nosniff, frame options, CSP on served HTML) - web: icon downloads requested once per path instead of on every update Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
295af1781e
commit
4124071371
13 files changed
+246
-57
No files matched your search
@@ -264,14 +264,18 @@ export class Ts3Connection {
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
const args = ["--address", this.options.host, "--nickname", this.options.nickname];
|
||||
if (this.options.serverPassword) args.push("--server-password", this.options.serverPassword);
|
||||
if (this.options.channelPassword) args.push("--channel-password", this.options.channelPassword);
|
||||
if (this.options.defaultChannel) args.push("--default-channel", this.options.defaultChannel);
|
||||
if (this.options.identity) args.push("--identity", this.options.identity);
|
||||
if (this.options.serverType) args.push("--server-type", this.options.serverType);
|
||||
if (this.options.privilegeKey) args.push("--privilege-key", this.options.privilegeKey);
|
||||
this.child = spawn(CONNECTOR_BIN, args);
|
||||
// "--flag=value" so a value starting with "-" can never be parsed as a
|
||||
// flag of its own. Secrets go through the environment instead of argv,
|
||||
// which any process on the host can read via `ps`.
|
||||
const args = [`--address=${this.options.host}`, `--nickname=${this.options.nickname}`];
|
||||
if (this.options.defaultChannel) args.push(`--default-channel=${this.options.defaultChannel}`);
|
||||
if (this.options.serverType) args.push(`--server-type=${this.options.serverType}`);
|
||||
const env: NodeJS.ProcessEnv = { ...process.env };
|
||||
if (this.options.serverPassword) env.TS_SERVER_PASSWORD = this.options.serverPassword;
|
||||
if (this.options.channelPassword) env.TS_CHANNEL_PASSWORD = this.options.channelPassword;
|
||||
if (this.options.identity) env.TS_IDENTITY = this.options.identity;
|
||||
if (this.options.privilegeKey) env.TS_PRIVILEGE_KEY = this.options.privilegeKey;
|
||||
this.child = spawn(CONNECTOR_BIN, args, { env });
|
||||
|
||||
// The connector can exit on its own (e.g. the TS3 server drops it) and close
|
||||
// its stdin pipe before writeLine()'s `this.child.killed` guard has any way
|
||||
|
||||
Reference in new issue
Block a user