mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:31:23 +00:00
security(gateway): block webchat session mutators (#20800)
* chore(ci): local claude settings gitignore * Gateway: block webchat session mutators * Changelog: note webchat session mutator guard * Changelog: credit report for webchat mutator guard
This commit is contained in:
@@ -231,7 +231,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
}
|
||||
respond(true, { ok: true, key: resolved.key }, undefined);
|
||||
},
|
||||
"sessions.patch": async ({ params, respond, context }) => {
|
||||
"sessions.patch": async ({ params, respond, context, client, isWebchatConnect }) => {
|
||||
if (!assertValidParams(params, validateSessionsPatchParams, "sessions.patch", respond)) {
|
||||
return;
|
||||
}
|
||||
@@ -240,6 +240,17 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
if (client?.connect && isWebchatConnect(client.connect)) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(
|
||||
ErrorCodes.INVALID_REQUEST,
|
||||
"webchat clients cannot patch sessions; use chat.send for session-scoped updates",
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const { cfg, target, storePath } = resolveGatewaySessionTargetFromKey(key);
|
||||
const applied = await updateSessionStore(storePath, async (store) => {
|
||||
@@ -346,7 +357,7 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
});
|
||||
respond(true, { ok: true, key: target.canonicalKey, entry: next }, undefined);
|
||||
},
|
||||
"sessions.delete": async ({ params, respond }) => {
|
||||
"sessions.delete": async ({ params, respond, client, isWebchatConnect }) => {
|
||||
if (!assertValidParams(params, validateSessionsDeleteParams, "sessions.delete", respond)) {
|
||||
return;
|
||||
}
|
||||
@@ -355,6 +366,17 @@ export const sessionsHandlers: GatewayRequestHandlers = {
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
if (client?.connect && isWebchatConnect(client.connect)) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(
|
||||
ErrorCodes.INVALID_REQUEST,
|
||||
"webchat clients cannot delete sessions; use chat.send for session-scoped updates",
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const { cfg, target, storePath } = resolveGatewaySessionTargetFromKey(key);
|
||||
const mainKey = resolveMainSessionKey(cfg);
|
||||
|
||||
Reference in New Issue
Block a user