Skip to content

Self-improving AI Employees for everyone

security: fix all open Dependabot and CodeQL alerts

trohitg3f175dce57de
diff --git a/package.json b/package.json
index 6ade66a1..a2bbe1ca 100644
--- a/package.json
+++ b/package.json
@@ -118,13 +118,15 @@
},
"overrides": {
"@babel/core@<7.29.6": "^7.29.7",
+ "@hono/node-server@<2.0.5": "^2.0.5",
"body-parser@>=2.0.0 <2.3.0": "^2.3.0",
"brace-expansion@<1.1.16": "^1.1.16",
"brace-expansion@>=5.0.0 <5.0.7": "^5.0.7",
"dompurify@>=3.0.0 <3.4.11": "^3.4.12",
"esbuild@<0.28.1": "^0.28.1",
- "form-data@>=4.0.0 <4.0.6": "^4.0.6",
- "hono@<4.12.21": "^4.12.21",
+ "fast-uri@>=3.0.0 <3.1.4": "^3.1.4",
+ "form-data@>=4.0.0 <4.0.6": "^4.0.6",
+ "hono@<4.12.27": "^4.12.27",
"js-cookie@<3.0.7": "^3.0.7",
"js-yaml@>=4.0.0 <4.2.0": "^4.2.0",
"qs@<6.15.2": "^6.15.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0fb1ed66..cdfdfaaf 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -6,13 +6,15 @@ settings:
overrides:
'@babel/core@<7.29.6': ^7.29.7
+ '@hono/node-server@<2.0.5': ^2.0.5
body-parser@>=2.0.0 <2.3.0: ^2.3.0
brace-expansion@<1.1.16: ^1.1.16
brace-expansion@>=5.0.0 <5.0.7: ^5.0.7
dompurify@>=3.0.0 <3.4.11: ^3.4.12
esbuild@<0.28.1: ^0.28.1
+ fast-uri@>=3.0.0 <3.1.4: ^3.1.4
form-data@>=4.0.0 <4.0.6: ^4.0.6
- hono@<4.12.21: ^4.12.21
+ hono@<4.12.27: ^4.12.27
js-cookie@<3.0.7: ^3.0.7
js-yaml@>=4.0.0 <4.2.0: ^4.2.0
qs@<6.15.2: ^6.15.2
@@ -897,11 +899,11 @@ packages:
react: ^16 || ^17 || ^18 || ^19
react-dom: ^16 || ^17 || ^18 || ^19
- resolution: {integrity: sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==}
- engines: {node: '>=18.14.1'}
+ resolution: {integrity: sha512-bjD221KPLoJTWUwso1J6fGKiTXEUFedG/s0visavY4zakFPkeGURMRNly+FhBHs7T8Dz4qHaZIMX9ZoJHSJtKA==}
+ engines: {node: '>=20'}
peerDependencies:
- hono: ^4.12.21
+ hono: ^4.12.27
'@hookform/[email protected]':
resolution: {integrity: sha512-A/IxlMLShx3KjV/HeTcTfaMxdwy690+L/ZADoeaTltLx+CVuzkeVIPuybK3jrRfw7YZnmdKsVVHAlEPIAEUNlA==}
@@ -3602,8 +3604,8 @@ packages:
resolution: {integrity: sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==}
- resolution: {integrity: sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==}
+ resolution: {integrity: sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==}
resolution: {integrity: sha512-rLV8JHxTyhVmFYhBJuMujcrHqOT2cnO5Zxj37qROj23CP39GXubJRBUFF0z8KFK77Uc0SukZUf7JZhsVEQ6n8w==}
@@ -3876,8 +3878,8 @@ packages:
resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==}
- resolution: {integrity: sha512-2NFaIyNVgJmBs/ecmtGzlmluTFs5cHEWGTdu0t1HBwYzoGXOL5nUQBRMXsXWla5i4KkG//QMzVP88m1+I3fdAQ==}
+ resolution: {integrity: sha512-XcuyW9qE2kJn07PkecMOBd5Vq/hMy7mmGw+idz1yblbg9N17ijJODrvPkn7/dwL3Kulj8LcRJ69DLOWf91dRUg==}
engines: {node: '>=16.9.0'}
@@ -7030,9 +7032,9 @@ snapshots:
react: 19.2.6
react-dom: 19.2.6([email protected])
dependencies:
- hono: 4.12.25
+ hono: 4.12.32
dependencies:
@@ -7294,7 +7296,7 @@ snapshots:
'@modelcontextprotocol/[email protected]([email protected])':
dependencies:
- '@hono/node-server': 1.19.14([email protected])
+ '@hono/node-server': 2.0.11([email protected])
ajv: 8.20.0
ajv-formats: 3.0.1([email protected])
content-type: 1.0.5
@@ -7304,7 +7306,7 @@ snapshots:
eventsource-parser: 3.0.8
express: 5.2.1
express-rate-limit: 8.5.1([email protected])
- hono: 4.12.25
+ hono: 4.12.32
jose: 6.2.3
json-schema-typed: 8.0.2
pkce-challenge: 5.0.1
@@ -9136,7 +9138,7 @@ snapshots:
dependencies:
fast-deep-equal: 3.1.3
- fast-uri: 3.1.2
+ fast-uri: 3.1.4
json-schema-traverse: 1.0.0
require-from-string: 2.0.2
@@ -10144,7 +10146,7 @@ snapshots:
dependencies:
fast-string-truncated-width: 3.0.3
dependencies:
@@ -10494,7 +10496,7 @@ snapshots:
dependencies:
react-is: 16.13.1
dependencies:
diff --git a/server/core/encryption.py b/server/core/encryption.py
index c0878ab8..d3ab925f 100644
--- a/server/core/encryption.py
+++ b/server/core/encryption.py
@@ -11,9 +11,10 @@ Security:
"""
import base64
+import hashlib
import logging
import os
-from typing import Optional
+from typing import Dict, Optional
from cryptography.fernet import Fernet, InvalidToken
from cryptography.hazmat.primitives import hashes
@@ -21,6 +22,33 @@ from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
logger = logging.getLogger(__name__)
+# Deterministic credential fingerprinting for in-memory cache keys. The salt is
+# a fixed context string (not a secret): fingerprints must be stable across
+# processes and restarts, so a random per-process salt would break cache-key
+# identity. PBKDF2 (not plain SHA-256) because credentials require a
+# computationally expensive hash (CodeQL py/weak-sensitive-data-hashing);
+# results are memoized so the KDF cost is paid once per credential per process.
+_FINGERPRINT_SALT = b"opencompany-credential-fingerprint-v1"
+_fingerprint_cache: Dict[str, str] = {}
+
+
+def fingerprint_credential(credential: str) -> str:
+ """Stable hex fingerprint of a credential (API key, token) for cache keys.
+
+ Never use for password verification storage; this is for deriving
+ non-reversible in-memory cache-key components from credentials.
+ """
+ cached = _fingerprint_cache.get(credential)
+ if cached is None:
+ cached = hashlib.pbkdf2_hmac(
+ "sha256",
+ credential.encode("utf-8"),
+ _FINGERPRINT_SALT,
+ EncryptionService.PBKDF2_ITERATIONS,
+ ).hex()
+ _fingerprint_cache[credential] = cached
+ return cached
+
class EncryptionService:
"""
diff --git a/server/services/llm/unifier.py b/server/services/llm/unifier.py
index 6190b4cb..ea323896 100644
--- a/server/services/llm/unifier.py
+++ b/server/services/llm/unifier.py
@@ -20,6 +20,7 @@ from collections import OrderedDict
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, TYPE_CHECKING
+from core.encryption import fingerprint_credential
from core.logging import get_logger
from services.llm.protocol import (
LLMError,
@@ -353,9 +354,7 @@ class ChatUnifier:
proxy_url: Optional[str],
sdk_max_retries: int,
) -> str:
- credential_fingerprint = hashlib.sha256(
- api_key.encode("utf-8")
- ).hexdigest()
+ credential_fingerprint = fingerprint_credential(api_key)
material = json.dumps(
{
"provider": spec.name,
diff --git a/server/services/memory/vector_store.py b/server/services/memory/vector_store.py
index bfe908fb..148c6985 100644
--- a/server/services/memory/vector_store.py
+++ b/server/services/memory/vector_store.py
@@ -8,7 +8,6 @@ model construction and encoding run through :func:`asyncio.to_thread`.
from __future__ import annotations
import asyncio
-import hashlib
import importlib.util
import inspect
import math
@@ -18,6 +17,7 @@ from dataclasses import dataclass, field
from typing import Any, Dict, Iterable, List, Literal, Optional, Protocol
from uuid import uuid4
+from core.encryption import fingerprint_credential
from core.logging import get_logger
logger = get_logger(__name__)
@@ -482,7 +482,7 @@ class NativeMemoryVectorStore:
def _credential_fingerprint(api_key: Optional[str]) -> str:
if not api_key:
return "none"
- return hashlib.sha256(api_key.encode("utf-8")).hexdigest()[:16]
+ return fingerprint_credential(api_key)[:16]
async def get_memory_vector_store(