Skip to content

Real-time network monitor + outbound firewall — see & block every connection. Privacy-first, local-first, Rust fleet agent, SIEM exports, 8 languages. / Moniteur réseau temps réel + pare-feu sortant, agent de flotte Rust, exports SIEM. 100 % local.

Address CodeQL findings

MoneyLisa7676536cab69
diff --git a/.github/workflows/ci-agent.yml b/.github/workflows/ci-agent.yml
index 286b3e7..5c539c3 100644
--- a/.github/workflows/ci-agent.yml
+++ b/.github/workflows/ci-agent.yml
@@ -10,6 +10,11 @@
name: agent-ci
+# EN: read-only checkout + artifact upload — nothing else is needed.
+# FR: checkout lecture seule + upload d'artefacts — rien d'autre.
+permissions:
+ contents: read
+
on:
push:
paths: ["agent/**", ".github/workflows/ci-agent.yml"]
diff --git a/backend/api/main.py b/backend/api/main.py
index 4912609..128bcdf 100644
--- a/backend/api/main.py
+++ b/backend/api/main.py
@@ -2467,7 +2467,13 @@ async def list_interfaces() -> dict:
try:
devs = await loop.run_in_executor(None, list_devices)
except PcapError as exc:
- return {"interfaces": [], "current": None, "error": str(exc)}
+ # EN: log the real cause, return a fixed label — raw exception
+ # text leaks internal paths/versions to API clients.
+ # FR: logguer la cause réelle, renvoyer un libellé fixe — le
+ # texte d'exception divulgue chemins/versions internes.
+ logger.warning("pcap interface enumeration failed: %s", exc)
+ return {"interfaces": [], "current": None,
+ "error": "interface enumeration failed"}
return {
"interfaces": [
{"name": d.name, "description": d.description,
@@ -3043,7 +3049,12 @@ async def alert_rules_sigma(body: dict) -> dict:
try:
out = sig.convert(text)
except ValueError as exc:
- raise HTTPException(400, str(exc))
+ # EN: generic client-facing reason; details stay in the log —
+ # exception text is internal information (stack-trace exposure).
+ # FR: raison générique côté client ; les détails restent au log —
+ # le texte d'exception est une info interne (CodeQL).
+ logger.info("sigma import rejected: %s", exc)
+ raise HTTPException(400, "invalid sigma document")
imported = []
for r in out["rules"]:
try:
@@ -3051,7 +3062,8 @@ async def alert_rules_sigma(body: dict) -> dict:
r["severity"], "alert",
conds=r["conds"])
except ValueError as exc:
- out["skipped"].append(f"{r['name']}: {exc}")
+ logger.info("sigma rule %s skipped: %s", r["name"], exc)
+ out["skipped"].append(f"{r['name']}: invalid rule")
continue
rule["sigma_id"] = r["sigma_id"]
imported.append(rule)
diff --git a/backend/api/notify.py b/backend/api/notify.py
index 6faaf1e..839ecfc 100644
--- a/backend/api/notify.py
+++ b/backend/api/notify.py
@@ -26,6 +26,7 @@ import json
import logging
import socket as _socket
import threading
+import urllib.parse
import urllib.request
from datetime import datetime
@@ -140,9 +141,17 @@ class WebhookNotifier:
self._send_syslog(syslog_addr, alert, body)
if not enabled or not url:
return
- if "discord.com" in url or "slack.com" in url:
+ # EN: Host-matched provider detection — a substring check would
+ # misclassify `discord.com.evil.example` as Discord. Compare
+ # the parsed hostname (+ subdomain suffix), not the raw URL.
+ # FR: Détection du fournisseur par hôte — un test de sous-chaîne
+ # classerait `discord.com.evil.example` comme Discord. On
+ # compare le hostname parsé (+ suffixe de sous-domaine).
+ host = (urllib.parse.urlparse(url).hostname or "").lower()
+ if host == "discord.com" or host.endswith(".discord.com") \
+ or host == "slack.com" or host.endswith(".slack.com"):
payload = {"content": f"**{text}**"}
- elif "api.telegram.org" in url:
+ elif host == "api.telegram.org":
payload = {"text": text}
if chat_id:
payload["chat_id"] = chat_id
diff --git a/backend/detection/askmode.py b/backend/detection/askmode.py
index 8c5ef58..fd1c906 100644
--- a/backend/detection/askmode.py
+++ b/backend/detection/askmode.py
@@ -127,7 +127,20 @@ class AskMode:
ok, why = available()
if not ok:
return False, why
- self._exempt = list(exempt_ips or [])[:64]
+ # EN: Exempt IPs end up as `iptables -d <value>` argv — even
+ # without a shell, a crafted value could smuggle extra
+ # iptables flags. Only literal addresses/prefixes pass.
+ # FR: Les IP exemptées deviennent `iptables -d <valeur>` — même
+ # sans shell, une valeur forgée pourrait injecter des options
+ # iptables. Seules des adresses/préfixes littéraux passent.
+ import ipaddress
+ self._exempt = []
+ for ip in (exempt_ips or [])[:64]:
+ try:
+ ipaddress.ip_network(str(ip), strict=False)
+ except ValueError:
+ continue
+ self._exempt.append(str(ip))
import subprocess
from .nfqueue import NfqSocket # noqa: PLC0415
try:
diff --git a/backend/tests/test_v15_features.py b/backend/tests/test_v15_features.py
index 0aa1f68..378f2d4 100644
--- a/backend/tests/test_v15_features.py
+++ b/backend/tests/test_v15_features.py
@@ -181,7 +181,11 @@ def test_tls_cert_parsed_single_segment():
assert cert["subject_cn"] == "www.example.com"
assert cert["issuer_cn"] == "Example CA"
assert cert["self_signed"] is False
- assert "example.com" in cert["sans"]
+ # EN: exact SAN list — substring-style `in` is both weaker and a
+ # CodeQL substring-sanitization false-positive pattern.
+ # FR: liste SAN exacte — le `in` de sous-chaîne est plus faible et
+ # déclenche un faux positif CodeQL.
+ assert cert["sans"] == ["www.example.com", "example.com"]
assert cert["not_before"] == "250101000000Z"