Skip to content

Yes, the security concern regarding subprocess environment leakage remains valid and is a critical issue. The fix involves ensuring that any subprocess.run or subprocess.Popen call that executes external commands (like ffmpeg or npm) does not inherit the full environment of the parent process, which may contain sensitive API keys. #698

@badMade

Description

@badMade

Yes, the security concern regarding subprocess environment leakage remains valid and is a critical issue. The fix involves ensuring that any subprocess.run or subprocess.Popen call that executes external commands (like ffmpeg or npm) does not inherit the full environment of the parent process, which may contain sensitive API keys.

To address this in tools/transcription_tools.py, you should use the _sanitize_subprocess_env helper function, which is designed to filter out sensitive variables.

Here is the code suggestion to apply this fix to the _prepare_local_audio function:

    ffmpeg = _find_ffmpeg_binary()
    if not ffmpeg:
        return (
            None,
            "Local STT fallback requires ffmpeg for non-WAV inputs, but ffmpeg was not found",
        )

    converted_path = os.path.join(work_dir, f"{audio_path.stem}.wav")
    command = [ffmpeg, "-y", "-i", file_path, converted_path]
    sanitized_env = _sanitize_subprocess_env(os.environ.copy())
    subprocess.run(command, check=True, capture_output=True, text=True, env=sanitized_env)
    return converted_path, None

Originally posted by @gemini-code-assist[bot] in #681 (comment)

security-critical critical

🛡️ Security Vulnerability: Subprocess Environment Leakage in _prepare_local_audio

The _prepare_local_audio function executes ffmpeg via subprocess.run without sanitizing the environment variables passed to the child process:

subprocess.run(command, check=True, capture_output=True, text=True)

This exposes sensitive API keys and credentials contained in the main Hermes process environment to the ffmpeg child process.

Please update the subprocess.run call inside _prepare_local_audio to pass a sanitized environment:

sanitized_env = _sanitize_subprocess_env(os.environ.copy())
subprocess.run(command, check=True, capture_output=True, text=True, env=sanitized_env)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions