Skip to content

bug(supervisor): quote nft log prefixes in bypass rules #2470

Description

@johntmyers

Agent Diagnostic

  • Skills loaded: launch-openshell-gator, create-github-issue.
  • OpenShell version tested: 0.0.92-dev.3+g850bd42e on the local docker-dev gateway.
  • Latest release checked: v0.0.91 published 2026-07-24.
  • Known fixes reviewed: reviewed the current bypass-rule generator and its unit tests; related open issue feat(supervisor): NFLOG-based bypass detection to drop the CAP_SYSLOG requirement #2382 tracks an NFLOG-based redesign, but does not describe this nft syntax error.
  • Possible duplicates reviewed: searched open and closed issues for nft log prefix bypass and nftables bypass detection; no duplicate found.
  • Findings: gator sandbox startup consistently logs failures for the optional TCP and UDP nft log prefix rules. The generated command uses an unquoted value containing colons, which nft parses as invalid syntax. The required ACCEPT/REJECT bypass rules continue to install.
  • Remaining reason for filing: this deterministically disables bypass-attempt logging and makes the success event misleading, even on hosts where nft logging otherwise works.

Description

Actual behavior: Sandbox startup emits warnings such as:

non-required nft command failed in namespace (continuing)
command=add rule inet openshell_bypass output tcp flags syn limit rate 5/second burst 10 packets log prefix openshell:bypass:sandbox-cc817378: flags skuid
error=Error: syntax error, unexpected colon, expecting end of file or newline or semicolon

The same failure occurs for the UDP log rule. install_bypass_rules() subsequently emits Bypass detection rules installed, although the LOG rules did not install.

Expected behavior: The log prefix is passed as an nft string literal, for example:

log prefix "openshell:bypass:sandbox-cc817378:" flags skuid

Both TCP and UDP bypass LOG rules should install when nft logging is available. If an optional rule fails, the configuration outcome should accurately indicate partial observability degradation.

Reproduction Steps

  1. Start a Docker-backed sandbox that invokes NetworkNamespace::install_bypass_rules() with a namespace name such as sandbox-cc817378.
  2. Read sandbox supervisor logs.
  3. Observe syntax failures for the generated log prefix openshell:bypass:<namespace>: TCP and UDP rules.

Environment

Suggested Fix and Regression Coverage

  • In crates/openshell-supervisor-process/src/netns/nft_ruleset.rs, render the log prefix value as an nft-quoted string, including correct escaping for any permitted characters.
  • Update the existing expected-command tests, which currently assert the unquoted invalid form.
  • Add a regression test that validates the generated log rules against nft parsing (or an equivalent parser/integration fixture), so command-shape tests alone cannot accept invalid nft syntax.
  • Consider emitting a partial/degraded configuration result when non-required logging rules fail, instead of reporting all bypass detection rules as installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions