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

[BUG] Command Injection Vulnerability

Open stamandster opened this issue 7 months ago • 1 comments

Using latest installation I've identified a critical command injection vulnerability in the /api/skills/install endpoint.

Vulnerability Details

Location: /mnt/c/Users/chris/hermes-control-interface/server.js lines 3397-3408

Issue: The skill parameter is passed directly to execHermes without any sanitization or validation:

javascript
app.post('/api/skills/install', requireRole('admin'), requireCsrf, async (req, res) => {
  try {
    const { skill, profile } = req.body || {};
    if (!skill) return res.status(400).json({ ok: false, error: 'skill name required' });
    const profArg = profile ? ['-p', sanitizeProfileName(profile)] : [];
    const output = await execHermes([...profArg, 'skills', 'install', skill, '--yes'], 30000);
    // ...
  }
});


Comparison with /api/skills/uninstall

Interestingly, the uninstall endpoint (lines 3411-3417) has proper input validation:

javascript
// Sanitize skill name — only allow safe characters to prevent command injection
if (!/^[\w.\-]+$/.test(skill)) return res.status(400).json({ ok: false, error: 'invalid skill name' });


This protection is missing from the install endpoint.

Risk

An authenticated admin could inject arbitrary commands via the skill parameter, potentially leading to:
- Remote code execution on the server
- Privilege escalation
- System compromise

Recommended Fix

Add input validation to the install endpoint, similar to uninstall:

javascript
app.post('/api/skills/install', requireRole('admin'), requireCsrf, async (req, res) => {
  try {
    const { skill, profile } = req.body || {};
    if (!skill) return res.status(400).json({ ok: false, error: 'skill name required' });

    // Sanitize skill name — only allow safe characters to prevent command injection
    if (!/^[\w.\-]+$/.test(skill)) {
      return res.status(400).json({ ok: false, error: 'invalid skill name' });
    }

    const profArg = profile ? ['-p', sanitizeProfileName(profile)] : [];
    const output = await execHermes([...profArg, 'skills', 'install', skill, '--yes'], 30000);
    // ...
  }
});


This ensures only alphanumeric characters, dots, and hyphens are allowed in the skill parameter.

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