Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ jobs:
- name: Name the system call when the worker sandbox's filter killed a grant worker
if: failure()
run: sudo dmesg | grep 'type=1326' | tail -n 20 || true
gateway-filter-sandbox:
# A container under Docker's default security profile refuses namespaces,
# as ECS Fargate does. The script runs the containment test and the
# runtime test under the filter sandbox there, and proves that the
# namespace sandbox fails at startup with the named error.
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Run the Gateway under the filter sandbox where namespaces are refused
run: scripts/filter-sandbox-container.sh
- name: Name the system call when the worker sandbox's filter killed a grant worker
if: failure()
run: sudo dmesg | grep 'type=1326' | tail -n 20 || true
curl:
runs-on: ubuntu-24.04
timeout-minutes: 40
Expand Down
34 changes: 34 additions & 0 deletions crates/countersign-gateway/src/runtime/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashSet;
use std::fmt;
use std::fs;
use std::io;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
Expand Down Expand Up @@ -27,12 +28,45 @@ pub(crate) struct Config {
#[serde(default)]
pub denied_networks: Vec<IpNet>,
pub shared: Option<Shared>,
#[serde(default)]
pub worker_sandbox: WorkerSandbox,
/// Conservative upper bound on the difference between Broker and Gateway
/// UTC. The operator must maintain synchronized clocks.
#[serde(default = "default_uncertainty")]
pub clock_uncertainty_ms: u64,
}

/// The worker sandbox the operator chose (ADR 0001). The Gateway runs every
/// grant worker under it, and never under the other one.
#[derive(Deserialize, Debug, Clone, Copy, Default, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub(crate) enum WorkerSandbox {
/// The base layers inside bubblewrap's namespaces.
#[default]
Namespaces,
/// The base layers alone, for a host that refuses namespaces.
Filter,
}

impl WorkerSandbox {
/// The layer the supervisor adds around the base layers, when it adds one.
pub fn outer_layer(self) -> Option<&'static str> {
match self {
WorkerSandbox::Namespaces => Some("namespaces"),
WorkerSandbox::Filter => None,
}
}
}

impl fmt::Display for WorkerSandbox {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
WorkerSandbox::Namespaces => "namespaces",
WorkerSandbox::Filter => "filter",
})
}
}

fn default_uncertainty() -> u64 {
1000
}
Expand Down
24 changes: 18 additions & 6 deletions crates/countersign-gateway/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Gateway {
return Err(Capacity.into());
}
let (fence, closed) = watch::channel(false);
let (process, exit) = ChildHandle::launch()?;
let (process, exit) = ChildHandle::launch(self.config.worker_sandbox)?;
let slot = Slot {
fence,
requests: Arc::new(Semaphore::new(32)),
Expand Down Expand Up @@ -856,9 +856,10 @@ pub fn grant_worker() -> Result<()> {
match countersign_gateway::worker_sandbox::confine() {
Ok(layers) => worker::serve(layers),
Err(error) => {
// The startup probe passes this on: the layer, then the cause.
eprintln!("{error}");
std::process::exit(1);
// The startup probe passes both on: the cause as written here,
// the layer as the exit status.
eprintln!("{}", error.source);
std::process::exit(worker::failed_layer_exit(error.layer));
}
}
}
Expand All @@ -875,8 +876,19 @@ pub async fn run(args: &[String]) -> Result<()> {
if verb != "serve" {
return Err(invalid("unrecognized Gateway command"));
}
let layers = ChildHandle::verify_environment().await?;
eprintln!("Gateway worker sandbox \"namespaces\": namespaces, {layers}");
let sandbox = config.worker_sandbox;
let layers = match ChildHandle::verify_environment(sandbox).await {
Ok(layers) => layers,
Err(error) => {
// In its own words, not as `main` would print it.
eprintln!("{error}");
std::process::exit(1);
}
};
match sandbox.outer_layer() {
Some(outer) => eprintln!("Gateway worker sandbox \"{sandbox}\": {outer}, {layers}"),
None => eprintln!("Gateway worker sandbox \"{sandbox}\": {layers}"),
}
let policy = config.policy()?;
let broker = Broker::new(&config)?;
let (issuer, tls) = if let Some(shared) = &config.shared {
Expand Down
Loading
Loading