Skip to content

fix(cli): pass config dict via process environment instead of command line (#3383) - #3472

Merged
yuhezhang-ai merged 3 commits into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/pass-config-env-block-3383
Oct 1, 2026
Merged

yuhezhang-ai merged 3 commits into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/pass-config-env-block-3383

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Description

Fixes #3383.

Previously, RunHelper in nemo_gym/cli/env.py embedded NEMO_GYM_CONFIG_DICT and NEMO_GYM_CONFIG_PATH as literal VAR=value shell variable assignments directly inside the launch command string passed to run_command. Because the merged config dictionary contains every key from env.yaml (including API keys and sensitive credentials), this resulted in sensitive secrets being exposed in plaintext on the process command line (ps aux, ps -ef, and /proc/<pid>/cmdline) across the entire server runtime (CWE-214).

Changes

  1. Updated run_command in nemo_gym/cli/setup_command.py to accept an optional extra_env: Mapping[str, str] | None parameter and merge it into custom_env before passing to Popen(..., env=custom_env).
  2. Updated RunHelper.run in nemo_gym/cli/env.py to pass NEMO_GYM_CONFIG_DICT and NEMO_GYM_CONFIG_PATH via extra_env to run_command, removing them from the literal shell command string.
  3. Added unit test in tests/unit_tests/test_cli_setup_command.py verifying that extra_env is correctly propagated to the spawned process environment block.
  4. Added unit test in tests/unit_tests/test_cli.py verifying that RunHelper passes secrets via the process environment block and never exposes them on the shell command line.

Verification

  • Ran tests/unit_tests/test_cli_setup_command.py and tests/unit_tests/test_cli.py with pytest: 130 passed.
  • Ran ruff check on modified files: all checks passed.
  • DCO signed-off commit.

… line (NVIDIA-NeMo#3383)

Pass NEMO_GYM_CONFIG_DICT and NEMO_GYM_CONFIG_PATH via process environment block
rather than embedding them directly in the child process launch command string.
This prevents secrets in env.yaml from being visible in plaintext via ps aux
or /proc/<pid>/cmdline (CWE-214).

Closes NVIDIA-NeMo#3383

Signed-off-by: Manohar Paturi <[email protected]>
Copilot AI lite review requested due to automatic review settings September 17, 2026 09:25
@copy-pr-bot

copy-pr-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Sep 17, 2026
@yaoyu-33 yaoyu-33 added area:cli Command-line interfaces and user-facing command behavior bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer labels Sep 17, 2026
@yaoyu-33
yaoyu-33 enabled auto-merge September 17, 2026 16:38
auto-merge was automatically disabled September 17, 2026 17:17

Head branch was pushed to by a user without write access

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Sep 19, 2026
@yaoyu-33 yaoyu-33 removed the needs-review PR is ready for code review and waiting on a reviewer label Sep 19, 2026
yaoyu-33
yaoyu-33 previously approved these changes Sep 19, 2026

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed a1ce5da; the Ruff formatting issue is already fixed in that commit. Validation passed: 130 CLI tests, pre-commit run --all-files, and a real subprocess smoke covering raw YAML/Unicode/quotes, inherited environment, and config values absent from command arguments. Model rollouts are N/A for this launcher transport change. Full-scope repository CI is still awaiting trust-gate authorization.

@yaoyu-33 yaoyu-33 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed waiting-on-maintainers Waiting on maintainers to respond labels Sep 19, 2026
@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

thank you for the really thorough validation pass, the subprocess smoke with unicode and quotes is exactly the kind of check i could not run confidently from my side. glad the transport change holds up. the workflows still need a maintainer approval to run, so whenever someone can green-light those this should be ready to go.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Sep 21, 2026
@yaoyu-33 yaoyu-33 removed the ready-to-merge PR is approved, current, and waiting for final CI or merge label Sep 21, 2026
@yaoyu-33 yaoyu-33 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed waiting-on-maintainers Waiting on maintainers to respond labels Sep 30, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Sep 30, 2026
@yaoyu-33 yaoyu-33 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed ready-to-merge PR is approved, current, and waiting for final CI or merge waiting-on-maintainers Waiting on maintainers to respond labels Sep 30, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Sep 30, 2026
@yuhezhang-ai
yuhezhang-ai requested a review from a team as a code owner October 1, 2026 19:31
Preserve the explicit venv interpreter and cache-lock timeout from main while passing server configuration through the process environment. Adapt launcher tests to the current helper signature.

Signed-off-by: Yuhe Zhang <[email protected]>
@yuhezhang-ai
yuhezhang-ai force-pushed the fix/pass-config-env-block-3383 branch from 2cc7ab1 to 36529b5 Compare October 1, 2026 19:33
@yuhezhang-ai

Copy link
Copy Markdown
Contributor

/ok to test 36529b5

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 36529b5; no blocking findings.

Resolved the minor conflicts with current main (2c10237), preserving the explicit, shell-quoted server venv interpreter from #3681, its UV_LOCK_TIMEOUT behavior, and the serialized venv setup from #3435. Configuration YAML and the per-server config path now travel through Popen's environment; no config assignments remain in the launch command. The original PR commits are preserved in the signed-off merge commit.

Validation on the final code:

  • python -m pytest tests/unit_tests/test_cli.py tests/unit_tests/test_cli_setup_command.py tests/unit_tests/test_cli_server_launch.py tests/unit_tests/test_global_config.py -q -o addopts='' --durations=5: 338 passed, 1 failed on macOS. The sole failure, test_memory_profiler_uses_spawned_server_metadata, also fails on an untouched snapshot of main because memory profiling requires Linux procfs.
  • pre-commit run --all-files: all applicable hooks passed with no modifications.
  • Real subprocess smoke with logging disabled and enabled: raw YAML, Unicode, quotes and newlines round-trip through get_global_config_dict; inherited variables and UV_LOCK_TIMEOUT survive; the selected venv interpreter is used even with spaces in its path; the parent environment is unchanged; the child process tree's command arguments contain neither config assignment nor the synthetic secret.
  • Both new regression tests fail against main without this fix and pass with it.
  • DCO sign-offs verified.

CI classification is full scope because this changes core CLI code and tests. The full core/sandbox and eight-shard server suites are delegated to repository CI; they were not run locally. Model rollouts are N/A: this changes launcher configuration transport, not agent, verifier, prompt, or scoring behavior. Server config values and schemas remain unchanged.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36916851619

Merged via the queue into NVIDIA-NeMo:main with commit ab9d65a Oct 1, 2026
43 checks passed
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label Oct 1, 2026

This branch was previously deployed

1 inactive deployment
public — 36529b5e Deployed Oct 1, 2026 by copy-pr-bot[bot] via release / finalize / notify #4133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli Command-line interfaces and user-facing command behavior bug Something isn't working community-request Issue reported or requested by someone from the community complexity:low Localized change in one scope with a small, straightforward review surface ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secrets in env.yaml are exposed via ps aux / process command line

5 participants