Security

Security

SSH-Frontière is a security component. Its purpose is to restrict what incoming SSH connections can do. This page documents the security model, what has been implemented, and what is not guaranteed.

Security model

Core principle: deny by default

Nothing runs without being explicitly configured. If a command is not in the TOML whitelist, it is denied. There is no permissive mode, no fallback to a shell.

Three layers of defense in depth

LayerMechanismProtection
1command= + restrict in authorized_keysForces the access level, blocks forwarding/PTY
2SSH-Frontière (login shell)Validates the command against the TOML whitelist
3sudo whitelist in sudoersRestricts privileged system commands

Even if an attacker compromises an SSH key (layer 1), they can only execute commands authorized in the TOML whitelist (layer 2). Even if they bypass layer 2, they can only escalate privileges for commands authorized in sudoers (layer 3).

Grammatical parser, not a blacklist

SSH-Frontière is not a shell. Security does not rely on character filtering (no blacklist of |, ;, &), but on a grammatical parser.

The expected grammar is domain action [key=value ...]. Anything that does not match this structure is rejected. Special characters inside quotes are argument content, not syntax — they are valid.

std::process::Command executes directly, without going through an intermediate shell. Command injection is structurally impossible.

Determinism against AI agents

This behavior is deterministic: a given command always produces the same validation result, regardless of context. This is an essential property when working with AI agents, whose nature is precisely indeterminism — a model can be biased, or the agent's production chain can be corrupted, targeting shells to extract additional information or exfiltrate secrets. With SSH-Frontière, a compromised agent cannot bypass the whitelist, cannot inject commands into a shell, and cannot access unconfigured resources. This is structurally impossible.

What has been implemented

Rust language

SSH-Frontière is written in Rust, which eliminates the most common vulnerability classes in system programs:

399 cargo tests + 72 E2E SSH scenarios

The project is covered by 399 cargo tests and 72 additional E2E SSH scenarios:

TypeCountDescription
Unit tests~340Each module tested independently (10 *_tests.rs files)
Integration tests50Complete stdio scenarios (binary execution)
Conformance tests1 (6 scenarios)JSON interface contract validation (ADR 0003)
Proptest tests8Property-based tests (constraint-guided fuzzing)
Cargo total399
E2E SSH scenarios72Docker Compose with real SSH server
cargo-fuzz harnesses9Unguided fuzzing (random mutations)

The E2E SSH tests cover the complete protocol, authentication, sessions, security, robustness, and logging. They run in a Docker Compose environment with a real SSH server.

Dependency auditing

RBAC access control

Three hierarchical trust levels:

LevelUsageExamples
readRead-onlyhealthcheck, status, list
opsRoutine operationsbackup, deploy, restart
adminAll actionsconfiguration, sensitive data

Each action has a required level. Each SSH connection has an effective level (via --level in authorized_keys or via token authentication).

Visibility tags

In addition to vertical RBAC, tags enable horizontal filtering: a token with the forgejo tag only sees actions tagged forgejo, even if it has the ops level.

Token authentication

Two authentication modes:

Additional protections

What is not guaranteed

No software is perfect. Here are the known and documented limitations:

8-bit XOR counter

The cryptographic implementation uses an XOR counter with a keystream limited to 8192 bytes. This is sufficient for current usage (64-character SHA-256 proofs), but not designed for encrypting large volumes.

Length leak in comparison

The constant-time comparison may reveal the length of compared values. In practice, SHA-256 proofs are always 64 characters, making this leak negligible.

Per-connection rate limiting

The authentication attempt counter is local to each SSH connection. An attacker can open N connections and have N × max_auth_failures attempts. Recommendation: combine with fail2ban, sshd MaxAuthTries, or iptables rules.

Reporting a vulnerability

Do not report vulnerabilities via public issues. Contact the maintainer directly for responsible disclosure. The process is described in the contribution guide.

Dependencies

SSH-Frontière has a strict policy of minimal dependencies. Each external crate is evaluated against a weighted matrix (license, governance, community, size, transitive dependencies).

CrateVersionUsageJustification
serde1.xSerialization/deserializationRust de facto standard, required for JSON and TOML
serde_json1.xJSON responsesProtocol output format
toml0.8.xConfiguration loadingRust standard for configuration

Dev dependency: proptest (property tests only, not in the final binary).

Authorized sources: crates.io only. No external git repository allowed. Policy verified by cargo deny.