summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-05-06 21:23:32 +0200
committerRory& <root@rory.gay>2026-05-06 21:23:32 +0200
commite7b96f2bea821d9b96dffcb8bbf196c64e67c1be (patch)
tree152f80988162fc878d6fc58a9ef4d2172be7bbab
parentSecurity: validate token for webhook update (diff)
downloadserver-ts-e7b96f2bea821d9b96dffcb8bbf196c64e67c1be.tar.xz
Security: Dont allow other users to manage application commands
-rw-r--r--src/api/routes/applications/#application_id/commands/#command_id/index.ts9
-rw-r--r--src/api/routes/applications/#application_id/commands/index.ts4
2 files changed, 13 insertions, 0 deletions
diff --git a/src/api/routes/applications/#application_id/commands/#command_id/index.ts b/src/api/routes/applications/#application_id/commands/#command_id/index.ts

index e0618613..e32399a6 100644 --- a/src/api/routes/applications/#application_id/commands/#command_id/index.ts +++ b/src/api/routes/applications/#application_id/commands/#command_id/index.ts
@@ -61,6 +61,10 @@ router.patch( return; } + if (req.user_id != req.params.application_id) { + res.status(401).send({ code: 401, message: "You are not this application" }); + } + const body = req.body as ApplicationCommandCreateSchema; if (!body.type) { @@ -115,6 +119,11 @@ router.delete("/", route({}), async (req: Request, res: Response) => { return; } + if (req.user_id != req.params.application_id) { + res.status(401).send({ code: 401, message: "You are not this application" }); + } + + await ApplicationCommand.delete({ application_id: req.params.application_id as string, id: req.params.command_id as string }); res.sendStatus(204); }); diff --git a/src/api/routes/applications/#application_id/commands/index.ts b/src/api/routes/applications/#application_id/commands/index.ts
index a3aaec2f..1aa70890 100644 --- a/src/api/routes/applications/#application_id/commands/index.ts +++ b/src/api/routes/applications/#application_id/commands/index.ts
@@ -49,6 +49,10 @@ router.post( return; } + if (req.user_id != req.params.application_id) { + res.status(401).send({ code: 401, message: "You are not this application" }); + } + const body = req.body as ApplicationCommandCreateSchema; if (!body.type) {