mirror of
https://github.com/pollen-robotics/microduck.git
synced 2026-12-03 02:47:45 +08:00
Default media and BLE listeners to secure access
This commit is contained in:
+3
-2
@@ -398,8 +398,9 @@ async fn serve_on_an_adapter(
|
||||
// authentication" and starts pairing there and then, which a subscribe cannot do:
|
||||
// `CharacteristicNotify` carries no encryption flags at all.
|
||||
//
|
||||
// NOTE: this is currently the *unencrypted* path in practice — see
|
||||
// `docs/design/app-path-design.md` §5.5. Requiring encryption here hangs CoreBluetooth.
|
||||
// The secure default requires encryption here. The historical macOS
|
||||
// CoreBluetooth hang still needs phone-specific validation; see
|
||||
// `docs/design/app-path-design.md` §5.5.
|
||||
//
|
||||
// The value matters less than the fact that reading it needs a bond; the API
|
||||
// version is the most useful byte available, and a client that finds a version it
|
||||
|
||||
+24
-28
@@ -30,29 +30,13 @@ struct Args {
|
||||
#[arg(long, default_value = duck_ipc_proto::socket::CONFIG)]
|
||||
config_socket: PathBuf,
|
||||
|
||||
/// Require a paired, encrypted link.
|
||||
///
|
||||
/// **Off by default, and that is not where this ends up.** Requiring pairing makes the version
|
||||
/// read hang on macOS — CoreBluetooth issues the Read Request, BlueZ refuses it for insufficient
|
||||
/// encryption, and nothing resolves it — so a robot serving the secure configuration cannot be
|
||||
/// talked to at all (`docs/design/app-path-design.md` §5.5).
|
||||
///
|
||||
/// Between a default that is secure and unusable and one that works and is insecure, this is
|
||||
/// pre-shipping development tooling and the usable one wins. The cost is real and unhedged:
|
||||
/// with pairing off, anyone in radio range can read the PIN as it crosses and write any allowed
|
||||
/// request — including `net.connect`, which carries a wifi passphrase. Every robot running this
|
||||
/// is a robot whose wifi credentials are readable by a bystander.
|
||||
///
|
||||
/// This must flip before anything is handed to anyone. §8.1 is the blocker.
|
||||
#[arg(long)]
|
||||
/// Retained for compatibility with existing service overrides. Pairing is now required
|
||||
/// unless `--insecure-no-pairing` is explicitly selected for a controlled bench.
|
||||
#[arg(long, conflicts_with = "insecure_no_pairing")]
|
||||
require_pairing: bool,
|
||||
|
||||
/// Accepted and ignored: not requiring pairing is now the default.
|
||||
///
|
||||
/// Kept only so a board carrying a `--insecure-no-pairing` drop-in — which is how the flag was
|
||||
/// used while it existed — does not fail to start on the update that removes it. An unknown
|
||||
/// argument would take BLE down on exactly the boards that were using it.
|
||||
#[arg(long, hide = true)]
|
||||
/// Disable BLE link encryption only on an isolated development bench.
|
||||
#[arg(long, hide = true, conflicts_with = "require_pairing")]
|
||||
insecure_no_pairing: bool,
|
||||
|
||||
/// Pin the advertised name, instead of asking `configd` what the robot is called.
|
||||
@@ -64,6 +48,22 @@ struct Args {
|
||||
name: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod security_defaults {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn pairing_requires_explicit_insecure_override_to_disable() {
|
||||
let normal = Args::try_parse_from(["btd"]).unwrap();
|
||||
assert!(!normal.insecure_no_pairing);
|
||||
let bench = Args::try_parse_from(["btd", "--insecure-no-pairing"]).unwrap();
|
||||
assert!(bench.insecure_no_pairing);
|
||||
assert!(
|
||||
Args::try_parse_from(["btd", "--require-pairing", "--insecure-no-pairing"]).is_err()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn hostname() -> String {
|
||||
// /etc/hostname rather than the `hostname` crate or a libc call: one file read, no
|
||||
// dependency, and it is what the board is actually configured with.
|
||||
@@ -115,12 +115,8 @@ async fn main() -> ExitCode {
|
||||
fallback: hostname(),
|
||||
};
|
||||
|
||||
if args.insecure_no_pairing {
|
||||
tracing::warn!(
|
||||
"--insecure-no-pairing is now the default and does nothing; remove it from the unit"
|
||||
);
|
||||
}
|
||||
if !args.require_pairing {
|
||||
let require_pairing = args.require_pairing || !args.insecure_no_pairing;
|
||||
if !require_pairing {
|
||||
// Loud, every start, because the whole point of choosing the usable default is that the
|
||||
// insecurity stays visible rather than becoming the thing nobody remembers.
|
||||
tracing::warn!(
|
||||
@@ -129,7 +125,7 @@ async fn main() -> ExitCode {
|
||||
);
|
||||
}
|
||||
|
||||
run(sockets, name, args.require_pairing).await
|
||||
run(sockets, name, require_pairing).await
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# The App Path — `btd` and `configd`
|
||||
|
||||
> **Security update (production candidate):** `btd` now requires an encrypted
|
||||
> paired link by default. `--insecure-no-pairing` remains an explicit bench-only
|
||||
> override. The historical macOS CoreBluetooth hang described in §5.5 is not
|
||||
> resolved by this policy change; onboarding must be validated on real iPhone
|
||||
> and Android devices before shipment. A factory `000000` PIN still provides no
|
||||
> meaningful per-device authorization and must be replaced in provisioning.
|
||||
|
||||
Status: draft · Date: 2026-08-04 · Owner: pierre
|
||||
|
||||
How a phone configures a robot: wifi, name, reboot, version, and triggering an update.
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# WebRTC: sessions, signalling, and the control channel
|
||||
|
||||
> **Security update (production candidate):** `mediad` now binds its signalling,
|
||||
> control and HTTP console/snapshot listeners to `127.0.0.1` by default. The
|
||||
> authenticated remote relay still connects to that local signaller. Direct LAN
|
||||
> WebRTC and `http://<robot>:8080/` no longer work with the secure default; the
|
||||
> local-mode design below describes the previous behavior. Do not bind a LAN
|
||||
> address until an authenticated local gateway is implemented and tested.
|
||||
|
||||
How a phone, a browser or a server-side program drives and observes the robot over WebRTC.
|
||||
[`architecture.md`](architecture.md) §5 states the requirement; this owns the mechanism.
|
||||
|
||||
|
||||
+19
-12
@@ -1,16 +1,13 @@
|
||||
//! `mediad` — camera, mic, WebRTC, and the remote gateway.
|
||||
//!
|
||||
//! Runs the signalling server in this process, streams video to whoever connects, and gives each
|
||||
//! peer a `control` datachannel that is a pipe to the robot API. `docs/design/remote-webrtc.md` is
|
||||
//! the design.
|
||||
//! Runs the signalling server in this process and gives each admitted peer a `control`
|
||||
//! datachannel that is a pipe to the robot API. `docs/design/remote-webrtc.md` is the design.
|
||||
//!
|
||||
//! ## What it does not do
|
||||
//!
|
||||
//! **It does not authenticate.** Anyone who reaches the signalling port can drive the robot and
|
||||
//! see its camera. That is a decision, not an omission — §4 has the reasoning, and the short
|
||||
//! version is that the pairing PIN is a shared `000000`, so a gate would add a step to every
|
||||
//! connection and prove nothing. The bridge that makes a robot reachable from outside the LAN
|
||||
//! authenticates on both sides before a session arrives.
|
||||
//! **The local signalling server does not authenticate.** It therefore binds to loopback by
|
||||
//! default; the remote bridge authenticates before forwarding a session to it. Explicitly
|
||||
//! binding a LAN address exposes camera and control to every peer that can reach that address.
|
||||
//!
|
||||
//! **It is not on the recovery path.** If `mediad` will not start, the robot still walks, still
|
||||
//! takes an update, and is still reachable over Bluetooth. That is why it may depend on a plugin
|
||||
@@ -26,10 +23,9 @@ use clap::Parser;
|
||||
struct Args {
|
||||
/// Where to bind the signalling server.
|
||||
///
|
||||
/// All interfaces by default, and that is the point: loopback-only would mean a peer on the
|
||||
/// LAN cannot reach it at all and every session would have to go through a bridge, which
|
||||
/// defeats having a local mode. See `remote-webrtc.md` §3.
|
||||
#[arg(long, default_value = "0.0.0.0")]
|
||||
/// Also used for the unauthenticated console and snapshot endpoint. Keep loopback-only
|
||||
/// until an authenticated local gateway is available. A LAN bind is for controlled benches.
|
||||
#[arg(long, default_value = "127.0.0.1")]
|
||||
host: String,
|
||||
|
||||
/// The signalling server's port. 8443 is what `webrtcsink`'s own signaller defaults to, so a
|
||||
@@ -173,6 +169,17 @@ struct Args {
|
||||
frame_socket: std::path::PathBuf,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod security_defaults {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn local_listeners_are_not_exposed_by_default() {
|
||||
let args = Args::try_parse_from(["mediad"]).unwrap();
|
||||
assert_eq!(args.host, "127.0.0.1");
|
||||
}
|
||||
}
|
||||
|
||||
// Gated with the `main` that calls it: without a pipeline there is nothing to point at a socket and
|
||||
// `-D warnings` would call this dead.
|
||||
#[cfg(any(target_os = "linux", feature = "gstreamer"))]
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
//! The page, served by the daemon it drives.
|
||||
//!
|
||||
//! An embedded console and an on-demand PNG snapshot, with no frontend build step. `http://<robot>:8080/` and there is nothing else to run —
|
||||
//! An embedded console and an on-demand PNG snapshot, with no frontend build step. The secure
|
||||
//! default serves these on loopback only; a direct LAN console needs an authenticated gateway.
|
||||
//! which is the whole of it, and `webrtc-console.md` §1 is why it is worth a dependency and a
|
||||
//! second port.
|
||||
//!
|
||||
|
||||
Reference in New Issue
Block a user