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
20 changes: 20 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,24 @@ ignore = [
# sqlx is ever built with the `sqlite` feature or any other libsqlite3-sys
# consumer enters the build.
"RUSTSEC-2026-0459", # libsqlite3-sys bundled SQLite CVE (not linked in our build)

# curve25519-dalek 4.1.3 (AVX-512 backend scalar-multiplication arithmetic
# bug; RUSTSEC-2026-0620, upstream dalek-cryptography/curve25519-dalek#934).
# Reached through ed25519-dalek 2.2.0 and crypto_box 0.9.1 (twigpine-core,
# twigpine-attest, twigpine-cli, twigpine-node). Only 5.1.0 is patched and
# nothing on the 4.x line is, and crypto_box has no stable release after
# 0.9.1 that could move us to dalek 5 (verified 2026-11-30: only
# 0.10.0-pre.0 exists). NOT REACHABLE in our builds: on 4.0.0 to 4.1.3 the
# AVX-512 backend needs a nightly compiler, and every build and CI path here
# uses stable Rust (Dockerfile and Dockerfile.bins pin rust:1.91; CI uses
# stable, 1.91 and beta; no RUSTFLAGS, target-cpu or nightly anywhere in the
# repo). Impact if it were reachable is incorrect scalar-multiplication
# output on an attacker-chosen point (worst case a valid signature read as
# invalid), not key or secret disclosure. The other copy (5.0.0 via
# libp2p-identity) is fixed in Cargo.lock by the 5.1.0 bump, so this ignore
# applies to 4.1.3 only. REMOVE when Cargo.lock has no curve25519-dalek
# below 5.1.0: `grep -A1 'name = "curve25519-dalek"' Cargo.lock`.
# Retirement owner: node maintainers, enforced by the weekly audit-schedule
# drift guard ("Fail if curve25519-dalek moved while its ignore remains").
"RUSTSEC-2026-0620", # curve25519-dalek AVX-512 bug (4.1.3 needs nightly; no 4.x fix)
]
21 changes: 21 additions & 0 deletions .github/workflows/audit-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,24 @@ jobs:
exit 1
fi
echo "No drift: lru ignore is consistent with the pinned versions."

# Drift guard: the RUSTSEC-2026-0620 (curve25519-dalek) ignore is only
# valid while the lockfile holds exactly the versions it was written for
# (4.1.3 via ed25519-dalek 2 and crypto_box, 5.1.0 via libp2p-identity).
# Any move, whether the 4.x copy leaving the tree or a vulnerable 5.0.0
# returning, must revisit the ignore. Retirement owner: node maintainers,
# via this weekly job (see the waiver comment in .cargo/audit.toml).
- name: Fail if curve25519-dalek moved while its ignore remains
run: |
set -euo pipefail
versions="$(grep -A1 'name = "curve25519-dalek"' Cargo.lock | grep '^version' | cut -d'"' -f2 | sort -u | tr '\n' ' ' || true)"
echo "curve25519-dalek versions in Cargo.lock: ${versions:-not present}"
dalek_ignore_present=false
if grep -qE '^[[:space:]]*"RUSTSEC-2026-0620"' .cargo/audit.toml; then
dalek_ignore_present=true
fi
if [ "$dalek_ignore_present" = true ] && [ "${versions}" != "4.1.3 5.1.0 " ]; then
echo "::error::curve25519-dalek versions are [${versions:-absent from Cargo.lock}] but the RUSTSEC-2026-0620 ignore is still in .cargo/audit.toml. Re-triage the waiver against the advisory's patched range (>=5.1.0) and either drop the ignore or update the pinned set."
exit 1
fi
echo "No drift: curve25519-dalek ignore is consistent with the pinned versions."
6 changes: 3 additions & 3 deletions Cargo.lock

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

27 changes: 11 additions & 16 deletions crates/twigpine-node/src/api/encrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub async fn get_encrypted_blob(
auth: Option<Extension<AuthenticatedDid>>,
Path((owner, repo, oid)): Path<(String, String, String)>,
) -> Result<axum::response::Response> {
let key = crate::rate_limit::client_key(&headers, peer, state.push_limiter_trust);
let key = state.client_key(&headers, peer);
let caller = auth.as_ref().map(|e| e.0 .0.as_str());
let (record, _rules) =
crate::api::authorize_repo_read(&state, &owner, &repo, caller, "/").await?;
Expand All @@ -144,26 +144,21 @@ pub async fn get_encrypted_blob(
Ok(permit) => permit,
Err(_) => {
tracing::warn!("encrypted-blob serve cap reached; shedding request with 503");
if let Some(key) = key.as_deref() {
state.encrypted_blob_rate_limiter.refund(key).await;
}
state.encrypted_blob_rate_limiter.refund(&key).await;
return Err(AppError::Overloaded(
"encrypted blob service at capacity, retry shortly".into(),
));
}
};
let per_source = match key.as_deref() {
Some(ip) => match state.encrypted_serve_per_caller.try_acquire(ip) {
Some(permit) => Some(permit),
None => {
tracing::warn!(key = %ip, "encrypted-blob per-source serve cap reached; shedding request with 503");
state.encrypted_blob_rate_limiter.refund(ip).await;
return Err(AppError::Overloaded(
"encrypted blob service at capacity for this source, retry shortly".into(),
));
}
},
None => None,
let per_source = match state.encrypted_serve_per_caller.try_acquire(&key) {
Some(permit) => Some(permit),
None => {
tracing::warn!(key = %key, "encrypted-blob per-source serve cap reached; shedding request with 503");
state.encrypted_blob_rate_limiter.refund(&key).await;
return Err(AppError::Overloaded(
"encrypted blob service at capacity for this source, retry shortly".into(),
));
}
};
// Opaque on purpose: the error text names the node's Kubo endpoint and the
// upstream status, neither of which an anonymous caller should see.
Expand Down
4 changes: 2 additions & 2 deletions crates/twigpine-node/src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,10 @@ where
T: Send + 'static,
F: FnOnce(&str, &std::path::Path, std::time::Instant) -> Result<T> + Send + 'static,
{
let caller_key = read_caller_key(headers, peer, state.push_limiter_trust);
let caller_key = state.client_key(headers, peer);
let caller_permit = acquire_read_caller_permit(
&state.git_read_per_caller,
caller_key.as_deref(),
&caller_key,
&record.name,
handler,
)?;
Expand Down
1 change: 1 addition & 0 deletions crates/twigpine-node/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ pub fn build_router(state: AppState) -> Router {
let encrypted_blob_limiter = rate_limit::IpRateLimiter {
limiter: state.encrypted_blob_rate_limiter.clone(),
trust: state.push_limiter_trust,
trusted_peers: state.push_limiter_trusted_peers.clone(),
};
let encrypted_blob_serve_routes = Router::new()
.route(
Expand Down
2 changes: 1 addition & 1 deletion crates/twigpine-node/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ pub struct AppState {
pub encrypted_serve_semaphore: Arc<tokio::sync::Semaphore>,
/// Per-source share of `encrypted_serve_semaphore`, keyed on the resolved
/// client IP, so one source cannot hold every serve slot. A request with no
/// resolvable key is bounded by the global pool only.
/// verifiable socket peer shares the reserved unknown-peer bucket under this cap.
pub encrypted_serve_per_caller: crate::rate_limit::PerCallerConcurrency,
/// Per-client-IP rate brake for the encrypted-blob serve, in a bucket of its
/// own: a clone fetches one envelope per withheld blob, so sharing the hourly
Expand Down
Loading