Skip to content

Build your personal knowledge base with Trilium Notes

fix(server): minor SQL-injection in special notes

Elian Doran4199ec63eb9a
diff --git a/apps/server/src/routes/api/special_notes.ts b/apps/server/src/routes/api/special_notes.ts
index a15db9df5a..69f9ec3dac 100644
--- a/apps/server/src/routes/api/special_notes.ts
+++ b/apps/server/src/routes/api/special_notes.ts
@@ -49,10 +49,10 @@ function getDayNotesForMonth(req: Request) {
AND attr.isDeleted = 0
AND attr.type = 'label'
AND attr.name = 'dateNote'
- AND attr.value LIKE '${month}%'`;
+ AND attr.value LIKE ? || '%'`;
if (calendarRoot) {
- const rows = sql.getRows<{ date: string; noteId: string }>(query);
+ const rows = sql.getRows<{ date: string; noteId: string }>(query, [month]);
const result: Record<string, string> = {};
for (const { date, noteId } of rows) {
const note = becca.getNote(noteId);
@@ -63,7 +63,7 @@ function getDayNotesForMonth(req: Request) {
return result;
}
- return sql.getMap(query);
+ return sql.getMap(query, [month]);
}
async function saveSqlConsole(req: Request) {