Skip to content

Commit 60292e2

Browse files
lwy-2claude
andcommitted
fix(nextcloud-talk,discord): bound response body reads for webhook and error paths
Bound two unbounded response body reads to prevent potential OOM: - extensions/nextcloud-talk/src/bot-preflight.ts: error-path response.text() for Nextcloud API error body was unbounded. - extensions/discord/src/send.webhook.ts: happy-path response.json() for Discord webhook send result was unbounded (error path already used readResponseTextLimited). These follow the same project-wide bound-response-read pattern. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8afcab3 commit 60292e2

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

extensions/discord/src/send.webhook.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Discord plugin module implements send.webhook behavior.
22
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
33
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
4-
import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
4+
import {
5+
readProviderJsonResponse,
6+
readResponseTextLimited,
7+
} from "openclaw/plugin-sdk/provider-http";
58
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
69
import { resolveDiscordClientAccountContext } from "./client.js";
710
import {
@@ -120,10 +123,10 @@ export async function sendWebhookMessageDiscord(
120123
await throwWebhookResponseError(response);
121124
}
122125

123-
const payload = (await response.json().catch(() => ({}))) as {
126+
const payload = await readProviderJsonResponse<{
124127
id?: string;
125128
channel_id?: string;
126-
};
129+
}>(response, "Discord webhook send").catch(() => ({}) as { id?: string; channel_id?: string });
127130
try {
128131
recordChannelActivity({
129132
channel: "discord",

extensions/nextcloud-talk/src/bot-preflight.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Nextcloud Talk plugin module implements bot preflight behavior.
22
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
33
import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
4-
import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
4+
import {
5+
readProviderJsonResponse,
6+
readResponseTextLimited,
7+
} from "openclaw/plugin-sdk/provider-http";
58
import { fetchWithSsrFGuard } from "../runtime-api.js";
69
import type { ResolvedNextcloudTalkAccount } from "./accounts.js";
710
import { resolveNextcloudTalkApiCredentials } from "./api-credentials.js";
@@ -125,7 +128,7 @@ export async function probeNextcloudTalkBotResponseFeature(params: {
125128
});
126129
try {
127130
if (!response.ok) {
128-
const body = await response.text().catch(() => "");
131+
const body = await readResponseTextLimited(response, 4 * 1024).catch(() => "");
129132
return {
130133
ok: false,
131134
code: "api_error",

0 commit comments

Comments
 (0)