HIGHMatter documents are fetched without a team scope
routes/matters.ts:61VULK-2117CWE-639
The handler looks the matter up by the identifier in the path and returns its documents. Nothing ties that lookup to the caller’s team, and the authentication middleware only proves somebody is signed in. Any signed-in user can read another team’s matter by changing the number in the URL. The other four handlers on this resource scope the query; this one does not. The check belongs in the query rather than in the response.
Suggested change
| Line before | Line after | Change | Source |
|---|---|---|---|
| @@ -61,7 +61,11 @@ router.get('/matters/:id/documents') | |||
| 61 | 61 | router.get('/matters/:id/documents', requireAuth, async (req, res) => { | |
| 62 | Removed line. const matter = await db.matter.findUnique({ | ||
| 63 | Removed line. where: {id: req.params.id}, | ||
| 62 | Added line. const matter = await db.matter.findFirst({ | ||
| 63 | Added line. where: {id: req.params.id, teamId: req.user.teamId}, | ||
| 64 | 64 | }); | |
| 65 | 65 | ||
| 66 | Added line. if (!matter) { | ||
| 67 | Added line. return res.status(404).send('not found'); | ||
| 68 | Added line. } | ||
| 69 | Added line. | ||
| 66 | 70 | return res.json(await listDocuments(matter.id)); | |
| 67 | 71 | }); | |
vulkro scan · exit 1 · 1 high, 0 criticalRan on your own runner. The code never left it.