gabriel / muse public
task/fd-guard #1 / 1
AI Agent gabriel · 162 days ago · Apr 17, 2026 · Diff

security: reject reserved fds (0/1/2) for --passphrase-fd and --mnemonic-fd

Passing fd 0, 1, or 2 to either flag is always a bug and can be destructive: --passphrase-fd 1 → os.read(1,…) reads stdout, os.close(1) kills all output --passphrase-fd 2 → os.read(2,…) reads stderr, os.close(2) kills error output --mnemonic-fd 0 → wraps stdin with fdopen, corrupting the stdin pipe

Both _resolve_passphrase and _read_mnemonic_securely now reject fd < 3 with a clear error before touching the descriptor.

8 tests in test_fd_guard.py.

sha256:1ae4c1a788dd9cfc6f3932bd48c1d08772c02d13ec930f84b7b6bbfc04a71025 sha
+24 ~2 symbols
sha256:9066143dba49e6ee5a3aede0f4358ed5a35cff884f0d1ec8c89887dca3aeb544 snapshot
+24
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 26 symbols
~ tests/test_fd_guard.py .py 24 symbols added
+ TestMnemonicFdGuard class class TestMnemonicFdGuard L108–131
+ test_II1_mnemonic_fd_0_rejected method method test_II1_mnemonic_fd_0_rejected L109–115
+ test_II2_mnemonic_fd_1_rejected method method test_II2_mnemonic_fd_1_rejected L117–123
+ test_II3_mnemonic_fd_2_rejected method method test_II3_mnemonic_fd_2_rejected L125–131
+ TestPassphraseFdGuard class class TestPassphraseFdGuard L81–101
+ test_I1_passphrase_fd_0_rejected method method test_I1_passphrase_fd_0_rejected L82–87
+ test_I2_passphrase_fd_1_rejected method method test_I2_passphrase_fd_1_rejected L89–94
+ test_I3_passphrase_fd_2_rejected method method test_I3_passphrase_fd_2_rejected L96–101
+ TestValidFdStillWorks class class TestValidFdStillWorks L138–163
+ test_III1_passphrase_fd_valid_pipe_works method method test_III1_passphrase_fd_valid_pipe_works L139–148
+ test_III2_mnemonic_fd_valid_pipe_works method method test_III2_mnemonic_fd_valid_pipe_works L150–163
+ _HUB variable variable _HUB L45–45
+ _MNEMONIC variable variable _MNEMONIC L46–49
+ _pipe function function _pipe L70–74
+ fixed_mnemonic function function fixed_mnemonic L64–67
+ CliRunner import import CliRunner L39–39
+ annotations import import annotations L32–32
+ id_module import import id_module L41–41
+ kp_module import import kp_module L40–40
+ os import import os L34–34
+ pathlib import import pathlib L35–35
+ pytest import import pytest L37–37
+ isolated function function isolated L53–60
+ runner variable variable runner L43–43
← Older Oldest on task/fd-guard
All commits
Newer → Latest on task/fd-guard

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:1ae4c1a788dd9cfc6f3932bd48c1d08772c02d13ec930f84b7b6bbfc04a71025 --body "your comment"