Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.

Commit 5fbf80d

Browse files
committed
fix: use parameterized LIMIT/OFFSET in activity query to prevent SQL injection
1 parent 0537029 commit 5fbf80d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

services/activity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export async function logActivity(userId, action, details = '', serverId = null)
1313

1414
export async function getRecentActivity(userId, limit = 20, offset = 0) {
1515
const rows = await query(
16-
`SELECT *, (SELECT COUNT(*) FROM activity_log WHERE user_id = ?) as _total FROM activity_log WHERE user_id = ? ORDER BY created_at DESC LIMIT ${parseInt(offset, 10)}, ${parseInt(limit, 10)}`,
17-
[userId, userId]
16+
'SELECT *, (SELECT COUNT(*) FROM activity_log WHERE user_id = ?) as _total FROM activity_log WHERE user_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?',
17+
[userId, userId, parseInt(limit, 10), parseInt(offset, 10)]
1818
);
1919
const total = rows.length > 0 ? Number(rows[0]._total) : 0;
2020
rows.forEach(r => delete r._total);

0 commit comments

Comments
 (0)