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.

Release v1.6.4 — icon fix, elevated-run data dir ownership

MoneyLisa6b2040eac869
diff --git a/.gitignore b/.gitignore
index 1a7f2c1..489a244 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,9 +24,6 @@ data/
*.db-shm
*.mmdb
-# EN: Electron generated files / FR: Fichiers générés Electron
-electron/icon.png
-
# EN: Pinokio launcher artifacts / FR: Artefacts du launcher Pinokio
backend/env/
frontend_dist/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c217e2f..4e66575 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,9 @@ All notable changes to Snitch. / Toutes les modifications notables de Snitch.
The format follows [Keep a Changelog](https://keepachangelog.com/) — EN/FR.
-## [Unreleased] — security & efficiency hardening / durcissement sécurité & efficacité
+## [Unreleased]
+
+## [1.6.4] — 2026-10-23 — security & efficiency hardening / durcissement sécurité & efficacité
### Security / Sécurité
@@ -141,6 +143,29 @@ The format follows [Keep a Changelog](https://keepachangelog.com/) — EN/FR.
FR: workflow release — `workflow_dispatch` pour republication
manuelle ; le garde winget n'échoue plus quand le compte est non nul.
+- EN: **Packaged app icon restored** — `generate-icon.js` used to
+ redraw the deprecated wireframe "radar eye" and overwrite `icon.png`
+ on every build; the committed monogram is now the single icon source
+ for Windows/macOS/Linux artifacts.
+ FR: **Icône de l'app packagée restaurée** — `generate-icon.js`
+ redessinait l'ancien « œil radar » et écrasait `icon.png` à chaque
+ build ; le monogramme commité est désormais la source unique.
+- EN: **Elevated backend no longer bricks the data dir** — files it
+ creates (logs, `snitch.db`, `api_token.txt`) are chowned back to the
+ real user via `SNITCH_OWNER_UID/GID` (on every write and again
+ recursively at shutdown), instead of leaving root-owned files that
+ killed the next unprivileged launch with EACCES.
+ FR: **Le backend élevé ne brique plus le dossier de données** — les
+ fichiers qu'il crée sont rendus à l'utilisateur réel via
+ `SNITCH_OWNER_UID/GID` (à chaque écriture et récursivement à l'arrêt),
+ au lieu de laisser des fichiers root qui tuaient le lancement suivant.
+- EN: Electron now shows a bilingual error with the repair command when
+ `userData` is unwritable (e.g. root-owned leftovers) instead of dying
+ silently.
+ FR: Electron affiche désormais une erreur bilingue avec la commande de
+ réparation quand `userData` est inscriptible, au lieu de mourir en
+ silence.
+
## [1.6.3] — 2026-10-22 — hygiene & hardening / hygiène & durcissement
### Fixed / Corrigé
diff --git a/README.md b/README.md
index 898c5d3..7b492dc 100644
--- a/README.md
+++ b/README.md
@@ -219,7 +219,7 @@ cd ../frontend
npm ci
npm run build
-# 3 — Build Electron installer (the icon is generated automatically)
+# 3 — Build Electron installer
cd ../electron
npm ci
npm run build # NSIS installer -> dist/installer/Snitch Setup <version>.exe
diff --git a/backend/api/main.py b/backend/api/main.py
index 262b759..8eec4f9 100644
--- a/backend/api/main.py
+++ b/backend/api/main.py
@@ -114,7 +114,7 @@ from detection import protomatch
from detection.sinkresponder import SinkholeResponder
from detection.threatintel import ThreatIntel
from api.notify import notifier
-from paths import data_dir
+from paths import data_dir, chown_tree
import storage.db as db
from version import __version__
@@ -2154,9 +2154,17 @@ async def _shutdown_all() -> None:
db.flush()
except Exception as exc:
logger.error("final db flush failed: %s", exc)
-
-
-@asynccontextmanager
+ # EN: Elevated run → logs/db/token were created as root inside the USER's
+ # data dir. Hand the tree back so the next unprivileged launch can
+ # write it (otherwise the UI dies with EACCES — see Electron guard).
+ # FR: Run élevé → logs/db/jeton créés en root dans le dossier de données
+ # de L'UTILISATEUR. Rendre l'arbre pour que le lancement non
+ # privilégié suivant puisse y écrire (sinon l'UI meurt en EACCES —
+ # voir le garde-fou Electron).
+ try:
+ chown_tree(data_dir())
+ except Exception:
+ pass
async def lifespan(app: FastAPI):
"""EN: FastAPI lifespan — startup, yield, then clean shutdown.
FR: Lifespan FastAPI — démarrage, yield, puis arrêt propre."""
diff --git a/backend/api/security.py b/backend/api/security.py
index 39cfe61..f5b8413 100644
--- a/backend/api/security.py
+++ b/backend/api/security.py
@@ -36,7 +36,7 @@ import time
from fastapi import HTTPException, Request, WebSocket, status
-from paths import data_dir
+from paths import data_dir, chown_to_user
logger = logging.getLogger("snitch.api.security")
@@ -134,6 +134,9 @@ def _load_or_create_token() -> str:
except OSError:
pass # EN: Windows has no chmod semantics
# FR: Windows n'a pas de sémantique chmod
+ # EN: Elevated run → file is root-owned; give it back to the user.
+ # FR: Run élevé → fichier possédé par root ; le rendre à l'utilisateur.
+ chown_to_user(token_file)
except OSError as exc:
logger.warning("Could not persist API token to %s: %s", token_file, exc)
diff --git a/backend/logging_config.py b/backend/logging_config.py
index 191da7a..f755eab 100644
--- a/backend/logging_config.py
+++ b/backend/logging_config.py
@@ -18,7 +18,7 @@ import logging
from logging.handlers import RotatingFileHandler
from pathlib import Path
-from paths import data_dir
+from paths import data_dir, chown_to_user
def setup_logging(level: int = logging.INFO) -> Path:
@@ -30,6 +30,11 @@ def setup_logging(level: int = logging.INFO) -> Path:
"""
log_dir = data_dir() / "logs"
log_dir.mkdir(parents=True, exist_ok=True)
+ # EN: Elevated run → dir/file land root-owned; hand them back so the
+ # next unprivileged launch can still write the data dir.
+ # FR: Run élevé → dossier/fichier en root ; les rendre à l'utilisateur
+ # pour que le lancement non privilégié suivant puisse encore écrire.
+ chown_to_user(log_dir)
log_file = log_dir / "snitch.log"
root = logging.getLogger("snitch")
diff --git a/backend/paths.py b/backend/paths.py
index c0f6203..1a1ab4d 100644
--- a/backend/paths.py
+++ b/backend/paths.py
@@ -35,6 +35,69 @@ import sys
from pathlib import Path
+def _real_owner() -> tuple[int, int] | None:
+ """
+ EN: (uid, gid) of the desktop user who launched the app — passed via
+ SNITCH_OWNER_UID/SNITCH_OWNER_GID by the Electron launcher when it
+ elevates the backend (osascript/pkexec). None when not elevated or
+ not told — chown is then skipped.
+ FR: (uid, gid) de l'utilisateur qui a lancé l'app — transmis via
+ SNITCH_OWNER_UID/SNITCH_OWNER_GID par le lanceur Electron quand il
+ élève le backend (osascript/pkexec). None si non élevé ou non
+ renseigné — le chown est alors sauté.
+ """
+ if not hasattr(os, "geteuid") or os.geteuid() != 0:
+ return None
+ try:
+ return int(os.environ["SNITCH_OWNER_UID"]), int(os.environ["SNITCH_OWNER_GID"])
+ except (KeyError, ValueError):
+ return None
+
+
+def chown_to_user(path: Path) -> None:
+ """
+ EN: Hand a file/dir we just created back to the real desktop user.
+ Without this, an ELEVATED backend leaves root-owned files inside
+ ~/Library/Application Support/Snitch (or ~/.local/share/snitch) —
+ the next unprivileged launch then dies with EACCES because
+ Chromium/the launcher can no longer write there.
+ FR: Rendre un fichier/dossier qu'on vient de créer au vrai utilisateur.
+ Sans ça, un backend ÉLEVÉ laisse des fichiers possédés par root dans
+ ~/Library/Application Support/Snitch (ou ~/.local/share/snitch) —
+ le lancement non privilégié suivant meurt en EACCES car
+ Chromium/le lanceur ne peut plus y écrire.
+ """
+ owner = _real_owner()
+ if owner is not None:
+ try:
+ os.chown(path, *owner)
+ except OSError:
+ pass
+
+
+def chown_tree(root: Path) -> None:
+ """
+ EN: Recursively chown the whole data dir back to the desktop user —
+ called on shutdown so files created DURING this elevated run
+ (logs, db, token) don't brick the next launch.
+ FR: chown récursif de tout le dossier de données vers l'utilisateur —
+ appelé à l'arrêt pour que les fichiers créés PENDANT ce run élevé
+ (logs, db, jeton) ne briquent pas le lancement suivant.
+ """
+ owner = _real_owner()
+ if owner is None:
+ return
+ try:
+ os.chown(root, *owner)
+ for p in root.rglob("*"):
+ try:
+ os.chown(p, *owner)
+ except OSError:
+ pass
+ except OSError:
+ pass
+
+
def data_dir() -> Path:
"""
EN: Resolve (and create) the writable data directory.
@@ -53,4 +116,5 @@ def data_dir() -> Path:
else:
d = Path(__file__).parent.parent / "data"
d.mkdir(parents=True, exist_ok=True)
+ chown_to_user(d)
return d
diff --git a/deploy/helm/snitch/Chart.yaml b/deploy/helm/snitch/Chart.yaml
index 3422e59..169db31 100644
--- a/deploy/helm/snitch/Chart.yaml
+++ b/deploy/helm/snitch/Chart.yaml
@@ -6,7 +6,7 @@ description: |
(/remote/fleet over gossip_peers) or a per-node agent.
type: application
version: 0.1.0
-appVersion: "1.6.3"
+appVersion: "1.6.4"
home: https://github.com/aixisstudio/Snitch
keywords:
- security
diff --git a/electron/generate-icon.js b/electron/generate-icon.js
deleted file mode 100644
index 8d5d7c7..0000000
--- a/electron/generate-icon.js
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * Snitch — application icon generator.
- *
- * EN: Draws electron/icon.png (256×256 RGBA) from scratch using only Node.js
- * built-ins — no image library needed. The icon is a wireframe sphere
- * ringed by nodes, matching the splash screen.
- *
- * Run: node generate-icon.js
- *
- * FR: Dessine electron/icon.png (256×256 RGBA) à partir de zéro avec les
- * modules Node.js intégrés uniquement — aucune lib d'image nécessaire.
- * L'icône est une sphère filaire entourée de nœuds, assortie au splash.
- *
- * Usage : node generate-icon.js
- */
-
-const zlib = require('zlib')
-const fs = require('fs')
-const path = require('path')
-
-const S = 512
-// EN: RGBA pixel buffer, fully transparent. / FR: buffer de pixels RGBA, entièrement transparent.
-const buf = Buffer.alloc(S * S * 4, 0)
-
-/**
- * EN: Alpha-composite one pixel over the buffer (source-over blending).
- * FR: Composite un pixel en alpha au-dessus du buffer (mélange source-over).
- */
-function px(x, y, r, g, b, a) {
- x = Math.round(x); y = Math.round(y)
- if (x < 0 || x >= S || y < 0 || y >= S || a <= 0) return
- const i = (y * S + x) * 4
- const sa = a / 255, da = buf[i+3] / 255
- const oa = sa + da * (1 - sa)
- if (oa < 0.001) return
- buf[i] = Math.round((r * sa + buf[i] * da * (1 - sa)) / oa)
- buf[i+1] = Math.round((g * sa + buf[i+1] * da * (1 - sa)) / oa)
- buf[i+2] = Math.round((b * sa + buf[i+2] * da * (1 - sa)) / oa)
- buf[i+3] = Math.round(oa * 255)
-}
-
-/** EN: Filled circle with 1px antialiased edge. / FR: Cercle plein avec bord anticrénelé de 1 px. */
-function fillCircle(cx, cy, R, r, g, b, a) {
- for (let y = Math.ceil(cy - R - 1); y <= cy + R + 1; y++)
- for (let x = Math.ceil(cx - R - 1); x <= cx + R + 1; x++) {
- const d = Math.sqrt((x-cx)**2 + (y-cy)**2)
- if (d < R + 0.5) px(x, y, r, g, b, Math.round(a * Math.min(1, R + 0.5 - d)))
- }
-}
-
-/** EN: Ring of stroke width `sw`. / FR: Anneau d'épaisseur `sw`. */
-function strokeCircle(cx, cy, R, sw, r, g, b, a) {
- for (let y = Math.ceil(cy - R - sw - 1); y <= cy + R + sw + 1; y++)
- for (let x = Math.ceil(cx - R - sw - 1); x <= cx + R + sw + 1; x++) {
- const d = Math.sqrt((x-cx)**2 + (y-cy)**2)
- const dist = Math.abs(d - R)
- if (dist < sw/2 + 0.5) px(x, y, r, g, b, Math.round(a * Math.min(1, sw/2 + 0.5 - dist)))
- }
-}
-
-/** EN: Straight line via linear interpolation. / FR: Ligne droite par interpolation linéaire. */
-function drawLine(x0, y0, x1, y1, r, g, b, a) {
- const dx = x1-x0, dy = y1-y0
- const steps = Math.ceil(Math.sqrt(dx*dx + dy*dy)) * 2
- for (let i = 0; i <= steps; i++) {
- const t = i / steps
- px(x0 + t*dx, y0 + t*dy, r, g, b, a)
- }
-}
-
-/** EN: Ellipse outline — used for the sphere's lat/long wireframe. / FR: Contour d'ellipse — pour le filaire lat/long de la sphère. */
-function drawEllipse(cx, cy, rx, ry, r, g, b, a) {
- const steps = Math.ceil(Math.PI * (rx + ry) * 2.5)
- for (let i = 0; i < steps; i++) {
- const t = (i / steps) * Math.PI * 2
- px(cx + rx * Math.cos(t), cy + ry * Math.sin(t), r, g, b, a)
- }
-}
-
-const cx = S / 2, cy = S / 2
-const R = 184 // EN: sphere radius / FR: rayon de la sphère
-
-// ── Rounded-square black background / Fond noir à coins arrondis ─────────────
-const cornerR = 100
-for (let y = 0; y < S; y++)
- for (let x = 0; x < S; x++) {
- const dx = Math.abs(x - cx) - (cx - cornerR)
- const dy = Math.abs(y - cy) - (cy - cornerR)
- const d = dx > 0 && dy > 0 ? Math.sqrt(dx*dx + dy*dy) : Math.max(dx, dy, 0)
- if (d <= cornerR) { const i=(y*S+x)*4; buf[i]=0;buf[i+1]=0;buf[i+2]=0;buf[i+3]=255 }
- }
-
-// ── Latitude lines / Lignes de latitude ──────────────────────────────────────
-for (const ry_f of [0.28, 0.63, 0.92])
- drawEllipse(cx, cy, R, R * ry_f, 255, 255, 255, 38)
-
-// ── Longitude lines / Lignes de longitude ────────────────────────────────────
-for (const rx_f of [0.32, 0.74])
- drawEllipse(cx, cy, R * rx_f, R, 255, 255, 255, 38)
-
-// ── Sphere ring / Anneau de la sphère ────────────────────────────────────────
-strokeCircle(cx, cy, R, 5.6, 255, 255, 255, 190)
-
-// ── Peripheral nodes / Nœuds périphériques ───────────────────────────────────
-const scale = R / 118
-function svgPt(sx, sy) { return [cx + (sx-240)*scale, cy + (sy-210)*scale] }
-const nodes = [
- svgPt(155,110), svgPt(332,118), svgPt(355,230),
- svgPt(308,300), svgPt(158,298), svgPt(124,175),
-]
-
-// EN: Ring lines between adjacent nodes. / FR: Lignes d'anneau entre nœuds adjacents.
-for (let i = 0; i < nodes.length; i++) {
- const [ax,ay] = nodes[i], [bx,by] = nodes[(i+1) % nodes.length]
- drawLine(ax, ay, bx, by, 255, 255, 255, 55)
-}
-// EN: Spokes to center. / FR: Rayons vers le centre.
-for (const [nx,ny] of nodes) drawLine(cx, cy, nx, ny, 255, 255, 255, 38)
-
-for (const [nx,ny] of nodes) {
- fillCircle(nx, ny, 11, 0, 0, 0, 255)
- strokeCircle(nx, ny, 11, 3.6, 255, 255, 255, 210)
- fillCircle(nx, ny, 5.6, 247, 176, 22, 255)
-}
-
-// ── Center node / Nœud central ───────────────────────────────────────────────
-fillCircle(cx, cy, 36, 247, 176, 22, 45)
-fillCircle(cx, cy, 22, 247, 176, 22, 155)
-fillCircle(cx, cy, 14, 247, 176, 22, 255)
-fillCircle(cx, cy, 6, 255, 255, 255, 255)
-
-// ── PNG encoding / Encodage PNG ──────────────────────────────────────────────
-// EN: Minimal hand-rolled PNG writer: signature + IHDR + IDAT + IEND with
-// CRC32 checksums. Avoids pulling in a whole image dependency.
-// FR: Encodeur PNG minimal fait main : signature + IHDR + IDAT + IEND avec
-// sommes CRC32. Évite d'ajouter toute une dépendance d'image.
-function crc32(data) {
- const T = new Int32Array(256)
- for (let i = 0; i < 256; i++) {
- let c = i
- for (let j = 0; j < 8; j++) c = c & 1 ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)
- T[i] = c
- }
- let crc = -1
- for (const b of data) crc = T[(crc ^ b) & 0xFF] ^ (crc >>> 8)
- return (crc ^ -1) >>> 0
-}
-
-function ck(type, data) {
- const tb = Buffer.from(type, 'ascii')
- const body = Buffer.concat([tb, data])
- const len = Buffer.alloc(4); len.writeUInt32BE(data.length)
- const crc = Buffer.alloc(4); crc.writeUInt32BE(crc32(body))
- return Buffer.concat([len, body, crc])
-}
-
-const ihdr = Buffer.alloc(13)
-ihdr.writeUInt32BE(S, 0); ihdr.writeUInt32BE(S, 4)
-ihdr[8] = 8; ihdr[9] = 6 // EN: 8-bit RGBA / FR: RGBA 8 bits
-
-const raw = []
-for (let y = 0; y < S; y++) {
- raw.push(0) // EN: PNG filter type: None / FR: filtre PNG : None
- for (let x = 0; x < S; x++) {
- const i = (y*S+x)*4
- raw.push(buf[i], buf[i+1], buf[i+2], buf[i+3])
- }
-}
-
-const png = Buffer.concat([
- Buffer.from([0x89,0x50,0x4E,0x47,0x0D,0x0A,0x1A,0x0A]),
- ck('IHDR', ihdr),
- ck('IDAT', zlib.deflateSync(Buffer.from(raw), { level: 9 })),
- ck('IEND', Buffer.alloc(0)),
-])
-
-const out = path.join(__dirname, 'icon.png')
-fs.writeFileSync(out, png)
-console.log('Generated', out, '-', png.length, 'bytes')
diff --git a/electron/icon.png b/electron/icon.png
new file mode 100644
index 0000000..861161b
Binary files /dev/null and b/electron/icon.png differ
diff --git a/electron/main.js b/electron/main.js
index 7d80fd1..22066dd 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -593,7 +593,14 @@ function launchBackendElevated() {
// (' → '\''), incassables pour sh.
const shq = s => `'${String(s).replace(/'/g, `'\\''`)}'`
const tokenPrefix = tokenFileWritten ? '' : `SNITCH_TOKEN=${shq(API_TOKEN)} `
- const shellCmd = `SNITCH_DATA_DIR=${shq(dataDir)} ${tokenPrefix}${shq(backendExe)} --port ${backendPort}`
+ // EN: SNITCH_OWNER_* tells the ELEVATED backend which real uid/gid to
+ // chown its files back to — otherwise logs/db/token stay root-owned
+ // inside the user's data dir and the next launch dies with EACCES.
+ // FR: SNITCH_OWNER_* indique au backend ÉLEVÉ vers quel uid/gid réel
+ // chown ses fichiers — sinon logs/db/jeton restent en root dans le
+ // dossier utilisateur et le lancement suivant meurt en EACCES.
+ const ownerPrefix = `SNITCH_OWNER_UID=${process.getuid()} SNITCH_OWNER_GID=${process.getgid()} `
+ const shellCmd = `SNITCH_DATA_DIR=${shq(dataDir)} ${ownerPrefix}${tokenPrefix}${shq(backendExe)} --port ${backendPort}`
backendProc = spawn('osascript', [
'-e', `do shell script "${esc(shellCmd)}" with administrator privileges`,
], { stdio: 'ignore' })
@@ -612,7 +619,13 @@ function launchBackendElevated() {
// FR: Même règle que macOS — préférer le fichier de jeton à une
// affectation d'env visible dans /proc/<pid>/cmdline ; l'env sert
// seulement si l'écriture a échoué.
- const envArgs = [`SNITCH_DATA_DIR=${dataDir}`]
+ const envArgs = [
+ `SNITCH_DATA_DIR=${dataDir}`,
+ // EN: same ownership hand-back as macOS (see above)
+ // FR: même rétrocession de propriété que macOS (voir ci-dessus)
+ `SNITCH_OWNER_UID=${process.getuid()}`,
+ `SNITCH_OWNER_GID=${process.getgid()}`,
+ ]
if (!tokenFileWritten) envArgs.push(`SNITCH_TOKEN=${API_TOKEN}`)
backendProc = spawn(pkexecBin, [
'env', ...envArgs,
diff --git a/electron/package.json b/electron/package.json
index 41f9dac..32d91f3 100644
--- a/electron/package.json
+++ b/electron/package.json
@@ -6,11 +6,10 @@
"license": "AGPL-3.0-or-later",
"scripts": {
"start": "electron .",
- "icon": "node generate-icon.js",
- "build": "npm run icon && electron-builder --win --x64 --publish never",
+ "build": "electron-builder --win --x64 --publish never",
"build:dir": "electron-builder --win --x64 --dir",
- "build:mac": "npm run icon && electron-builder --mac --arm64 --publish never",
- "build:linux": "npm run icon && electron-builder --linux --x64 --publish never"
+ "build:mac": "electron-builder --mac --arm64 --publish never",
+ "build:linux": "electron-builder --linux --x64 --publish never"
},
"devDependencies": {
"electron": "^44.9.0",
diff --git a/icon.png b/icon.png
index ba36ef6..861161b 100644
Binary files a/icon.png and b/icon.png differ
diff --git a/packaging/nfpm.yaml b/packaging/nfpm.yaml
index b36219c..ab10c59 100644
--- a/packaging/nfpm.yaml
+++ b/packaging/nfpm.yaml
@@ -10,7 +10,7 @@
name: snitch
arch: amd64
platform: linux
-version: "1.6.3"
+version: "1.6.4"
release: 1
section: net
priority: optional