Skip to content

Commit ee96e96

Browse files
xinhuagujalehman
authored andcommitted
fix(plugins): strip profileId/preferredProfile from plugin modelAuth wrappers
Address Aisle CWE-862: plugins could use profileId to resolve credentials for arbitrary profiles regardless of provider, enabling cross-provider credential access. Now plugins can only specify provider/model — the core auth pipeline picks the appropriate credential. The TypeScript type is also narrowed so plugin authors cannot pass profileId at compile time.
1 parent 8e0fd21 commit ee96e96

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/plugins/runtime/index.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,21 @@ export function createPluginRuntime(_options: CreatePluginRuntimeOptions = {}):
6464
logging: createRuntimeLogging(),
6565
state: { resolveStateDir },
6666
modelAuth: {
67-
// Wrap model-auth helpers to prevent plugins from passing arbitrary
68-
// agentDir / store overrides, which would let them steer credential
69-
// lookups outside their own context. Only provider, model, cfg, and
70-
// profileId are forwarded.
67+
// Wrap model-auth helpers so plugins cannot steer credential lookups:
68+
// - agentDir / store: stripped (prevents reading other agents' stores)
69+
// - profileId / preferredProfile: stripped (prevents cross-provider
70+
// credential access via profile steering)
71+
// Plugins only specify provider/model; the core auth pipeline picks
72+
// the appropriate credential automatically.
7173
getApiKeyForModel: (params) =>
7274
getApiKeyForModelRaw({
7375
model: params.model,
7476
cfg: params.cfg,
75-
profileId: params.profileId,
76-
preferredProfile: params.preferredProfile,
7777
}),
7878
resolveApiKeyForProvider: (params) =>
7979
resolveApiKeyForProviderRaw({
8080
provider: params.provider,
8181
cfg: params.cfg,
82-
profileId: params.profileId,
83-
preferredProfile: params.preferredProfile,
8482
}),
8583
},
8684
} satisfies PluginRuntime;

src/plugins/runtime/types-core.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ export type PluginRuntimeCore = {
5353
resolveStateDir: typeof import("../../config/paths.js").resolveStateDir;
5454
};
5555
modelAuth: {
56-
getApiKeyForModel: typeof import("../../agents/model-auth.js").getApiKeyForModel;
57-
resolveApiKeyForProvider: typeof import("../../agents/model-auth.js").resolveApiKeyForProvider;
56+
/** Resolve auth for a model. Only provider/model and optional cfg are used. */
57+
getApiKeyForModel: (params: {
58+
model: import("@mariozechner/pi-ai").Model<import("@mariozechner/pi-ai").Api>;
59+
cfg?: import("../../config/config.js").OpenClawConfig;
60+
}) => Promise<import("../../agents/model-auth.js").ResolvedProviderAuth>;
61+
/** Resolve auth for a provider by name. Only provider and optional cfg are used. */
62+
resolveApiKeyForProvider: (params: {
63+
provider: string;
64+
cfg?: import("../../config/config.js").OpenClawConfig;
65+
}) => Promise<import("../../agents/model-auth.js").ResolvedProviderAuth>;
5866
};
5967
};

0 commit comments

Comments
 (0)