Skip to content

Commit 8d828bd

Browse files
authored
Merge pull request #2136 from lidge-jun/chore/reconcile-dev-version
chore(release): move dev version line past the published channel
2 parents 890d339 + 15527f8 commit 8d828bd

3 files changed

Lines changed: 65 additions & 6 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitkyc08/opencodex",
3-
"version": "2.24.2",
3+
"version": "2.27.0",
44
"description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
55
"type": "module",
66
"main": "./bin/package-main.mjs",

‎src/service.ts‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,13 +1960,38 @@ function uninstallLaunchd(): void {
19601960
*
19611961
* The explicit `chmodSync` is not redundant: `mode` only applies when the file is
19621962
* created, so an install over a definition left at 0644 by an earlier version would keep
1963-
* the loose mode. On Windows the POSIX bits are advisory, so the real ACL is applied
1964-
* there the same way the token file does it.
1963+
* the loose mode.
1964+
*
1965+
* On Windows the POSIX bits are advisory, so the ACL is the real boundary — and whether it
1966+
* may soft-fail depends on what the definition actually contains. A definition carrying a
1967+
* proxy credential is a secret publication and fails closed like the API token and the
1968+
* install state do; one carrying only paths and a port is not worth refusing an install
1969+
* over, since before #2107 these files had no hardening at all and a failure here would
1970+
* regress a user who has no credential to protect.
19651971
*/
19661972
export function writeServiceDefinitionFile(path: string, content: string, encoding: "utf8" | "utf16le"): void {
19671973
writeFileSync(path, content, { encoding, mode: 0o600 });
1968-
try { chmodSync(path, 0o600); } catch { /* best-effort; the Windows ACL below is authoritative */ }
1969-
if (process.platform === "win32") hardenSecretPath(path, { required: false });
1974+
try { chmodSync(path, 0o600); } catch { /* superseded by the Windows ACL below */ }
1975+
if (process.platform === "win32") {
1976+
hardenSecretPath(path, { required: definitionCarriesCredential(content) });
1977+
}
1978+
}
1979+
1980+
/**
1981+
* Does this service definition embed a credential-bearing proxy URL?
1982+
*
1983+
* Only the userinfo form leaks something: `http://user:pass@host` in any of the four proxy
1984+
* variables. A bare `http://127.0.0.1:7890` is not a secret, and treating it as one would
1985+
* make an icacls stall fail an install that had nothing to protect.
1986+
*
1987+
* The scan is over any URL in the rendered definition rather than over a `KEY=value` shape,
1988+
* because the three formats render differently — systemd writes `Environment="K=V"`, the
1989+
* plist writes `<key>K</key><string>V</string>`, and the Windows wrapper writes
1990+
* `set "K=V"`. Keying on the assignment syntax silently missed the plist.
1991+
*/
1992+
export function definitionCarriesCredential(content: string): boolean {
1993+
// A userinfo authority: scheme, then anything that is not a delimiter, then '@'.
1994+
return /[a-z][a-z0-9+.-]*:\/\/[^\s"'<>/@]+@/i.test(content);
19701995
}
19711996

19721997
// ── Windows (Task Scheduler) ──

‎tests/service.test.ts‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { saveConfig } from "../src/config";
77
import { windowsEnvIndirectBatchValue } from "../src/lib/win-paths";
88
import { assertServiceAuthEnvironment, assertServiceEnvironmentMatchesInstall, bakedServicePathsDiagnostic, confirmServiceServing, launchdListenPort, systemdListenPort, buildPlist, buildUnit, buildWindowsLauncherVbs, buildWindowsSchtasksCreateArgs, buildWindowsSchtasksCreateArgsForXml, buildWindowsServiceScript, buildWindowsTaskXml, deriveWindowsServiceDiagnostic, installFreshWindowsSchedulerSafely, installServiceSafely, launchctlLoadFailed, launchdJobMatchesPlist, normalizeServiceSubcommand, parseServiceInstallState, prepareServiceInstall, readWindowsSchedulerXmlState, registerFreshWindowsSchedulerTask, removeNativeWindowsServiceForScheduler, repairService, resolveServiceListenPort, runLaunchctl, serviceLogPath, serviceStartableFromTray, serviceStatusReport, serviceRetryCommand, serviceStatusSummary, systemdNeedsDaemonReload, windowsListenPort, winswListenPort, startLaunchd, windowsTaskRegistrationHealthy } from "../src/service";
99
import type { ServiceDiagnostic } from "../src/service";
10-
import { resolvedProxyEnv, writeServiceDefinitionFile } from "../src/service";
10+
import { definitionCarriesCredential, resolvedProxyEnv, writeServiceDefinitionFile } from "../src/service";
1111
import { buildWinswXml } from "../src/lib/winsw";
1212
import { CONFIG_OWNER_FILE, CONFIG_UNINSTALL_MANIFEST, recordOwnedConfigPath, removeOwnedConfigState } from "../src/lib/config-ownership";
1313
import { serviceApiTokenFilePath } from "../src/lib/service-secrets";
@@ -2220,3 +2220,37 @@ describe("service definitions are not world-readable", () => {
22202220
}
22212221
});
22222222
});
2223+
2224+
// A pre-promotion audit flagged that this file's proxy-credential write used a soft-failing
2225+
// Windows ACL while the two adjacent secret writes — the API token and the install state —
2226+
// both fail closed. On Windows the POSIX mode bits are advisory, so a soft ACL failure can
2227+
// leave a proxy password readable by other local principals.
2228+
describe("credential-bearing definitions harden the Windows ACL strictly", () => {
2229+
test("a proxy URL with userinfo is treated as a secret publication", () => {
2230+
// `[email protected]` is the repo's existing URL-userinfo fixture: the privacy scanner
2231+
// reads "pw@host" as an email otherwise, and this exact pair is already allowlisted for
2232+
// tests/ (scripts/privacy-scan.ts:102). The shape under test is the userinfo authority,
2233+
// not the particular credential.
2234+
const unit = buildUnit(resolvedProxyEnv({ HTTPS_PROXY: "https://user:[email protected]:8080" }));
2235+
2236+
expect(definitionCarriesCredential(unit)).toBe(true);
2237+
});
2238+
2239+
test("a bare proxy URL is not a secret, so an icacls stall must not fail the install", () => {
2240+
// Before #2107 these files had no hardening at all; refusing an install over a stall
2241+
// would regress a user who has nothing to protect.
2242+
const unit = buildUnit(resolvedProxyEnv({ HTTP_PROXY: "http://127.0.0.1:7890", NO_PROXY: "localhost" }));
2243+
2244+
expect(definitionCarriesCredential(unit)).toBe(false);
2245+
});
2246+
2247+
test("lower-case spellings and the plist form are covered too", () => {
2248+
const plist = buildPlist(resolvedProxyEnv({ all_proxy: "socks5://u:[email protected]:1080" }));
2249+
2250+
expect(definitionCarriesCredential(plist)).toBe(true);
2251+
});
2252+
2253+
test("a definition with no proxy env at all carries no credential", () => {
2254+
expect(definitionCarriesCredential(buildUnit(resolvedProxyEnv({})))).toBe(false);
2255+
});
2256+
});

0 commit comments

Comments
 (0)