Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

fix(tags, webhooks): prevent unauthorized listing (#893)

Corentin Thomasset0c62716e5d67
diff --git a/.changeset/wise-animals-repair.md b/.changeset/wise-animals-repair.md
new file mode 100644
index 00000000..ff34ff0b
--- /dev/null
+++ b/.changeset/wise-animals-repair.md
@@ -0,0 +1,5 @@
+---
+"@papra/app": patch
+---
+
+Security fix: prevented unauthorized listing to organization tags and webhooks. An authenticated user could list the tags and webhooks of an organization they are not a member of by sending requests to the corresponding endpoints by knowing the organization ID.
\ No newline at end of file
diff --git a/apps/papra-server/src/modules/tags/tags.routes.ts b/apps/papra-server/src/modules/tags/tags.routes.ts
index 917006b2..0afc0d77 100644
--- a/apps/papra-server/src/modules/tags/tags.routes.ts
+++ b/apps/papra-server/src/modules/tags/tags.routes.ts
@@ -71,9 +71,14 @@ function setupGetOrganizationTagsRoute({ app, db }: RouteDefinitionContext) {
})),
async (context) => {
+ const { userId } = getUser({ context });
+
const { organizationId } = context.req.valid('param');
const tagsRepository = createTagsRepository({ db });
+ const organizationsRepository = createOrganizationsRepository({ db });
+
+ await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
const { tags } = await tagsRepository.getOrganizationTags({ organizationId });
diff --git a/apps/papra-server/src/modules/webhooks/webhook.routes.ts b/apps/papra-server/src/modules/webhooks/webhook.routes.ts
index 7c2ea6c1..f56bfdc8 100644
--- a/apps/papra-server/src/modules/webhooks/webhook.routes.ts
+++ b/apps/papra-server/src/modules/webhooks/webhook.routes.ts
@@ -70,8 +70,13 @@ function setupGetWebhooksRoute({ app, db }: RouteDefinitionContext) {
organizationId: organizationIdSchema,
})),
async (context) => {
+ const { userId } = getUser({ context });
const { organizationId } = context.req.valid('param');
+
const webhookRepository = createWebhookRepository({ db });
+ const organizationsRepository = createOrganizationsRepository({ db });
+
+ await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
const { webhooks } = await webhookRepository.getOrganizationWebhooks({ organizationId });