Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
225f435
test(bench): add frozen hillclimb latency, bytes, and lag harness
mneves75 Nov 27, 2026
367ec67
fix(security): harden vmm, guest init, image registry, and kernel con…
mneves75 Nov 27, 2026
680cc8c
fix(kiri-init): normalize VM ancestor bind paths and handle root dot …
mneves75 Nov 27, 2026
e0c39aa
fix(security): harden CLI, share, USB, setup, diag, and host-access b…
mneves75 Nov 27, 2026
87352a8
fix(daemon): harden mount isolation, auth gates, relays, and DoS bounds
mneves75 Nov 27, 2026
e86ba70
fix(daemon): close socket-ancestor, symlink, and hostetc volume bypasses
mneves75 Nov 27, 2026
5ff4bfc
fix(daemon): resolve dangling symlinks and parent-dir traversal in pa…
mneves75 Nov 27, 2026
4754426
perf(image): cache images.json index by file stamp and avoid cloning …
mneves75 Nov 27, 2026
bb763a0
perf(seccomp): cache compiled BPF programs in bounded LRU with exact …
mneves75 Nov 27, 2026
39c7266
perf(daemon): use RwLock for Engine state/networks and zero-alloc con…
mneves75 Nov 27, 2026
9810e87
perf(daemon): coalesce HTTP responses with writev and serialize hot e…
mneves75 Nov 28, 2026
5d65f2d
perf(daemon): cache RFC3339 prefix, SWAR log split, and zero-alloc lo…
mneves75 Nov 28, 2026
636a15a
perf(image): buffer blob/archive I/O at 128 KiB and batch index updat…
mneves75 Nov 28, 2026
21e995c
perf(proto): pre-reserve exact frame capacities and emit direct share…
mneves75 Nov 28, 2026
23db4af
security(ui,win,pkg,ci): harden webviews, Windows update/WSL, packagi…
mneves75 Nov 27, 2026
88b2199
chore(deps): update rustix for RUSTSEC-2026-0486
mneves75 Nov 28, 2026
6ed1682
perf(ui): lazy-load xterm.js, addons, and xterm.css on terminal open
mneves75 Nov 28, 2026
64ac67a
perf(ui): cache stripped page template and strings_js, compact static…
mneves75 Nov 28, 2026
1be1310
perf(ui): deduplicate inline SVG brand paths into snapshot map and co…
mneves75 Nov 28, 2026
9691056
perf(ui): use O(1) container map and cached live-pill buckets in 1s t…
mneves75 Nov 28, 2026
608e92a
perf(ui): eliminate layout thrashing in fitColumns/actionsWidth/spanR…
mneves75 Nov 28, 2026
2fd6872
perf(ui): early-bail unchanged lists fingerprint, keyed incremental r…
mneves75 Nov 28, 2026
a6d3c45
perf(ui): in-place statusbar/cpu vm tick updates, single memTitle, la…
mneves75 Nov 28, 2026
469888d
perf(ui): pre-apply rtl_ready per-language in lang::tr and avoid inte…
mneves75 Nov 28, 2026
0c8472d
perf(daemon): omit empty/default Docker API fields and coalesce same-…
mneves75 Nov 28, 2026
a013e1b
perf(ui): omit default Kubernetes fields in k8s_items::summarize and …
mneves75 Nov 28, 2026
516c51d
perf(client,ui): add HTTP/1.1 keep-alive connection pool in client.rs…
mneves75 Nov 28, 2026
0273630
perf(ui): encode k8s_items::summarize as compact string-table tuples
mneves75 Nov 28, 2026
83a2f31
perf(ui): lazy-load non-boot panels.js and tighten static JS/CSS comp…
mneves75 Nov 28, 2026
f110aa9
fix(ui): guard table() keyed fast-path against multi-tr rows and trai…
mneves75 Nov 28, 2026
8c05b8a
fix(daemon,scripts): re-check macOS bind security on start and exclud…
mneves75 Nov 28, 2026
4acd961
perf(vm): tune THP madvise, uplink RPS/IRQ affinity, and balloon sawt…
mneves75 Nov 28, 2026
5412a18
perf(vm): hold balloon churn level while shrink window is open
mneves75 Nov 28, 2026
b95bdcb
fix(client,ui): restore test fn boundaries lost in rebase conflict re…
mneves75 Nov 28, 2026
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
46 changes: 46 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Checks Rust dependency advisories, licenses, bans, and sources against
# deny.toml on dependency changes, pushes to main, and a weekly schedule.
#
# Safe for pull requests from forks: read-only token, no secrets, no build
# scripts executed (cargo-deny inspects Cargo.toml and Cargo.lock only).
name: Dependency audit

on:
pull_request:
paths:
- Cargo.toml
- Cargo.lock
- crates/*/Cargo.toml
- xtask/Cargo.toml
- deny.toml
- .github/workflows/audit.yml
push:
branches: [main]
paths:
- Cargo.toml
- Cargo.lock
- crates/*/Cargo.toml
- xtask/Cargo.toml
- deny.toml
- .github/workflows/audit.yml
schedule:
- cron: "17 5 * * 1"

permissions:
contents: read

concurrency:
group: audit-${{ github.event.pull_request.number || github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
deny:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: EmbarkStudios/cargo-deny-action@bb119f768ea239e765aeaef5769558d4f21213aa # v2.1.5
with:
command: check --all-features
28 changes: 28 additions & 0 deletions .github/workflows/page-read-reset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Removes the `page-read` approval label whenever new commits are pushed to a
# pull request, so a review of an earlier commit cannot approve JS added later
# in `crates/kiri/src/ui/index.html` or `crates/kiri-win/src/setup.html`.
#
# Runs on `pull_request_target` with no checkout of PR code and minimal
# `pull-requests: write` permission (only deletes one fixed label name).
name: Reset page-read label

on:
pull_request_target:
types: [synchronize]

permissions:
pull-requests: write

jobs:
reset:
if: contains(github.event.pull_request.labels.*.name, 'page-read')
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Remove page-read label after new commits
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
gh api -X DELETE "repos/$REPO/issues/$PR_NUMBER/labels/page-read" || true
5 changes: 4 additions & 1 deletion .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
# system calls one container costs.
#
# The limits come from main's copy of the script when it has one, so a pull
# request can't loosen them for itself.
# request can't accidentally loosen them for itself. (Because the PR binary
# runs in a `--privileged` container on the same runner as `base`, this guards
# against accidental threshold edits rather than adversarial tampering; the
# job itself has only a read-only token and no secrets.)
#
# Safe for pull requests from forks: it runs on GitHub's machines with a
# read-only token and no secrets, and uses pull_request (never
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ jobs:
read -r cv csum <<< "$(pin COMPOSE)"
[ -n "$dsum" ] && [ -n "$csum" ] || { echo "could not read the pins from cli_pins.rs"; exit 1; }
cd "$RUNNER_TEMP"
curl -fsSL --proto '=https' -o docker.tgz "https://download.docker.com/mac/static/stable/aarch64/docker-$dv.tgz"
curl -fsSL --proto '=https' -o compose "https://github.com/docker/compose/releases/download/$cv/docker-compose-darwin-aarch64"
curl -fsSL --proto '=https' --proto-redir '=https' -o docker.tgz "https://download.docker.com/mac/static/stable/aarch64/docker-$dv.tgz"
curl -fsSL --proto '=https' --proto-redir '=https' -o compose "https://github.com/docker/compose/releases/download/$cv/docker-compose-darwin-aarch64"
echo "$dsum docker.tgz" | shasum -a 256 -c
echo "$csum compose" | shasum -a 256 -c
mkdir -p bin "$HOME/.docker/cli-plugins"
Expand Down Expand Up @@ -254,8 +254,9 @@ jobs:
# pull request adds to the page that needs one (new addresses, new ways to
# reach the network, code that builds or hides code, reads of what is
# worth stealing) and fails until a maintainer who has read it adds the
# label page-read. Remove the label when new commits come in: it stays on
# the pull request and accepts them too.
# label page-read. `.github/workflows/page-read-reset.yml` removes `page-read`
# automatically whenever new commits are pushed so earlier approval cannot
# carry over to unreviewed JS.
page-scan:
needs: scope
if: needs.scope.outputs.page == 'true'
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contrib/windows/kiri.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if ($Update) {
Say "waiting for kiri-win $WaitFor"
while ($WaitFor -and (Get-Process -Id $WaitFor -ErrorAction SilentlyContinue)) { Start-Sleep -Milliseconds 200 }
if (-not (Test-Path -LiteralPath $Msi -PathType Leaf)) { throw "staged MSI not found: $Msi" }
if ((Get-Item -LiteralPath $Msi -Force).Attributes -band [IO.FileAttributes]::ReparsePoint) { throw "refusing silent install: staged MSI is a reparse point" }
$actualHash = (Get-FileHash -LiteralPath $Msi -Algorithm SHA256).Hash
if ($actualHash -notlike $Sha256 -or $actualHash.ToLowerInvariant() -ne $Sha256.ToLowerInvariant()) {
throw "refusing silent install: SHA-256 mismatch for $Msi (expected $Sha256, got $actualHash)"
Expand Down
36 changes: 16 additions & 20 deletions crates/kiri-image/src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//! content-addressed blobs already in the store are verified in memory without
//! rewriting disk files.

use std::collections::HashMap;
use std::io::{self, Read, Write};
use std::collections::{HashMap, HashSet};
use std::io::{self, BufReader, BufWriter, Read, Write};
use std::time::{SystemTime, UNIX_EPOCH};

use serde_json::{Value, json};
Expand Down Expand Up @@ -36,15 +36,15 @@ pub fn load_with_platform(store: &Store, archive: impl Read, platform: Option<&P

/// As [`load`], filtering a multi-platform OCI index to `platforms` when non-empty.
pub fn load_platforms(store: &Store, archive: impl Read, platforms: &[Platform]) -> io::Result<Vec<Image>> {
let mut tar = tar::Archive::new(archive);
let mut tar = tar::Archive::new(BufReader::with_capacity(128 << 10, archive));
// Archive path → blob digest and size, for every regular file.
let mut files: HashMap<String, (String, u64)> = HashMap::new();
let mut manifest: Option<Vec<u8>> = None;
let mut index: Option<Vec<u8>> = None;
let mut oci_layout: Option<Vec<u8>> = None;
let before: Vec<Image> = store.images()?;
let existed = |d: &str| before.iter().any(|i| i.referenced_digests().any(|r| r == d));
let mut ingested: Vec<String> = Vec::new();
let before = store.images_arc()?;
let before_digests: HashSet<&str> = before.iter().flat_map(|i| i.referenced_digests()).collect();
let mut ingested: HashSet<String> = HashSet::new();
let mut pins = Vec::new();
let read = (|| -> io::Result<Vec<Image>> {
for entry in tar.entries()? {
Expand Down Expand Up @@ -96,8 +96,8 @@ pub fn load_platforms(store: &Store, archive: impl Read, platforms: &[Platform])
// that shares the blob must not delete it meanwhile.
let (digest, size, pin) = w.finish_pinned()?;
pins.push(pin);
if !existed(&digest) && !ingested.contains(&digest) {
ingested.push(digest.clone());
if !before_digests.contains(digest.as_str()) {
ingested.insert(digest.clone());
}
files.insert(path, (digest, size));
}
Expand Down Expand Up @@ -162,9 +162,7 @@ fn load_docker(store: &Store, files: &HashMap<String, (String, u64)>, manifest:
loaded.push(from_config(name, &config_digest, &config, layers.clone()));
}
}
for image in &loaded {
store.put_image(image.clone())?;
}
store.put_images(loaded.clone())?;
Ok(loaded)
}

Expand Down Expand Up @@ -374,9 +372,7 @@ fn load_oci(
let name = candidate.tag.unwrap_or_else(|| config_digest.clone());
loaded.push(from_config(name, &config_digest, &config, layers));
}
for image in &loaded {
store.put_image(image.clone())?;
}
store.put_images(loaded.clone())?;
Ok(loaded)
}

Expand All @@ -402,8 +398,8 @@ pub fn hold(store: &Store, images: &[Image]) -> io::Result<Vec<crate::store::Pin
/// Writes `images` as one archive `docker load` reads back.
pub fn save(store: &Store, images: &[Image], out: impl Write) -> io::Result<()> {
let _held = hold(store, images)?;
let mut tar = tar::Builder::new(out);
let mut written: Vec<String> = Vec::new();
let mut tar = tar::Builder::new(BufWriter::with_capacity(128 << 10, out));
let mut written: HashSet<&str> = HashSet::new();
let mut manifest = Vec::new();
// Images that share a config are one entry with several tags.
let mut by_config: Vec<(&Image, Vec<String>)> = Vec::new();
Expand All @@ -420,18 +416,18 @@ pub fn save(store: &Store, images: &[Image], out: impl Write) -> io::Result<()>
for (image, tags) in &by_config {
let blob = |d: &str| format!("blobs/sha256/{}", d.strip_prefix("sha256:").unwrap_or(d));
for d in std::iter::once(&image.config_digest).chain(image.layers.iter().map(|l| &l.digest)) {
if written.contains(d) {
if !written.insert(d.as_str()) {
continue;
}
let path = store.blob_path(d)?;
let mut f = std::fs::File::open(&path)?;
let f = std::fs::File::open(&path)?;
let mut h = tar::Header::new_ustar();
h.set_size(f.metadata()?.len());
h.set_mode(0o644);
h.set_mtime(0);
h.set_entry_type(tar::EntryType::Regular);
tar.append_data(&mut h, blob(d), &mut f)?;
written.push(d.clone());
let mut br = BufReader::with_capacity(128 << 10, f);
tar.append_data(&mut h, blob(d), &mut br)?;
}
manifest.push(json!({
"Config": blob(&image.config_digest),
Expand Down
115 changes: 114 additions & 1 deletion crates/kiri-image/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,10 @@ impl Client {
.collect(),
});
};
// Validate the digest from the untrusted index before interpolating
// it into an authenticated manifest URL.
crate::store::digest_hex(&entry.digest)
.map_err(|_| Error::Manifest(format!("invalid manifest digest {:?}", entry.digest)))?;
let (entry_bytes, _) = self.manifest_with(r, &entry.digest, Some(cancel)).map_err(stopped)?;
if sha256_digest(&entry_bytes) != entry.digest {
return Err(Error::Manifest(format!("manifest {} failed digest check", entry.digest)));
Expand Down Expand Up @@ -1746,7 +1750,7 @@ impl Client {
/// `postgres` gives `latest`, `17-alpine`, `17`… Hub's own API, since
/// the registry's tag list is unordered and has no dates.
pub fn hub_tags(&self, repo: &str, limit: u32) -> Result<Vec<String>, Error> {
let repo = if repo.contains('/') { repo.to_owned() } else { format!("library/{repo}") };
let repo = validate_hub_repo(repo)?;
let url = format!("https://hub.docker.com/v2/repositories/{repo}/tags");
let mut resp = self.agent.get(&url).query("page_size", limit.to_string()).query("ordering", "last_updated").config().max_redirects(5).https_only(true).build().call()?;
if resp.status().as_u16() != 200 {
Expand Down Expand Up @@ -2110,6 +2114,27 @@ fn not_found(e: Error, r: &Reference) -> Error {
}
}

/// Validates a Docker Hub repository name (`alpine` or `namespace/name`) before
/// interpolating it into a `hub.docker.com` API URL (`SEC-V-13`).
fn validate_hub_repo(repo: &str) -> Result<String, Error> {
if repo.is_empty() || repo.len() > 255 {
return Err(Error::Manifest(format!("invalid Docker Hub repository {repo:?}")));
}
let alnum = |b: u8| b.is_ascii_lowercase() || b.is_ascii_digit();
let valid_seg = |s: &str| {
!s.is_empty()
&& s.as_bytes().first().is_some_and(|&b| alnum(b))
&& s.as_bytes().last().is_some_and(|&b| alnum(b))
&& s.bytes().all(|b| alnum(b) || b".-_".contains(&b))
};
let mut parts = repo.split('/');
match (parts.next(), parts.next(), parts.next()) {
(Some(name), None, None) if valid_seg(name) => Ok(format!("library/{name}")),
(Some(ns), Some(name), None) if valid_seg(ns) && valid_seg(name) => Ok(format!("{ns}/{name}")),
_ => Err(Error::Manifest(format!("invalid Docker Hub repository {repo:?}"))),
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -4438,4 +4463,92 @@ mod tests {
assert!(got.starts_with(b"{\"schemaVersion\":2"));
assert_eq!(server.join().unwrap(), 3);
}

#[test]
fn resolve_rejects_malformed_index_entry_digest_without_requesting_it() {
let index = serde_json::json!({
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 10,
"digest": "sha256:../../other-repo/manifests/secret?foo=bar",
"platform": {"architecture": "amd64", "os": "linux"},
}],
})
.to_string();
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let host = listener.local_addr().unwrap().to_string();
let served = std::thread::spawn(move || {
let mut seen = Vec::new();
'conns: for c in listener.incoming() {
let mut c = c.unwrap();
let mut first = [0u8; 1];
if c.peek(&mut first).unwrap_or(0) == 1 && first[0] == 0x16 {
let _ = c.write_all(b"HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
continue;
}
let mut head = Vec::new();
let mut b = [0u8; 1];
while !head.ends_with(b"\r\n\r\n") && c.read(&mut b).unwrap_or(0) == 1 {
head.push(b[0]);
}
let head = String::from_utf8_lossy(&head).to_string();
if head.starts_with("QUIT") {
break 'conns;
}
if head.is_empty() {
continue 'conns;
}
let path = head.lines().next().and_then(|l| l.split_whitespace().nth(1)).unwrap_or("").to_string();
seen.push(path.clone());
let (status, body, kind) = if path == "/v2/" {
(200, b"{}".as_slice(), "application/json")
} else {
(200, index.as_bytes(), "application/vnd.oci.image.index.v1+json")
};
let resp = format!("HTTP/1.1 {status} OK\r\nContent-Type: {kind}\r\nContent-Length: {}\r\nConnection: close\r\n\r\n", body.len());
let _ = c.write_all(resp.as_bytes());
let _ = c.write_all(body);
}
seen
});

let client = test_client();
let r = Reference::parse(&format!("{host}/app/test:latest")).unwrap();
let platform = Platform::parse("linux/amd64").unwrap();
let err = match client.resolve(&r, &platform, &Cancel::new()) {
Ok(_) => panic!("malformed index digest should be rejected"),
Err(e) => e,
};
assert!(matches!(err, Error::Manifest(_)), "unexpected error: {err:?}");
quit(&host);
let seen = served.join().unwrap();
assert!(!seen.iter().any(|p| p.contains("other-repo") || p.contains("..")), "malformed digest was requested: {seen:?}");
}

#[test]
fn hub_tags_rejects_malformed_repository_names() {
assert_eq!(validate_hub_repo("postgres").unwrap(), "library/postgres");
assert_eq!(validate_hub_repo("bitnami/redis").unwrap(), "bitnami/redis");
assert_eq!(validate_hub_repo("my_org/my-app.1").unwrap(), "my_org/my-app.1");
let client = Client::new();
for bad in [
"",
"../users/me#",
"library/alpine?page_size=999",
"library/alpine#frag",
"a/b/c",
"/alpine",
"alpine/",
"..",
".",
"library/..",
"Alpine",
"foo bar",
] {
assert!(validate_hub_repo(bad).is_err(), "{bad:?}");
assert!(matches!(client.hub_tags(bad, 10), Err(Error::Manifest(_))), "{bad:?}");
}
}
}
Loading