From 6cfa860294fe6d290d00d8ba3d4ca1de188c0027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Talbot?= <108630700+fetchfern@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:56:33 -0500 Subject: [PATCH] fix(labrinth): DBCharge user ownership check Reported-by: Haam --- apps/labrinth/src/routes/internal/billing.rs | 1 + apps/labrinth/src/routes/internal/billing/payments.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/apps/labrinth/src/routes/internal/billing.rs b/apps/labrinth/src/routes/internal/billing.rs index d3cb8004291..d013969873c 100644 --- a/apps/labrinth/src/routes/internal/billing.rs +++ b/apps/labrinth/src/routes/internal/billing.rs @@ -1789,6 +1789,7 @@ pub async fn initiate_payment( }, attached_charge: AttachedCharge::from_charge_request_type( &**pool, + &user, payment_request.charge, ) .await diff --git a/apps/labrinth/src/routes/internal/billing/payments.rs b/apps/labrinth/src/routes/internal/billing/payments.rs index 00a2c179522..31da2c6da66 100644 --- a/apps/labrinth/src/routes/internal/billing/payments.rs +++ b/apps/labrinth/src/routes/internal/billing/payments.rs @@ -139,6 +139,7 @@ impl AttachedCharge { pub async fn from_charge_request_type( exec: impl crate::database::Executor<'_, Database = sqlx::Postgres>, + user: &User, charge_request_type: ChargeRequestType, ) -> Result { Ok(match charge_request_type { @@ -146,6 +147,7 @@ impl AttachedCharge { charge: DBCharge::get(id.into(), exec) .await .wrap_internal_err("fetching charge from database")? + .filter(|charge| charge.user_id == user.id.into()) .wrap_request_err_with(|| { "could not find charge".to_string() })?,