fix(security): address PR 48 findings with bounded concurrent authentication

Classify IPv6 subnets numerically, reserve login capacity before hashing, bind authentication to credential revisions, revoke other sessions on password rotation, reuse trusted proxy client keys and bound PCM encoding by monotonic time. Credit ph1gros for the findings and proposed regression cases.
This commit is contained in:
illusia committed 2026-10-26 10:28:45 +08:00
1 parent 8bca848c21
commit 275e27c4ac
31 files changed
+449 -84

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import test from "node:test";
import { spawnSync } from "node:child_process";
test("protocol identifiers and favorite addresses keep ASCII casing under a Turkish locale", () => {
const child = spawnSync(process.execPath, ["--import", "tsx", "--input-type=module", "-e", `
import assert from 'node:assert/strict';
import { parseTeamSpeakTarget, teamSpeakTargetKey } from './src/domain/teamspeak-target.ts';
import { quickServerTargetsEqual, mergeQuickServers } from './web/src/services/quick-servers.ts';
import { normalizeTeamSpeakError } from './src/errors.ts';
// Windows ignores LANG for ICU's default locale; isolate the Turkish default in this child.
const localeLower = String.prototype.toLocaleLowerCase;
String.prototype.toLocaleLowerCase = function(...locales) {
return localeLower.call(this, ...(locales.length ? locales : ['tr']));
};
assert.equal('I'.toLocaleLowerCase(), 'ı', 'the child must actually run under Turkish casing');
const target = parseTeamSpeakTarget('VOICE.EXAMPLE.IO#9987');
assert.equal(target.host, 'voice.example.io');
assert.equal(teamSpeakTargetKey({host:'VOICE.EXAMPLE.IO',port:9987}), 'voice.example.io:9987');
assert.equal(quickServerTargetsEqual('VOICE.EXAMPLE.IO:9987', 'voice.example.io#9987'), true);
assert.equal(mergeQuickServers([{id:'a',label:'a',address:'VOICE.EXAMPLE.IO:9987'}],
[{id:'b',address:'voice.example.io:9987',lastConnectedAt:1}]).length, 1);
const upper=normalizeTeamSpeakError(new Error('INVALID IDENTITY'));
const lower=normalizeTeamSpeakError(new Error('invalid identity'));
assert.equal(upper.code, lower.code);
`], { env: { ...process.env, LANG: "tr_TR.UTF-8", LC_ALL: "tr_TR.UTF-8" }, encoding: "utf8" });
assert.equal(child.status, 0, child.stderr || child.stdout);
});
+2 -2
View File
@@ -72,11 +72,11 @@ export function formatTeamSpeakTarget(target: TeamSpeakTarget): string {
}
export function teamSpeakTargetKey(target: TeamSpeakTarget): string {
return formatTeamSpeakTarget(target).toLocaleLowerCase();
return formatTeamSpeakTarget(target).toLowerCase();
}
function createTarget(hostValue: string, portValue: string | number): TeamSpeakTarget {
const host = hostValue.trim().toLocaleLowerCase();
const host = hostValue.trim().toLowerCase();
if (!host || host.length > 255 || /[\s/\\?#@\[\]]/.test(host)) {
throw new InvalidTeamSpeakTargetError("Invalid TeamSpeak server address");
}