Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: validate report route path parameters (#4880)

Adam Eivy4d64b47cb302
diff --git a/server/routes/cosReportRoutes.js b/server/routes/cosReportRoutes.js
index 14a07537c6..d3e8e7910d 100644
--- a/server/routes/cosReportRoutes.js
+++ b/server/routes/cosReportRoutes.js
@@ -13,6 +13,10 @@ import { validateRequest } from '../lib/validation.js';
const router = Router();
+const dateParamSchema = z.object({
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'date must be YYYY-MM-DD')
+});
+
// The date is both a date-bucket key and the report's filename, so it must be a
// bare YYYY-MM-DD day. A full ISO timestamp would match no bucket (and no
// agent's `completedAt` prefix), silently writing an all-zero report under a
@@ -47,7 +51,8 @@ router.get('/reports/today', asyncHandler(async (req, res) => {
// GET /api/cos/reports/:date - Get report by date
router.get('/reports/:date', asyncHandler(async (req, res) => {
- const report = await cos.getReport(req.params.date);
+ const { date } = validateRequest(dateParamSchema, req.params);
+ const report = await cos.getReport(date);
if (!report) {
throw new ServerError('Report not found', { status: 404, code: 'NOT_FOUND' });
}
@@ -75,7 +80,8 @@ router.get('/briefings/latest', asyncHandler(async (req, res) => {
// GET /api/cos/briefings/:date - Get briefing by date
router.get('/briefings/:date', asyncHandler(async (req, res) => {
- const briefing = await cos.getBriefing(req.params.date);
+ const { date } = validateRequest(dateParamSchema, req.params);
+ const briefing = await cos.getBriefing(date);
if (!briefing) {
throw new ServerError('Briefing not found', { status: 404, code: 'NOT_FOUND' });
}
diff --git a/server/routes/jira.js b/server/routes/jira.js
index eea87e1528..7940e9ac9f 100644
--- a/server/routes/jira.js
+++ b/server/routes/jira.js
@@ -35,6 +35,11 @@ const jiraTicketCreateSchema = z.object({
const jiraTicketUpdateSchema = jiraTicketCreateSchema.partial();
+const reportParamsSchema = z.object({
+ appId: z.string().regex(/^[A-Za-z0-9._-]+$/, 'appId contains invalid characters'),
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'date must be YYYY-MM-DD')
+});
+
const router = express.Router();
/**
@@ -353,7 +358,8 @@ router.get('/reports/:appId/latest', asyncHandler(async (req, res) => {
* Get a specific report by app and date
*/
router.get('/reports/:appId/:date', asyncHandler(async (req, res) => {
- const report = await jiraReports.getReport(req.params.appId, req.params.date);
+ const { appId, date } = validateRequest(reportParamsSchema, req.params);
+ const report = await jiraReports.getReport(appId, date);
if (!report) {
throw new ServerError('Report not found', { status: 404, code: 'NOT_FOUND' });
}