Skip to content

Commit fe64c71

Browse files
committed
fix(qqbot): keep a configured upgrade guide off unauthenticated replies
/bot-upgrade is deliberately outside the allowlist, so returning the operator-configured upgradeUrl exposed a potentially private runbook to any C2C contact. Authorized senders get the configured guide; everyone else keeps the bundled public link.
1 parent c706e8c commit fe64c71

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

‎docs/channels/qqbot.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,11 @@ silently dropping the message.
350350
require the allowlist — any C2C sender can run them.
351351

352352
`/bot-upgrade` returns the `upgradeUrl` configured for the account that received
353-
the command. The key is accepted at `channels.qqbot.upgradeUrl` and at
354-
`channels.qqbot.accounts.<id>.upgradeUrl`. Leave it unset to keep the bundled
355-
OpenClaw upgrade guide link.
353+
the command, but only to a sender on the explicit non-wildcard allowlist. Any
354+
other C2C sender gets the bundled public OpenClaw guide, so a private runbook URL
355+
is never exposed by this unauthenticated command. The key is accepted at
356+
`channels.qqbot.upgradeUrl` and at `channels.qqbot.accounts.<id>.upgradeUrl`;
357+
leave it unset to always return the bundled link.
356358

357359
When QQ Bot exec approvals use the default same-chat fallback, native approval
358360
button clicks follow the same explicit non-wildcard command allowlist. To

‎extensions/qqbot/src/engine/commands/builtin/register-basic.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,16 @@ export function registerBasicBotCommands(registry: SlashCommandRegistry): void {
9292
c2cOnly: true,
9393
usage: [`/bot-upgrade`, ``, `查看 QQBot 升级说明。`].join("\n"),
9494
// channels.qqbot.upgradeUrl documents itself as the URL this command returns,
95-
// so an operator-configured guide wins over the bundled default.
95+
// so an operator-configured guide wins over the bundled default. This command
96+
// is deliberately outside the allowlist, and a configured guide may be a
97+
// private runbook, so only authorized senders see it; everyone else keeps the
98+
// public bundled link.
9699
handler: (ctx) => {
97-
const configuredUrl =
98-
typeof ctx.accountConfig?.upgradeUrl === "string"
100+
const configuredUrl = ctx.commandAuthorized
101+
? typeof ctx.accountConfig?.upgradeUrl === "string"
99102
? normalizeOptionalString(ctx.accountConfig.upgradeUrl)
100-
: undefined;
103+
: undefined
104+
: undefined;
101105
return [
102106
`📘 QQBot 升级指引:`,
103107
`[点击查看升级说明](${configuredUrl ?? QQBOT_UPGRADE_GUIDE_URL})`,

‎extensions/qqbot/src/engine/commands/slash-commands-impl.test.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,20 +308,23 @@ describe("QQBot framework slash commands", () => {
308308
});
309309

310310
describe("bot-upgrade guide url", () => {
311-
function runUpgradeCommand(accountConfig: SlashCommandContext["accountConfig"]): string {
311+
function runUpgradeCommand(
312+
accountConfig: SlashCommandContext["accountConfig"],
313+
commandAuthorized = true,
314+
): string {
312315
const registry = new SlashCommandRegistry();
313316
registerBasicBotCommands(registry);
314317
const command = registry.getAllCommands().get("bot-upgrade");
315318
if (!command) {
316319
throw new Error("bot-upgrade command not registered");
317320
}
318321
const result = command.handler(
319-
createStreamingContext({ rawContent: "/bot-upgrade", accountConfig }),
322+
createStreamingContext({ rawContent: "/bot-upgrade", accountConfig, commandAuthorized }),
320323
);
321324
return typeof result === "string" ? result : "";
322325
}
323326

324-
it("returns the operator-configured upgrade url", () => {
327+
it("returns the operator-configured upgrade url to an authorized sender", () => {
325328
const output = runUpgradeCommand({
326329
allowFrom: ["*"],
327330
upgradeUrl: "https://ops.example.com/qqbot-upgrade",
@@ -330,6 +333,17 @@ describe("bot-upgrade guide url", () => {
330333
expect(output).not.toContain("q.qq.com/qqbot/openclaw/upgrade.html");
331334
});
332335

336+
it("never reveals a configured guide to an unauthorized C2C sender", () => {
337+
// /bot-upgrade is deliberately outside the allowlist, so any contact can run
338+
// it. A configured guide may be a private runbook and must not leak here.
339+
const output = runUpgradeCommand(
340+
{ allowFrom: ["*"], upgradeUrl: "https://ops.example.com/qqbot-upgrade" },
341+
false,
342+
);
343+
expect(output).not.toContain("ops.example.com");
344+
expect(output).toContain("q.qq.com/qqbot/openclaw/upgrade.html");
345+
});
346+
333347
it("falls back to the bundled guide when the key is unset or blank", () => {
334348
expect(runUpgradeCommand({ allowFrom: ["*"] })).toContain(
335349
"q.qq.com/qqbot/openclaw/upgrade.html",

0 commit comments

Comments
 (0)