Repository navigation
fix(cli): pass config dict via process environment instead of command line (#3383) - #3472
Conversation
… 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]>
Signed-off-by: Manohar Paturi <[email protected]>
Head branch was pushed to by a user without write access
yaoyu-33
left a comment
There was a problem hiding this comment.
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.
|
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. |
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]>
2cc7ab1 to
36529b5
Compare
|
/ok to test 36529b5 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
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.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36916851619 |
Description
Fixes #3383.
Previously,
RunHelperinnemo_gym/cli/env.pyembeddedNEMO_GYM_CONFIG_DICTandNEMO_GYM_CONFIG_PATHas literalVAR=valueshell variable assignments directly inside the launch command string passed torun_command. Because the merged config dictionary contains every key fromenv.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
run_commandinnemo_gym/cli/setup_command.pyto accept an optionalextra_env: Mapping[str, str] | Noneparameter and merge it intocustom_envbefore passing toPopen(..., env=custom_env).RunHelper.runinnemo_gym/cli/env.pyto passNEMO_GYM_CONFIG_DICTandNEMO_GYM_CONFIG_PATHviaextra_envtorun_command, removing them from the literal shell command string.tests/unit_tests/test_cli_setup_command.pyverifying thatextra_envis correctly propagated to the spawned process environment block.tests/unit_tests/test_cli.pyverifying thatRunHelperpasses secrets via the process environment block and never exposes them on the shell command line.Verification
tests/unit_tests/test_cli_setup_command.pyandtests/unit_tests/test_cli.pywith pytest: 130 passed.ruff checkon modified files: all checks passed.