Skip to content

[NemoClaw] Predictable temp filenames in onboard probe functions allow symlink attacks #1093

@latenighthackathon

Description

@latenighthackathon

Description

Six functions in bin/lib/onboard.js create temporary files with predictable names using Date.now() and Math.random().toString(36):

  • probeOpenAiLikeEndpoint (line 666)
  • probeAnthropicEndpoint (line 710)
  • fetchNvidiaEndpointModels (line 856)
  • fetchOpenAiLikeModels (line 910)
  • fetchAnthropicModels (line 946)
  • writeSandboxConfigSyncFile (line 527)

Math.random() is not cryptographically secure — its output is predictable from a known seed. Combined with Date.now() (millisecond precision), a local attacker can predict the filename and win a race to:

  1. Create a symlink at the predicted path before the probe runs
  2. Redirect curl output (which may contain API responses with model data) to an attacker-controlled location
  3. For writeSandboxConfigSyncFile, inject a malicious script that gets piped into openshell sandbox connect

The same file already uses fs.mkdtempSync() securely in two other places (lines 1764 and 2680), making this an inconsistency rather than a missing capability.

Reproduction Steps

  1. Read bin/lib/onboard.js line 666
  2. Note the filename pattern: nemoclaw-probe-${Date.now()}-${Math.random()...}.json
  3. Both Date.now() and Math.random() are predictable — Date.now() is millisecond-resolution wall clock, Math.random() uses xorshift128+ with a recoverable seed
  4. An attacker on the same system can pre-create a symlink at the predicted path in /tmp

Expected Behavior

Temp files should use fs.mkdtempSync() which creates a directory with a cryptographically random suffix (via the OS mkdtemp syscall), preventing filename prediction.

Actual Behavior

Temp files use predictable names constructed from Date.now() + Math.random().

Environment

  • Code review — applies to current main branch
  • File: bin/lib/onboard.js

Debug Output

N/A — static analysis finding.

Logs

N/A

Checklist

  • I confirmed this bug is reproducible
  • I searched existing issues and this is not a duplicate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Getting StartedUse this label to identify setup, installation, or onboarding issues.bugSomething isn't workingpriority: highImportant issue that should be resolved in the next releasesecuritySomething isn't secure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions