Skip to content

Commit 9b0f744

Browse files
tlongwell-blocknpub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67dTyler Longwell
authored
resolve findings (#3150)
Fixes all six HIGH findings from the buzz security report, one commit per finding. Independently reviewed to approval by Max at `0158ae542`, plus a deep isolated live pass (clean-room compose stack, weird ports, full product matrix) at the same head — see the buzz-security thread for evidence. `fe65c07c3` merges current `origin/main` on top (new commit, no rebase), inheriting the nostr 0.44.6 bump (#3135) and relay-admin ban gate (#3128). ## Findings and fixes | Finding | Commit | Fix | |---|---|---| | 003 — quinn-proto RUSTSEC-2026-0185 | `e5dcdec72` | Bump quinn-proto 0.11.14 → 0.11.16 (lockfile-only) | | 002/004 — linkify-it quadratic-parse DoS (GHSA-22p9-wv53-3rq4, GHSA-v245-v573-v5vm) | `923b3c20f` | pnpm override `linkify-it: ^5.0.2`; `pnpm why` confirms a single 5.0.2 copy | | 001 — media reads served unauthenticated by default | `0f277e3e2` | Helm `requireMediaGetAuth` defaults to `true` + rendered-chart test pinning the default | | 006 — removed workflow owners retain webhook-exfiltration authority | `4749bd56c` | Fail-closed per-fire authority gate (current owner/admin membership) on **all four** trigger doors (on_event, scheduler pre-claim, manual trigger, webhook — masked as generic 404), save-time gate for `call_webhook` defs, durable disable-on-removal wired to kinds 9001 + 9022 | | 005 — git Smart-HTTP reads ignore channel membership | `e648f2dba` + `0158ae542` | `authorize_git_read`: caller's **current active membership** in the repo's bound channel, checked before any hydration/subprocess on all three read doors (`info_refs` for both services + `upload_pack` POST). Uniform generic 404 denials (no membership probing), no repo-owner bypass, first-`buzz-channel`-tag binding semantics fail closed on ambiguous duplicates (mutation-verified test). Resolution follows the live kind:30617 announcement, so deleted/replaced announcements deny immediately. The committed `e2e-git-perms.sh` guest scenario previously asserted the vulnerability — now asserts denial. | ## Behavior changes to be aware of 1. **Unbound repos fail closed for git reads.** `buzz repos create` emits no `buzz-channel` tag, so CLI-created repos without a binding are unreadable via git HTTP. Correct per finding 005's fail-closed posture; a follow-up could bind CLI-created repos at creation time. 2. **006 is conservative:** a workflow disabled on owner removal does not auto-re-enable if the owner is re-added — explicit re-enable required. 3. Merge conflict resolution in `fe65c07c3`: kept main's `@radix-ui/react-dismissable-layer` 1.1.19 bump alongside the linkify-it security override (`pnpm-workspace.yaml` + lockfile). ## Verification at the merge head `fe65c07c3` (same shell) - buzz-relay `--lib`: 761 passed / 1 failed — the lone red is the known pre-existing `mesh_demo::demo_join_forwarded_arm_round_trips_echo` 504 flake, present on main - SEC-005 module incl. PG behavioral matrix: 8/8 (removed-member, never-member, owner-no-bypass, deleted-30617, malformed/ambiguous binding, owner-mismatch all denied) - buzz-workflow 153/0, buzz-db 84/0; `clippy --all-targets -D warnings` + `fmt --check` clean - Desktop JS 3637/3637, tsc clean, biome clean, file-size/px-text/pubkey-truncation gates clean - `helm lint` + `helm unittest` (40/40) on `deploy/charts/buzz` - All five pre-push hooks green (desktop-check, desktop-test, rust-tests, desktop-tauri-test, branch-skew) Prior review evidence at `0158ae542` (pre-merge): Max's independent exact-head approval + clean-room live regression pass (`WORK_LOGS/2026-07-27_SECURITY_HIGH_LIVE_TEST.md` in his workspace). Max will re-run the deep local pass at this post-merge head before merge. --------- Signed-off-by: Tyler Longwell <[email protected]> Signed-off-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Co-authored-by: Tyler Longwell <[email protected]>
1 parent a041e2d commit 9b0f744

16 files changed

Lines changed: 1154 additions & 27 deletions

File tree

‎Cargo.lock‎

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/buzz-db/src/lib.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,6 +2639,23 @@ impl Db {
26392639
workflow::set_workflow_enabled(&self.pool, community_id, id, enabled).await
26402640
}
26412641

2642+
/// Disable all of an owner's workflows in a channel (SEC-006, on
2643+
/// membership loss). Returns the number of workflows disabled.
2644+
pub async fn disable_workflows_for_owner_in_channel(
2645+
&self,
2646+
community_id: CommunityId,
2647+
channel_id: Uuid,
2648+
owner_pubkey: &[u8],
2649+
) -> Result<u64> {
2650+
workflow::disable_workflows_for_owner_in_channel(
2651+
&self.pool,
2652+
community_id,
2653+
channel_id,
2654+
owner_pubkey,
2655+
)
2656+
.await
2657+
}
2658+
26422659
/// Delete a workflow and all its runs/approvals.
26432660
pub async fn delete_workflow(&self, community_id: CommunityId, id: Uuid) -> Result<()> {
26442661
workflow::delete_workflow(&self.pool, community_id, id).await

‎crates/buzz-db/src/workflow.rs‎

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,36 @@ pub async fn set_workflow_enabled(
707707
Ok(())
708708
}
709709

710+
/// Disable all of `owner_pubkey`'s workflows in a channel (SEC-006).
711+
///
712+
/// Called when the owner loses channel membership (kind 9001 removal or kind
713+
/// 9022 leave) so their workflows stop firing durably — across pods and
714+
/// restarts — rather than only until the per-fire authority gate happens to
715+
/// run. Idempotent; returns the number of workflows disabled so the caller
716+
/// can decide whether a trigger-cache invalidation is needed.
717+
pub async fn disable_workflows_for_owner_in_channel(
718+
pool: &PgPool,
719+
community_id: CommunityId,
720+
channel_id: Uuid,
721+
owner_pubkey: &[u8],
722+
) -> Result<u64> {
723+
let affected = sqlx::query(
724+
r#"
725+
UPDATE workflows
726+
SET enabled = FALSE
727+
WHERE community_id = $1 AND channel_id = $2 AND owner_pubkey = $3 AND enabled = TRUE
728+
"#,
729+
)
730+
.bind(community_id.as_uuid())
731+
.bind(channel_id)
732+
.bind(owner_pubkey)
733+
.execute(pool)
734+
.await?
735+
.rows_affected();
736+
737+
Ok(affected)
738+
}
739+
710740
/// Delete a workflow and all its runs/approvals (CASCADE).
711741
///
712742
/// NOTE: see the cache-invalidation note on [`update_workflow`]. The relay's
@@ -2272,4 +2302,100 @@ mod tests {
22722302
"B's approval must remain pending after A is granted"
22732303
);
22742304
}
2305+
2306+
// -- SEC-006: disable-on-membership-loss primitive -------------------------
2307+
2308+
/// `disable_workflows_for_owner_in_channel` must disable exactly the
2309+
/// departing owner's enabled workflows in that channel — not other owners'
2310+
/// workflows, not the same owner's workflows in other channels — and be
2311+
/// idempotent. Disabled workflows must drop out of the trigger-path list.
2312+
#[tokio::test]
2313+
#[ignore = "requires Postgres"]
2314+
async fn disable_for_owner_scopes_to_owner_and_channel() {
2315+
let pool = setup_pool().await;
2316+
let community = make_community(&pool).await;
2317+
2318+
let departing = vec![0xd1; 32];
2319+
let staying = vec![0xd2; 32];
2320+
ensure_user(&pool, community, &departing)
2321+
.await
2322+
.expect("ensure departing");
2323+
ensure_user(&pool, community, &staying)
2324+
.await
2325+
.expect("ensure staying");
2326+
2327+
let channel_a = make_channel(&pool, community, &departing).await;
2328+
let channel_b = make_channel(&pool, community, &departing).await;
2329+
2330+
let def = r#"{"trigger":{"on":"message_posted"},"steps":[]}"#;
2331+
let wf_departing_a = create_workflow(
2332+
&pool,
2333+
community,
2334+
Some(channel_a),
2335+
&departing,
2336+
"departing-a",
2337+
def,
2338+
&[0u8; 32],
2339+
)
2340+
.await
2341+
.expect("wf departing a");
2342+
let wf_departing_b = create_workflow(
2343+
&pool,
2344+
community,
2345+
Some(channel_b),
2346+
&departing,
2347+
"departing-b",
2348+
def,
2349+
&[0u8; 32],
2350+
)
2351+
.await
2352+
.expect("wf departing b");
2353+
let wf_staying_a = create_workflow(
2354+
&pool,
2355+
community,
2356+
Some(channel_a),
2357+
&staying,
2358+
"staying-a",
2359+
def,
2360+
&[0u8; 32],
2361+
)
2362+
.await
2363+
.expect("wf staying a");
2364+
2365+
let disabled =
2366+
disable_workflows_for_owner_in_channel(&pool, community, channel_a, &departing)
2367+
.await
2368+
.expect("disable");
2369+
assert_eq!(
2370+
disabled, 1,
2371+
"exactly the departing owner's channel-A workflow"
2372+
);
2373+
2374+
// Idempotent: second call finds nothing enabled.
2375+
let again = disable_workflows_for_owner_in_channel(&pool, community, channel_a, &departing)
2376+
.await
2377+
.expect("disable again");
2378+
assert_eq!(again, 0, "second disable must be a no-op");
2379+
2380+
let enabled_a = list_enabled_channel_workflows(&pool, community, channel_a)
2381+
.await
2382+
.expect("list channel a");
2383+
let enabled_a_ids: Vec<Uuid> = enabled_a.iter().map(|w| w.id).collect();
2384+
assert!(
2385+
!enabled_a_ids.contains(&wf_departing_a),
2386+
"departing owner's workflow must no longer be trigger-eligible"
2387+
);
2388+
assert!(
2389+
enabled_a_ids.contains(&wf_staying_a),
2390+
"other owners' workflows in the channel must be untouched"
2391+
);
2392+
2393+
let enabled_b = list_enabled_channel_workflows(&pool, community, channel_b)
2394+
.await
2395+
.expect("list channel b");
2396+
assert!(
2397+
enabled_b.iter().any(|w| w.id == wf_departing_b),
2398+
"same owner's workflow in a different channel must be untouched"
2399+
);
2400+
}
22752401
}

‎crates/buzz-relay/src/api/bridge.rs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,26 @@ pub async fn workflow_webhook(
18721872
}
18731873
let trigger_ctx_json = serde_json::to_value(&trigger_ctx).ok();
18741874

1875+
// SEC-006: the webhook secret authenticates the *caller*, but the run
1876+
// executes with the workflow **owner's** standing authority — so the
1877+
// secret alone is insufficient. Immediately before run creation, reject
1878+
// disabled/inactive workflows and recheck the owner's current channel
1879+
// membership (and role, for exfiltration-capable definitions). Fail
1880+
// closed with the same generic 404 as the lookups above so a
1881+
// revoked-owner workflow is indistinguishable from a nonexistent one.
1882+
if !workflow.enabled || workflow.status != buzz_db::workflow::WorkflowStatus::Active {
1883+
return Err(not_found("workflow not found"));
1884+
}
1885+
let Some(wf_channel_id) = workflow.channel_id else {
1886+
// No channel scope means no channel authority to verify — fail closed.
1887+
return Err(not_found("workflow not found"));
1888+
};
1889+
state
1890+
.workflow_engine
1891+
.check_owner_authority(community_id, wf_channel_id, &workflow.owner_pubkey, &def)
1892+
.await
1893+
.map_err(|_| not_found("workflow not found"))?;
1894+
18751895
let run_id = state
18761896
.db
18771897
.create_workflow_run(community_id, id, None, trigger_ctx_json.as_ref())

0 commit comments

Comments
 (0)