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

[BUG] Backup Download Path Traversal Check Uses String Matching

Open stamandster opened this issue 7 months ago • 1 comments

Location: server.js:3595-3601

javascript
if (!filePath || !filePath.endsWith('.zip') || filePath.includes('..')) {
  return res.status(400).json({ error: 'Invalid path' };
}


Issue: The .. check uses simple string inclusion (includes('..')), which can be bypassed with:
- URL-encoded .. (%2E%2E)
- Unicode lookalikes
- Other path normalization tricks

Recommendation: Use path.resolve() and verify the result stays within an allowed directory:
javascript
const resolved = path.resolve(filePath);
const tmpDir = '/tmp';
if (!resolved.startsWith(tmpDir + path.sep)) {
  return res.status(400).json({ error: 'Invalid path' });
}

stamandster avatar Apr 23 '26 14:04 stamandster

✅ RESOLVED in v3.5.0

Fix applied: Backup download endpoint now uses path.resolve() + startsWith('/tmp/') check instead of weak string matching (filePath.includes('..')).

The fix is part of the v3.5.0 release which includes all security hardening from v3.4.0 plus additional path traversal protections.

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

xaspx avatar Apr 27 '26 11:04 xaspx