Skip to content

Prevent host seed pathname races with a validated directory fd - #3

Closed
gl-agnx wants to merge 1 commit into
feat/mpunoxv-interactive-sshdfrom
fix/noxsshd-host-seed-dirfd
Closed

gl-agnx wants to merge 1 commit into
feat/mpunoxv-interactive-sshdfrom
fix/noxsshd-host-seed-dirfd

Conversation

@gl-agnx

@gl-agnx gl-agnx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Change

Fix the actual CodeQL TOCTOU report at server/main.c:87 in parent PR #2 (check115329964830). No suppression is added.

  • Open the host-seed parent directory once with O_DIRECTORY/O_NOFOLLOW, then validate the opened inode with fstat (owner and non-group/other-write mode).
  • Use that held descriptor for seed openat, exclusive creation, concurrent-creator retry, unlinkat failure cleanup and directory fsync. Renaming/replacing the pathname after validation cannot redirect these operations.
  • Strip redundant trailing parent separators before O_NOFOLLOW; reject invalid final names and avoid FIFO blocking before regular-file validation.
  • Preserve the 32-byte seed format and existing private ownership/mode checks. A completed seed survives directory-fsync failure while the invocation fails, preserving identity for retry.

Validation

24 isolated Linux synthetic fixtures passed. The harness extracts the actual production random_seed/host_seed functions and compiles only those with -std=c99 -Wall -Wextra -Werror -O2. It does not build or launch the daemon.

Coverage includes existing-key reuse, deterministic parent-path swaps during reuse/create/write-error cleanup, symlink parent (including repeated separators), seed symlink/FIFO/directory/length/mode/owner rejection, concurrent creator, short/EINTR I/O, entropy/read/write/file-fsync/close errors, and directory-fsync failure retaining the complete identity.

No real keys were accessed or exported. No full source/CMake/Yocto/Vivado build, board/network/UART/JTAG access, manual CI dispatch, merge, or recipe/source-pin change was performed. Automatic PR checks must confirm CodeQL disposition; focused fixtures are not full-server or board qualification.

Stack and deployment

Base feat/mpunoxv-interactive-sshd at a397eb9 (parent PR #2). Keep the existing BSP source pins and board binary until a separately built successor is tested. Existing persistent host seed is reused; no rekeying/migration is required.

@gl-agnx gl-agnx closed this Oct 13, 2026
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