The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 13:15 UTC
fix(settings): servers check secret provider writes and keep unknown configs to themselves (#27044)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 29, 2026 at 10:42 UTC
ee81ea4ce80ad21f5ee89b810127acf3ac126b1d
7 files changed
+75
-11
apps/server/src/serverSettings.test.ts
+18
@@ -235,6 +235,24 @@ it.layer(NodeServices.layer)("server settings", (it) => {
235
}).pipe(Effect.provide(layerServerSettings())),
236
);
237
238
+ it.effect("sends clients a known secret provider's config but never an unknown kind's", () =>
239
+ Effect.gen(function* () {
240
+ const settings = yield* decodeServerSettings({
241
+ secretProviders: {
242
+ personal: { kind: "one_password", label: "Personal", config: { account: "my" } },
243
+ vault: { kind: "openbao", label: "Vault", config: { token: "bao-token" } },
244
+ },
245
+ });
246
+ assert.deepStrictEqual<unknown>(
247
+ ServerSettingsModule.redactServerSettingsForClient(settings).secretProviders,
248
+ {
249
+ personal: { kind: "one_password", label: "Personal", config: { account: "my" } },
250
+ vault: { kind: "openbao", label: "Vault" },
251
+ },
252
+ );
253
+ }),
254
+ );
255
+
256
it.effect("saves through a symlinked settings file without replacing the link", () =>
257
Effect.gen(function* () {
258
const config = yield* ServerConfig.ServerConfig;
apps/server/src/serverSettings.ts
+16
-1
@@ -7,6 +7,7 @@ import {
7
type ProviderInstanceConfig,
8
type ProviderInstanceMutation,
9
defaultInstanceIdForDriver,
10
+ isKnownSecretProviderKind,
11
isProviderDriverKind,
12
ProviderDriverKind,
13
ProviderInstanceId,
@@ -128,11 +129,25 @@ const normalizeServerSettings = (
129
);
130
131
export function redactServerSettingsForClient(settings: ServerSettings): ServerSettings {
131
- return mapSettingsSecrets(settings, (secret) =>
132
+ const redacted = mapSettingsSecrets(settings, (secret) =>
133
secret.sensitive
134
? { value: "", redacted: secret.redacted || secret.value.length > 0 }
135
: { value: secret.value, redacted: false },
136
);
137
+ return { ...redacted, secretProviders: withoutUnknownSecretProviderConfigs(redacted) };
138
+}
139
+
140
+// A newer kind's config may hold credentials this build cannot recognize, so it never leaves the server.
141
+function withoutUnknownSecretProviderConfigs(
142
+ settings: ServerSettings,
143
+): ServerSettings["secretProviders"] {
144
+ return Object.fromEntries(
145
+ Object.entries(settings.secretProviders).map(([id, entry]) => {
146
+ if (isKnownSecretProviderKind(entry.kind)) return [id, entry];
147
+ const { config: _config, ...envelope } = entry;
148
+ return [id, envelope];
149
+ }),
150
+ ) as ServerSettings["secretProviders"];
151
}
152
153
export function applyProviderInstanceMutation(
apps/server/src/ws.ts
+1
@@ -1791,6 +1791,7 @@ export const layerWsRpc = (
1791
threadSnapshotPagination: true,
1792
threadFind: true,
1793
threadFindProgressive: true,
1794
+ secretProviderSettings: true,
1795
...Option.match(scratchWorkspaceRoot, {
1796
onNone: () => ({}),
1797
onSome: (root) => ({ scratchWorkspaceRoot: root }),
apps/web/src/components/settings/SecretsSettings.tsx
+10
-1
@@ -35,9 +35,18 @@ const SECRET_PROVIDER_KINDS: Readonly<
35
36
export function SecretsSettingsPanel() {
37
const { scope, environment } = useSettingsScope();
38
+ const connected = environment?.connection.phase === "connected";
39
return (
40
<SettingsPageContainer>
40
- {environment?.connection.phase === "connected" ? (
41
+ {connected &&
42
+ environment.serverConfig !== null &&
43
+ environment.serverConfig.secretProviderSettings !== true ? (
44
+ <SettingsSection {...searchableSetting("secret-providers")}>
45
+ <p className="px-4 py-3 text-sm text-muted-foreground">
46
+ Update T3 Code on {environment.label} to manage its secret providers.
47
+ </p>
48
+ </SettingsSection>
49
+ ) : connected ? (
50
<EnvironmentSecretProviders
51
key={environment.environmentId}
52
environment={environment}
packages/contracts/src/server.ts
+2
@@ -638,6 +638,8 @@ export const ServerConfig = Schema.Struct({
638
threadSnapshotPagination: Schema.optionalKey(Schema.Boolean),
639
threadFind: Schema.optionalKey(Schema.Boolean),
640
threadFindProgressive: Schema.optionalKey(Schema.Boolean),
641
+ /** Settings patches may carry `secretProviders`; older servers drop the key without an error. */
642
+ secretProviderSettings: Schema.optionalKey(Schema.Boolean),
643
scratchWorkspaceRoot: Schema.optionalKey(TrimmedNonEmptyString),
644
newProjectsRoot: Schema.optionalKey(TrimmedNonEmptyString),
645
/**
packages/contracts/src/settings.test.ts
+6
-7
@@ -15,7 +15,6 @@ import {
15
resolveProjectProviderInstanceEnabled,
16
resolveProviderInstanceEnabled,
17
ServerSettings,
18
- OnePasswordSecretProviderConfig,
18
ServerSettingsPatch,
19
withIdleCompaction,
20
} from "./settings.ts";
@@ -26,7 +25,6 @@ const encodeClientSettings = Schema.encodeSync(ClientSettingsSchema);
25
const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
26
const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
27
const encodeServerSettings = Schema.encodeSync(ServerSettings);
29
-const decodeOnePasswordConfig = Schema.decodeUnknownSync(OnePasswordSecretProviderConfig);
28
const decodeClaudeSettings = Schema.decodeUnknownSync(ClaudeSettings);
29
30
describe("storage cleanup settings", () => {
@@ -155,13 +153,14 @@ describe("ServerSettings secret providers", () => {
153
).toThrow();
154
});
155
158
- it("rejects a 1Password account op could misread", () => {
156
+ it("rejects writes of an unknown kind or an account op could misread", () => {
157
+ const write = (entry: unknown) => () =>
158
+ decodeServerSettingsPatch({ secretProviders: { personal: entry } });
159
for (const account of ["", "my account", "--help"]) {
160
- expect(() => decodeOnePasswordConfig({ account })).toThrow();
160
+ expect(write(onePassword(account))).toThrow();
161
}
162
- expect(decodeOnePasswordConfig({ account: "my.1password.com" }).account).toBe(
163
- "my.1password.com",
164
- );
162
+ expect(write({ kind: "one_password", label: "Personal" })).toThrow();
163
+ expect(write({ kind: "openbao", label: "Vault", config: { address: "https://x" } })).toThrow();
164
});
165
});
166
packages/contracts/src/settings.ts
+22
-2
@@ -859,7 +859,7 @@ export const UsageLimitSourceConfig = Schema.Struct({
859
});
860
export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type;
861
862
-// Final once shipped: a key or field that fails here fails the whole settings decode on older builds.
862
+// Final once shipped: older builds drop entries whose key fails here, and erase them on their next save.
863
// Unlike provider slugs it may start with a digit, so a provider named "1Password" fits.
864
const SecretProviderSlug = TrimmedNonEmptyString.check(
865
Schema.isMaxLength(64),
@@ -903,11 +903,31 @@ export const SecretProviderConfig = Schema.Struct({
903
});
904
export type SecretProviderConfig = typeof SecretProviderConfig.Type;
905
906
+/** Kinds this build can resolve. Their `config` holds no credentials, so clients may read it. */
907
+const SECRET_PROVIDER_KIND_CONFIG_GUARDS: Readonly<Record<string, (config: unknown) => boolean>> = {
908
+ one_password: Schema.is(OnePasswordSecretProviderConfig),
909
+};
910
+
911
+export function isKnownSecretProviderKind(kind: string): boolean {
912
+ return Object.hasOwn(SECRET_PROVIDER_KIND_CONFIG_GUARDS, kind);
913
+}
914
+
915
// Limits that may change later are enforced on writes only, never on the stored envelope.
916
+// Writes must be a kind this build knows with a config it accepts, so an older server
917
+// rejects a newer kind instead of storing what it cannot check.
918
const SecretProviderConfigWrite = Schema.Struct({
919
...SecretProviderConfig.fields,
920
label: SecretProviderLabel,
910
-});
921
+}).check(
922
+ Schema.makeFilter((entry) => {
923
+ if (!isKnownSecretProviderKind(entry.kind)) {
924
+ return `Unsupported secret provider kind: ${entry.kind}.`;
925
+ }
926
+ return SECRET_PROVIDER_KIND_CONFIG_GUARDS[entry.kind]!(entry.config)
927
+ ? true
928
+ : `Invalid ${entry.kind} secret provider config.`;
929
+ }),
930
+);
931
932
export const SourceControlHostSettings = Schema.Record(Schema.String, Schema.Unknown);
933
export type SourceControlHostSettings = typeof SourceControlHostSettings.Type;