Skip to content

fix(ns-api): improve ns.ha API - #1864

Closed
gsanchietti wants to merge 2 commits into
NethServer:mainfrom
gsanchietti:ha_fix
Closed

fix(ns-api): improve ns.ha API#1864
gsanchietti wants to merge 2 commits into
NethServer:mainfrom
gsanchietti:ha_fix

Conversation

@gsanchietti

@gsanchietti gsanchietti commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes a command-injection issue in packages/ns-api/files/ns.ha where a JSON payload was passed unescaped to a remote shell.
  • Adds input validation for HA API parameters and quotes the payload safely before sending it to the peer.
  • Adds error handling to the CLI dispatcher so invalid input returns a proper JSON error instead of crashing.
  • Applies the same fix to packages/ns-api/files/post-commit/update-timezone.py.

Test plan

Tested live on two NethSecurity 8.8.0 devices configured as an HA pair.

  • Verified malicious input is now rejected with a validation error and no commands execute on the peer
  • Full HA lifecycle (init, status, VIP add/remove, enable/disable, reset) verified end to end with no regressions

The timezone post-commit hook passed the UCI timezone value through
"sh -c echo '<value>' > /tmp/TZ", so a value containing a single quote
broke out of the quoting and the rest was executed as a command. Write
the file directly with Python instead: no shell is involved, and the
resulting content is unchanged.

Assisted-by: Claude Code:claude-opus-5[1m]
Sanitize JSON payloads sent to the HA peer and validate all HA
API parameters before use. Also handle validation errors in the
CLI dispatcher instead of crashing.

Assisted-by: Claude Code:claude-opus-5[1m]
@gsanchietti gsanchietti changed the title fix(ns-api): fix command injection in ns.ha fix(ns-api): improve ns.ha API Aug 6, 2026
@gsanchietti gsanchietti closed this Aug 6, 2026
@gsanchietti
gsanchietti deleted the ha_fix branch August 6, 2026 07:34
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.

1 participant