Skip to content

hardening: validate the device hostname and escape it on output - #214

Merged
TheWitness merged 2 commits into
developfrom
fix/validate-device-hostname
Nov 20, 2026
Merged

TheWitness merged 2 commits into
developfrom
fix/validate-device-hostname

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member
  • Save validation: new plugin_routerconfigs_valid_hostname() runs on save. It accepts letters, digits, . - _ : and inner spaces, since imported Cacti devices seed the name from the description. The name must start with a letter or digit and must not contain ...
  • Backup paths: before the backup path is built, the hostname goes through the new plugin_routerconfigs_backup_filename(). It rejects path separators, NUL, .. and anything that is not a single file name, so rows stored before this change fail their backup with an error instead of being used.
  • Escaping: the hostname is escaped in the edit header and the delete confirmation. The backup report email escapes the hostname, error text and file name.

The device directory field also feeds file paths. It is not changed here.

Tests: tests/Security/HostnameValidationTest.php. It includes a check that a traversal hostname leaves a file outside the backup directory untouched, and the traversal and email tests fail on develop. 364 passed.

Fixes #213

xmacan
xmacan previously approved these changes Nov 19, 2026
Reject hostnames with path separators, traversal sequences or unexpected characters on save, refuse to build backup file paths from a stored hostname that is not a single plain file name, and escape the hostname in the edit header, delete confirmation list and report email.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit e0f2317 into develop Nov 20, 2026
7 checks passed
@TheWitness
TheWitness deleted the fix/validate-device-hostname branch November 20, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate the device hostname before using it as a backup file name

3 participants