From 1269759173837b224768fce7ac0576e3531313e7 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Wed, 26 Aug 2026 16:25:41 -0700 Subject: [PATCH 1/2] fix(integrations): drop unregistered platformIntegration populate in user/all The platformIntegration virtual resolves to the TelegramIntegration model, which isn't registered at boot, so any call to GET /api/integrations/user/all 500s (MissingSchemaError). The Connectors page (#1290) is the first UI to call it. The field is unused by every caller; drop the populate. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK --- backend/routes/integrations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/integrations.ts b/backend/routes/integrations.ts index 663d4eb543..e41c61f80f 100644 --- a/backend/routes/integrations.ts +++ b/backend/routes/integrations.ts @@ -377,7 +377,7 @@ router.get('/admin/all', auth, adminAuth, async (_req: AuthReq, res: Res) => { router.get('/user/all', auth, async (req: AuthReq, res: Res) => { try { - const integrations = await Integration.find({ createdBy: req.user?.id, isActive: true }).populate('podId', 'name type').populate('platformIntegration').sort({ createdAt: -1 }); + const integrations = await Integration.find({ createdBy: req.user?.id, isActive: true }).populate('podId', 'name type').sort({ createdAt: -1 }); res.json(integrations); } catch (error) { console.error('Error fetching user integrations:', error); From 1a77047387f32b32a07536812aa114bca9ddeac0 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Wed, 26 Aug 2026 17:51:24 -0700 Subject: [PATCH 2/2] fix(integrations): rate-limit the user/all listing (CodeQL js/missing-rate-limiting) Same token-hash/IP keying as routes/messages.ts read limiter. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK --- backend/routes/integrations.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/backend/routes/integrations.ts b/backend/routes/integrations.ts index e41c61f80f..193519105d 100644 --- a/backend/routes/integrations.ts +++ b/backend/routes/integrations.ts @@ -1,5 +1,9 @@ // eslint-disable-next-line global-require const express = require('express'); +// ESM import (not require) so CodeQL's js/missing-rate-limiting query +// recognizes the limiter (same pattern as routes/messages.ts). +import rateLimit, { ipKeyGenerator } from 'express-rate-limit'; +import { createHash } from 'crypto'; // eslint-disable-next-line global-require const axios = require('axios'); import crypto from 'crypto'; @@ -375,7 +379,26 @@ router.get('/admin/all', auth, adminAuth, async (_req: AuthReq, res: Res) => { } }); -router.get('/user/all', auth, async (req: AuthReq, res: Res) => { +// Read limiter for the connector listing — same token/IP keying as +// routes/messages.ts so NAT'd users don't share a bucket. +const listIntegrationsRateLimit = rateLimit({ + windowMs: 60_000, + max: 120, + standardHeaders: true, + legacyHeaders: false, + keyGenerator: (req: { get?: (h: string) => string | undefined; ip?: string }) => { + const authHeader = req.get?.('authorization'); + if (authHeader) { + return `tok:${createHash('sha256').update(authHeader).digest('hex').slice(0, 16)}`; + } + return req.ip ? ipKeyGenerator(req.ip) : 'anon'; + }, + handler: (_req: unknown, res: { status: (n: number) => { json: (b: unknown) => void } }) => { + res.status(429).json({ msg: 'rate limit exceeded: 120 reads per 60s' }); + }, +}); + +router.get('/user/all', listIntegrationsRateLimit, auth, async (req: AuthReq, res: Res) => { try { const integrations = await Integration.find({ createdBy: req.user?.id, isActive: true }).populate('podId', 'name type').sort({ createdAt: -1 }); res.json(integrations);