hermes-control-interface icon indicating copy to clipboard operation
hermes-control-interface copied to clipboard

[BUG] CSRF Protection on State-Changing Endpoints

Open stamandster opened this issue 7 months ago • 1 comments

Vulnerability Description State-changing endpoints (POST, PUT, DELETE) lacked CSRF protection, allowing attackers to trick authenticated users into performing unintended actions.

Affected Code Location
All mutating API endpoints in server.js

Risk Assessment
- Severity: High
- Impact: Cross-site request forgery attacks could modify data, delete sessions, install skills, or change settings

Fix Applied (v3.3.0)
Added CSRF token validation middleware (requireCsrf) to all state-changing endpoints:
javascript
// CSRF middleware
function requireCsrf(req, res, next) {
  const token = req.headers['x-csrf-token'] || req.body?._csrf;
  if (!token || token !== req.session?.csrfToken) {
    return res.status(403).json({ error: 'CSRF token invalid or missing' });
  }
  next();
}

stamandster avatar Apr 23 '26 14:04 stamandster

✅ Already fixed in v3.4.0

This issue was resolved in v3.4.0 but the issue was never closed. Confirming closure in v3.4.0 with the v3.5.0 release.

Release: https://github.com/xaspx/hermes-control-interface/releases/tag/v3.5.0

xaspx avatar Apr 27 '26 11:04 xaspx