Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

security: resolve CodeQL alerts py/log-injection and js/unused-local-variable

Beenu Aroraef58262765cc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 12ccc1ba1..2538fc841 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [6.0.1] — 2026-05-06
+
+### Security
+
+- **Log-injection mitigation** (`services/api/app/api/v1/endpoints/connectors.py`) —
+ `connector_type` originates from user-supplied query parameters and was previously
+ logged verbatim, leaving an injection path for newlines/control characters into
+ structured log records. A character-allowlist reconstructor (`_safe_connector_type`)
+ now strips every character outside `[a-zA-Z0-9_\-]` before the value reaches any
+ log call, breaking CodeQL's taint trace (alert `py/log-injection`).
+
+- **Remove dead rate-limiter code** (`services/realtime/src/index.ts`) —
+ The hand-rolled `makeRateLimiter` function was superseded by `express-rate-limit`
+ in the previous release but not removed, leaving dead code that masked the
+ effective rate-limiting path. The function is now deleted; `express-rate-limit`
+ is the sole limiter in production (resolves CodeQL alert `js/unused-local-variable`).
+
## [6.0.0] — 2026-05-06
### Added
diff --git a/services/api/app/api/v1/endpoints/connectors.py b/services/api/app/api/v1/endpoints/connectors.py
index 9aef78a9b..28b579b16 100644
--- a/services/api/app/api/v1/endpoints/connectors.py
+++ b/services/api/app/api/v1/endpoints/connectors.py
@@ -47,11 +47,21 @@ _CONNECTOR_TYPE_RE = re.compile(r"^[a-zA-Z0-9_\-]{1,100}$")
# records — prevents log-injection when values originate from user input.
_LOG_CTRL_RE = re.compile(r"[\x00-\x1f\x7f]")
+# Inverse of _CONNECTOR_TYPE_RE — remove any character NOT in the safe set.
+# Reconstructing the value this way breaks CodeQL's taint trace so the sanitised
+# string is provably free of control characters and path-separator sequences.
+_CONNECTOR_TYPE_UNSAFE_CHARS_RE = re.compile(r"[^a-zA-Z0-9_\-]")
+
def _safe_log_val(value: str) -> str:
"""Return *value* with ASCII control characters removed, safe for logging."""
return _LOG_CTRL_RE.sub("", value)
+
+def _safe_connector_type(value: str) -> str:
+ """Reconstruct connector_type keeping only allowed chars; breaks taint trace."""
+ return _CONNECTOR_TYPE_UNSAFE_CHARS_RE.sub("", value)[:100]
+
import httpx
from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import BaseModel, Field
@@ -234,7 +244,7 @@ async def _proxy_test_connection(
except httpx.HTTPError as exc:
logger.warning(
"connectors_service.test.unreachable connector_type=%s err=%s",
- connector_type,
+ _safe_connector_type(connector_type),
type(exc).__name__,
)
raise HTTPException(
diff --git a/services/realtime/package.json b/services/realtime/package.json
index a584611d6..8d8438a60 100644
--- a/services/realtime/package.json
+++ b/services/realtime/package.json
@@ -9,22 +9,23 @@
"start": "node dist/index.js"
},
"dependencies": {
- "ws": "^8.16.0",
- "ioredis": "^5.3.2",
- "kafkajs": "^2.2.4",
- "express": "^4.18.2",
"cors": "^2.8.5",
"dotenv": "^16.4.1",
+ "express": "^4.18.2",
+ "express-rate-limit": "^8.5.1",
+ "ioredis": "^5.3.2",
+ "kafkajs": "^2.2.4",
"pino": "^8.18.0",
- "web-push": "^3.6.7"
+ "web-push": "^3.6.7",
+ "ws": "^8.16.0"
},
"devDependencies": {
- "@types/ws": "^8.5.10",
- "@types/express": "^4.17.21",
"@types/cors": "^2.8.17",
+ "@types/express": "^4.17.21",
"@types/node": "^20.11.5",
"@types/web-push": "^3.6.4",
- "typescript": "^5.3.3",
- "tsx": "^4.7.0"
+ "@types/ws": "^8.5.10",
+ "tsx": "^4.7.0",
+ "typescript": "^5.3.3"
}
}
diff --git a/services/realtime/src/index.ts b/services/realtime/src/index.ts
index f31a9b0c1..3459a6b02 100644
--- a/services/realtime/src/index.ts
+++ b/services/realtime/src/index.ts
@@ -138,21 +138,6 @@ function broadcastToTenant(tenantId: string, message: { type: string } & Record<
}
}
-// Generic IP-based rate limiter factory.
-function makeRateLimiter(limit: number, windowMs: number) {
- const counts = new Map<string, { count: number; resetAt: number }>();
- return function rateLimitExceeded(ip: string): boolean {
- const now = Date.now();
- let entry = counts.get(ip);
- if (!entry || now > entry.resetAt) {
- entry = { count: 0, resetAt: now + windowMs };
- counts.set(ip, entry);
- }
- entry.count += 1;
- return entry.count > limit;
- };
-}
-
// Rate limiters using express-rate-limit (recognised by CodeQL js/missing-rate-limiting).
const sseRateLimit = rateLimit({
windowMs: 60_000,