Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/middleware/auditLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function createAuditLogger(actionType: string) {
adminId: req.user.userId,
adminUsername: req.user.username || 'Unknown',
actionType,
targetUserId: req.body?.userId || null,
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetUserId is pulled directly from req.body, which is client-controlled and can be spoofed, leading to misleading audit trails. Derive the target user ID from a trusted source (e.g., route params, server-side resolved entity, or a value placed on res.locals by prior middleware) and validate its type before logging.

Suggested change
targetUserId: req.body?.userId || null,
targetUserId: (typeof res.locals.targetUserId === 'string' || typeof res.locals.targetUserId === 'number') ? res.locals.targetUserId : null,

Copilot uses AI. Check for mistakes.
Comment thread
1ceit marked this conversation as resolved.
Outdated
ipAddress: JSON.stringify(encryptedIP),
userAgent: req.get('User-Agent'),
details: {
Expand Down
Loading