From f0e5d6d26e3a72b7133ab906bbf0f5c7e831a827 Mon Sep 17 00:00:00 2001 From: harald Date: Mon, 21 Sep 2026 09:15:20 +0200 Subject: [PATCH] sec: add SECURITY.md policy, deny.toml config, and document automated audit results - Add SECURITY.md establishing Responsible Disclosure policy, SLA (48h/5d/90d), scope, and contact channels (security@pansi.eu) - Configure deny.toml for cargo-deny (advisories, bans, licenses, sources) - Audit with cargo audit (0 vulnerabilities) and cargo deny (all ok) - Scan entire git history with gitleaks (101 commits, no secrets leaked) - Baseline harmless unit-test mock tokens in .gitleaksignore - Document automated auditing in SECURITY_AUDIT.md and link in README.md --- .gitleaksignore | 5 + README.md | 2 +- SECURITY.md | 94 +++++++++++++++++ SECURITY_AUDIT.md | 17 +++- deny.toml | 249 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 365 insertions(+), 2 deletions(-) create mode 100644 .gitleaksignore create mode 100644 SECURITY.md create mode 100644 deny.toml diff --git a/.gitleaksignore b/.gitleaksignore new file mode 100644 index 0000000..eaa945d --- /dev/null +++ b/.gitleaksignore @@ -0,0 +1,5 @@ +# Gitleaks ignore file +# Test mock constants in unit tests (confirmed non-sensitive test tokens) +2af14eef362e718a86bb079c4897f61719398c42:src/mount.rs:generic-api-key:976 +1cdb30147b3c4ecb7f46db39f530a85113ad590d:tests/mount_security_test.rs:generic-api-key:90 +436790abf0e904c1aaeef51fb10cb318ce9b8bdc:tests/upgrade_security_test.rs:generic-api-key:42 diff --git a/README.md b/README.md index 7bf8879..22b96c1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Sanctum ist eine eigenständige, speichersichere und hochperformante CLI-Anwendu - **Disaster Recovery**: 24-Wort BIP-39 Mnemonic Seed Phrases, konsistente Online-Backups via SQLite Online Backup API und kryptografische Vollprüfung (`sanctum verify`). - **Statisches Single-Binary**: Standalone-Executables ohne externe DLL-Abhängigkeiten (`sanctum.exe` für Windows, statisches musl-ELF für Linux). -> 💡 **Neu bei Sanctum?** Eine kompakte Schritt-für-Schritt-Anleitung findest du in der [Schnellstartanleitung (QUICKSTART.md)](QUICKSTART.md). Hinweise zur Installation via Scoop oder Winget gibt es im [Installations-Guide (INSTALL.md)](INSTALL.md). +> 💡 **Neu bei Sanctum?** Eine kompakte Schritt-für-Schritt-Anleitung findest du in der [Schnellstartanleitung (QUICKSTART.md)](QUICKSTART.md). Hinweise zur Installation via Scoop oder Winget gibt es im [Installations-Guide (INSTALL.md)](INSTALL.md). Details zur Sicherheitsrichtlinie und Responsible Disclosure siehe [SECURITY.md](SECURITY.md). --- diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..0a61abe --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,94 @@ +# Sicherheitsrichtlinie & Responsible Disclosure (SECURITY.md) + +Die Sicherheit von **Sanctum** und der Schutz der Daten unserer Anwender haben höchste Priorität. Dieses Dokument definiert die Sicherheitsrichtlinie, den Geltungsbereich und den formalen Prozess zur vertraulichen Meldung von Sicherheitslücken (**Responsible Disclosure**). + +--- + +## 1. Unterstützte Versionen + +Sicherheitsupdates und Patches werden jeweils für die neueste Version von Sanctum bereitgestellt. Ältere Versionen werden nicht separat gepflegt; Anwendern wird dringend empfohlen, stets die aktuellste Version einzusetzen (automatisch prüfbar via `sanctum upgrade --check`). + +| Version | Status | Sicherheits-Support | +|:---:|:---:|:---:| +| **v0.9.x** | **Aktiv (Aktuell: v0.9.2)** | **Vollständig unterstützt** | +| <= v0.8.x | Veraltet | Nicht mehr unterstützt (Upgrade empfohlen) | + +--- + +## 2. Geltungsbereich (Scope) + +### 2.1 Im Geltungsbereich (In Scope) +Schwachstellen in folgenden Kernbereichen fallen unter diese Richtlinie: +- **Kryptografische Kernfunktionen**: + - Schlüsselableitung (`Argon2id`, KDF-Parametervalidierung, Salt-Erzeugung). + - Verschlüsselung, Integrität und Replay-Schutz (`AES-256-GCM`, 24-Byte Generation-AAD K-02, Inode-Metadaten-MAC K-01). + - Steganografisches Carrier-Format V2 (Paged Manifest, Superblock-Konsistenz C-02, Dirty-Tracking C-03). +- **Speicher- und Prozesssicherheit**: + - Schlüsselisolation im Arbeitsspeicher (`Zeroize`, `VirtualLock` / `mlock`). + - Schutz vor Auslagerung in Swap/Pagefile oder temporäre Absturz-Dumps. +- **Netzwerk- und Dienst-Sicherheit**: + - Lokaler WebDAV-Endpunkt (zwingende `127.0.0.1` Loopback-Beschränkung, Host-Header-Validierung). + - Session-Token-Schutz (dynamische Zufallserzeugung im RAM, keine Leaks über Prozessliste `argv`, Pfade oder URLs). +- **Anti-Forensik & Anti-Leak Shield**: + - Unterdrückung von Windows-Explorer-Artefakten (`Thumbs.db`, `desktop.ini`, ADS-Streams). + - Transaktionales Schreddern von Datenblöcken mit CSPRNG-Rauschen vor dem Löschen. +- **Software-Integrität & Upgrade-Prozess**: + - Signaturprüfung von Updates via **Minisign** (Ed25519) und Domain-Beschränkung. +- **Disaster Recovery**: + - BIP-39 Notfallschlüssel-Ableitung und Header-Wiederherstellung (R-NEW-1 MAC-Rebuild). + +### 2.2 Außerhalb des Geltungsbereichs (Out of Scope) +Folgende Szenarien stellen keine Sicherheitslücke in Sanctum dar: +- **Kompromittierter Host**: Angriffe, die bereits uneingeschränkte Administrator-/Root-Rechte oder physischen Zugriff auf einen laufenden, entsperrten Rechner voraussetzen (z. B. Kernel-Treiber-Injection, Direct-Memory-Access via Hardware, Keylogger auf OS-Ebene). +- **Physikalisches Flash-Wear-Leveling**: Restfragmente gelöschter Blöcke auf Flash-Speichern (SSD, NVMe) infolge des Flash Translation Layers (FTL) der Hardware, sofern Sanctum die logischen Datenblöcke nachweislich kryptografisch geschreddert hat (siehe Hinweis in `README.md` und `THREAT_MODEL.md`). +- **Social Engineering & Phishing**: Angriffe, die darauf abzielen, das Master-Passwort oder den Notfallschlüssel direkt vom Anwender zu erpressen oder zu erschleichen. +- **Lokales DoS durch Dateilöschung**: Das manuelle Löschen der `.sanctum`-Containerdatei durch einen Nutzer mit Schreibrechten auf dem Hostdateisystem. + +--- + +## 3. Vertrauliche Meldung (Responsible Disclosure) + +Wenn Sie eine potenzielle Sicherheitslücke in Sanctum identifiziert haben, bitten wir Sie eindringlich, diese **nicht öffentlich** (z. B. über GitHub/Gitea Public Issues, X/Twitter, Mastodon, Diskussionsforen oder Blogs) bekanntzugeben, bevor wir die Möglichkeit hatten, das Problem zu analysieren, zu beheben und ein Update bereitzustellen. + +### 3.1 Kontaktwege + +Bitte übermitteln Sie Ihren Bericht über einen der folgenden vertraulichen Kanäle: + +1. **Per E-Mail (Primär)**: + - **Adresse**: `security@pansi.eu` *(Fallback: `harald@pansi.eu`)* + - **Betreff**: `[SECURITY] Schwachstelle in Sanctum: ` + - Wenn Sie sensible Details (z. B. PoC-Exploits) verschlüsseln möchten, fordern Sie bitte vorab per Mail einen PGP-Schlüssel an oder nutzen Sie den Gitea Security Advisory Kanal. + +2. **Gitea Private Vulnerability Reporting (Web)**: + - Wenn Sie ein Gitea-Konto besitzen, können Sie unter folgender URL direkt einen vertraulichen Security Advisory erstellen: + - **URL**: [https://gitea.pansi.eu/harald/sanctum/security/advisories](https://gitea.pansi.eu/harald/sanctum/security/advisories) + +### 3.2 Erforderliche Informationen im Bericht +Um eine schnelle Untersuchung zu ermöglichen, sollte Ihre Meldung folgende Informationen enthalten: +1. **Zusammenfassung**: Eine prägnante Beschreibung der Schwachstelle und der betroffenen Komponente. +2. **Version & Umgebung**: Getestete Sanctum-Version (z. B. v0.9.2), Betriebssystem (Windows 11, Linux etc.) und Toolchain. +3. **Schritt-für-Schritt-Anleitung**: Genaue Reproduktionsschritte oder ein minimales Proof of Concept (PoC). +4. **Schweregrad / Impact**: Ihre Einschätzung der Auswirkung (z. B. Datenverlust, Umgehung der Verschlüsselung, Information Leak). +5. **Lösungsvorschlag** *(optional)*: Falls Sie bereits eine Idee oder einen Patch haben, freuen wir uns über Ihren Vorschlag. + +--- + +## 4. Reaktionszeiten & Zeitplan (SLA) + +Wir verpflichten uns zu einem transparenten und zügigen Ablauf: + +| Phase | Maximale Reaktionszeit | Beschreibung | +|---|---|---| +| **Eingangsbestätigung** | **Innerhalb von 48 Stunden** | Wir bestätigen den Empfang Ihrer Meldung und benennen einen Ansprechpartner. | +| **Erste Bewertung** | **Innerhalb von 5 Werktagen** | Wir prüfen die Reproduzierbarkeit und bewerten den Schweregrad. | +| **Status-Updates** | **Mindestens alle 7 Tage** | Sie werden regelmäßig über den Fortschritt der Behebung informiert. | +| **Embargo & Veröffentlichung** | **Standardmäßig 90 Tage** | Gemeinsam stimmen wir den Veröffentlichungstermin ab (spätestens nach 90 Tagen oder unmittelbar nach Bereitstellung des Patches). | + +--- + +## 5. Safe Harbor & Anerkennung + +- **Rechtlicher Schutz (Safe Harbor)**: Wenn Sie nach bestem Wissen und Gewissen im Rahmen dieser Richtlinie handeln (keine Daten Dritter kompromittieren, keine Systeme sabotieren und die Vertraulichkeitsfrist einhalten), werden wir keinerlei rechtliche Schritte gegen Sie einleiten. +- **Anerkennung**: Sofern von Ihnen gewünscht, nennen wir Sie namentlich (oder mit Alias/Handle) in den offiziellen Release Notes, im `SECURITY_AUDIT.md` sowie im Changelog als Entdecker der Schwachstelle. + +Vielen Dank, dass Sie dazu beitragen, Sanctum für alle Anwender sicher zu halten! diff --git a/SECURITY_AUDIT.md b/SECURITY_AUDIT.md index 7c69803..7f3d94c 100644 --- a/SECURITY_AUDIT.md +++ b/SECURITY_AUDIT.md @@ -147,8 +147,23 @@ Dieses Dokument fasst alle 39 Findings aus drei umfassenden externen Sicherheits - **Freier Speicherplatz unter Linux (W-1):** - `get_available_disk_space` nutzt unter Unix `libc::statvfs` zur exakten Quota-Ermittlung (`f_bavail * f_frsize`). +### 8. Automatisierte Sicherheitsprüfungen & Supply-Chain-Audit (cargo audit, cargo deny, gitleaks) +- **RustSec Advisory Database (`cargo audit`):** + - Vollständige Prüfung aller 248 Abhängigkeiten in `Cargo.lock` gegen die offizielle RustSec Advisory-Datenbank. + - **Ergebnis:** 0 bekannte Schwachstellen (0 vulnerabilities, 0 security warnings). +- **Supply-Chain- & Dependency-Governance (`cargo deny` via `deny.toml`):** + - `advisories ok`: Keine sicherheitskritischen oder zurückgezogenen (yanked) Crates. + - `bans ok`: Keine gesperrten Crates, unbedenkliche Duplikate (z. B. `windows-sys` Major-Versionen) innerhalb der Vorgaben. + - `licenses ok`: 100 % aller Lizenzen entsprechen den freigegebenen Permissive/OSI-Lizenzen (MIT, Apache-2.0, BSD, CC0, ISC, Unicode-3.0, Zlib, MPL-2.0, LGPL-2.1-or-later). + - `sources ok`: Sämtliche Crates stammen verifiziert aus dem offiziellen `crates.io`-Index. +- **Git-Historien-Scan auf Secrets (`gitleaks`):** + - Vollständiger Audit aller 101 Git-Commits und 1,28 MB Änderungshistorie mit `gitleaks detect`. + - **Ergebnis:** Keine privaten Schlüssel (Minisign Secret Keys, SSH-Schlüssel, Passwörter, API-Tokens) in der Git-Historie vorhanden. Drei harmlose Test-Mock-Strings in Unittests (`src/mount.rs`, `tests/mount_security_test.rs`, `tests/upgrade_security_test.rs`) wurden in `.gitleaksignore` gebaselined. +- **Responsible Disclosure Policy (`SECURITY.md`):** + - Einführung von `SECURITY.md` mit SLA (48h Reaktionszeit, 5 Tage Bewertung), Kontaktadresse (`security@pansi.eu`), Gitea Security Advisories Kanal und 90-Tage Embargo. + --- ## Verifikationsnachweis -Alle Unit- und Integrationstests wurden auf einem Windows x86_64 Host mit 100% Erfolgsquote ausgeführt. Die Release-Paketierung für Windows und Linux musl ist voll automatisiert und wird mit Minisign kryptografisch abgesichert. \ No newline at end of file +Alle Unit- und Integrationstests wurden auf einem Windows x86_64 Host mit 100% Erfolgsquote ausgeführt. Die Release-Paketierung für Windows und Linux musl ist voll automatisiert und wird mit Minisign kryptografisch abgesichert. Alle automatisierten Supply-Chain- und Secret-Scans (`cargo audit`, `cargo deny`, `gitleaks`) wurden erfolgreich ohne Befunde absolviert. \ No newline at end of file diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..79e6c1f --- /dev/null +++ b/deny.toml @@ -0,0 +1,249 @@ +# This template contains all of the possible sections and their default values + +# Note that all fields that take a lint level have these possible values: +# * deny - An error will be produced and the check will fail +# * warn - A warning will be produced, but the check will not fail +# * allow - No warning or error will be produced, though in some cases a note +# will be + +# The values provided in this template are the default values that will be used +# when any section or field is not specified in your own configuration + +# Root options + +# The graph table configures how the dependency graph is constructed and thus +# which crates the checks are performed against +[graph] +# If 1 or more target triples (and optionally, target_features) are specified, +# only the specified targets will be checked when running `cargo deny check`. +# This means, if a particular package is only ever used as a target specific +# dependency, such as, for example, the `nix` crate only being used via the +# `target_family = "unix"` configuration, that only having windows targets in +# this list would mean the nix crate, as well as any of its exclusive +# dependencies not shared by any other crates, would be ignored, as the target +# list here is effectively saying which targets you are building for. +targets = [ + # The triple can be any string, but only the target triples built in to + # rustc (as of 1.40) can be checked against actual config expressions + #"x86_64-unknown-linux-musl", + # You can also specify which target_features you promise are enabled for a + # particular target. target_features are currently not validated against + # the actual valid features supported by the target architecture. + #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, +] +# When creating the dependency graph used as the source of truth when checks are +# executed, this field can be used to prune crates from the graph, removing them +# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate +# is pruned from the graph, all of its dependencies will also be pruned unless +# they are connected to another crate in the graph that hasn't been pruned, +# so it should be used with care. The identifiers are [Package ID Specifications] +# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) +#exclude = [] +# If true, metadata will be collected with `--all-features`. Note that this can't +# be toggled off if true, if you want to conditionally enable `--all-features` it +# is recommended to pass `--all-features` on the cmd line instead +all-features = false +# If true, metadata will be collected with `--no-default-features`. The same +# caveat with `all-features` applies +no-default-features = false +# If set, these feature will be enabled when collecting metadata. If `--features` +# is specified on the cmd line they will take precedence over this option. +#features = [] + +# The output table provides options for how/if diagnostics are outputted +[output] +# When outputting inclusion graphs in diagnostics that include features, this +# option can be used to specify the depth at which feature edges will be added. +# This option is included since the graphs can be quite large and the addition +# of features from the crate(s) to all of the graph roots can be far too verbose. +# This option can be overridden via `--feature-depth` on the cmd line +feature-depth = 1 + +# This section is considered when running `cargo deny check advisories` +# More documentation for the advisories section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html +[advisories] +# The path where the advisory databases are cloned/fetched into +#db-path = "$CARGO_HOME/advisory-dbs" +# The url(s) of the advisory databases to use +#db-urls = ["https://github.com/rustsec/advisory-db"] +# A list of advisory IDs to ignore. Note that ignored advisories will still +# output a note when they are encountered. +ignore = [ + #"RUSTSEC-0000-0000", + #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, + #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish + #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, +] +# If this is true, then cargo deny will use the git executable to fetch advisory database. +# If this is false, then it uses a built-in git library. +# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. +# See Git Authentication for more information about setting up git authentication. +#git-fetch-with-cli = true + +# This section is considered when running `cargo deny check licenses` +# More documentation for the licenses section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html +[licenses] +# List of explicitly allowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. +allow = [ + "MIT", + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-2-Clause", + "BSD-3-Clause", + "CC0-1.0", + "CDLA-Permissive-2.0", + "ISC", + "Unicode-3.0", + "Unlicense", + "Zlib", + "MPL-2.0", + "LGPL-2.1-or-later", +] +# The confidence threshold for detecting a license from license text. +# The higher the value, the more closely the license text must be to the +# canonical license text of a valid SPDX license file. +# [possible values: any between 0.0 and 1.0]. +confidence-threshold = 0.8 +# Allow 1 or more licenses on a per-crate basis, so that particular licenses +# aren't accepted for every possible crate as with the normal allow list +exceptions = [ + # Each entry is the crate and version constraint, and its specific allow + # list + #{ allow = ["Zlib"], crate = "adler32" }, +] + +# Some crates don't have (easily) machine readable licensing information, +# adding a clarification entry for it allows you to manually specify the +# licensing information +#[[licenses.clarify]] +# The package spec the clarification applies to +#crate = "ring" +# The SPDX expression for the license requirements of the crate +#expression = "MIT AND ISC AND OpenSSL" +# One or more files in the crate's source used as the "source of truth" for +# the license expression. If the contents match, the clarification will be used +# when running the license check, otherwise the clarification will be ignored +# and the crate will be checked normally, which may produce warnings or errors +# depending on the rest of your configuration +#license-files = [ +# Each entry is a crate relative path, and the (opaque) hash of its contents +#{ path = "LICENSE", hash = 0xbd0eed23 } +#] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +# To see how to mark a crate as unpublished (to the official registry), +# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. +ignore = false +# One or more private registries that you might publish crates to, if a crate +# is only published to private registries, and ignore is true, the crate will +# not have its license(s) checked +registries = [ + #"https://sekretz.com/registry +] + +# This section is considered when running `cargo deny check bans`. +# More documentation about the 'bans' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html +[bans] +# Lint level for when multiple versions of the same crate are detected +multiple-versions = "warn" +# Lint level for when a crate version requirement is `*` +wildcards = "allow" +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" +# The default lint level for `default` features for crates that are members of +# the workspace that is being checked. This can be overridden by allowing/denying +# `default` on a crate-by-crate basis if desired. +workspace-default-features = "allow" +# The default lint level for `default` features for external crates that are not +# members of the workspace. This can be overridden by allowing/denying `default` +# on a crate-by-crate basis if desired. +external-default-features = "allow" +# List of crates that are allowed. Use with care! +allow = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, +] +# If true, workspace members are automatically allowed even when using deny-by-default +# This is useful for organizations that want to deny all external dependencies by default +# but allow their own workspace crates without having to explicitly list them +allow-workspace = false +# List of crates to deny +deny = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, + # Wrapper crates can optionally be specified to allow the crate when it + # is a direct dependency of the otherwise banned crate + #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, +] + +# List of features to allow/deny +# Each entry the name of a crate and a version range. If version is +# not specified, all versions will be matched. +#[[bans.features]] +#crate = "reqwest" +# Features to not allow +#deny = ["json"] +# Features to allow +#allow = [ +# "rustls", +# "__rustls", +# "__tls", +# "hyper-rustls", +# "rustls", +# "rustls-pemfile", +# "rustls-tls-webpki-roots", +# "tokio-rustls", +# "webpki-roots", +#] +# If true, the allowed features must exactly match the enabled feature set. If +# this is set there is no point setting `deny` +#exact = true + +# Certain crates/versions that will be skipped when doing duplicate detection. +skip = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, +] +# Similarly to `skip` allows you to skip certain crates during duplicate +# detection. Unlike skip, it also includes the entire tree of transitive +# dependencies starting at the specified crate, up to a certain depth, which is +# by default infinite. +skip-tree = [ + #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies + #{ crate = "ansi_term@0.11.0", depth = 20 }, +] + +# This section is considered when running `cargo deny check sources`. +# More documentation about the 'sources' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html +[sources] +# Lint level for what to happen when a crate from a crate registry that is not +# in the allow list is encountered +unknown-registry = "warn" +# Lint level for what to happen when a crate from a git repository that is not +# in the allow list is encountered +unknown-git = "warn" +# List of URLs for allowed crate registries. Defaults to the crates.io index +# if not specified. If it is specified but empty, no registries are allowed. +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +# List of URLs for allowed Git repositories +allow-git = [] + +[sources.allow-org] +# github.com organizations to allow git sources for +github = [] +# gitlab.com organizations to allow git sources for +gitlab = [] +# bitbucket.org organizations to allow git sources for +bitbucket = []