Skip to content

fix(agent,agent-installer): avoid leaking tunnel enrollment JWT via process cmdline#1798

Merged
Benoît Cortier (CBenoit) merged 11 commits into
masterfrom
copilot/stop-jwt-leak-and-remove-argv-risk
May 27, 2026
Merged

fix(agent,agent-installer): avoid leaking tunnel enrollment JWT via process cmdline#1798
Benoît Cortier (CBenoit) merged 11 commits into
masterfrom
copilot/stop-jwt-leak-and-remove-argv-risk

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

  • Rust: accept --enrollment-string - sentinel to read JWT from stdin (first line only)
  • C#: pass JWT via stdin instead of argv in EnrollAgentTunnel
  • C#: add EscapeArg helper for safe Windows argv quoting of --name
  • WiX: add AGENT_TUNNEL_ENROLLMENT_STRING to MsiHiddenProperties
  • E2E tests in testsuite cli module with real Gateway enrollment
  • Hardcode test provisioner key and JTI UUID
  • Simplify real-Gateway test: use disable_token_validation + sample_jwt, remove picky/time deps and provisioner_public_key_base64
  • Inline provisioner key value, clean up Cargo.toml
  • cargo fmt, clippy, and all tests pass

…nd MSI logs

- Rust: accept `--enrollment-string -` sentinel to read JWT from stdin
- Rust: factor parsing into `parse_up_command_args_with_reader` for testability
- Rust: add unit tests for stdin path and empty stdin error
- C#: pass JWT via stdin instead of argv in EnrollAgentTunnel
- C#: add EscapeArg helper for safe Windows argv quoting of --name
- WiX: add AGENT_TUNNEL_ENROLLMENT_STRING to MsiHiddenProperties

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Agent-Logs-Url: https://github.com/Devolutions/devolutions-gateway/sessions/80ac4af5-a42b-40aa-8cca-b3f8837f0a4b

Co-authored-by: CBenoit <3809077+CBenoit@users.noreply.github.com>
Copy link
Copy Markdown
Member

@CBenoit Benoît Cortier (CBenoit) left a comment

Choose a reason for hiding this comment

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

Copilot Extend the testsuite crate’s cli module, and perform proper E2E tests instead.

Remove unit tests for stdin path from devolutions-agent/src/main.rs
and add proper E2E tests in testsuite/tests/cli/agent/up.rs that
exercise the actual binary. Add agent_assert_cmd() to the testsuite
cli module.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Agent-Logs-Url: https://github.com/Devolutions/devolutions-gateway/sessions/89161343-5614-437e-8fb3-d06809bd7323

Co-authored-by: CBenoit <3809077+CBenoit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 26, 2026

Copilot Extend the testsuite crate’s cli module, and perform proper E2E tests instead.

Done in 0f73bc2. Removed the unit tests from main.rs and added proper E2E tests in testsuite/tests/cli/agent/up.rs that build and invoke the actual devolutions-agent binary via assert_cmd. Also added agent_assert_cmd() to testsuite/src/cli.rs. The four E2E tests cover: inline enrollment string, stdin enrollment string, empty stdin error, and JWT non-leakage in stderr.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gateway.example.com
    • Triggering command: /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent up --enrollment-string - /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/ebcd52e9457b6221-v3_ia5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/libaws_lc_0_40_0_crypto.a linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha256-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha512-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-vpaes-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont.o�� linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/b129d77c83f8bbf0-trampoline-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_mod_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_neg_p25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519_alt.o (dns block)
    • Triggering command: /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent up --enrollment-string ****** /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/ebcd52e9457b6221-v3_ia5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/libaws_lc_0_40_0_crypto.a linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha256-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha512-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-vpaes-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont.o�� linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/b129d77c83f8bbf0-trampoline-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_mod_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_neg_p25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519_alt.o (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Comment thread devolutions-agent/src/main.rs Outdated
Comment thread devolutions-agent/src/main.rs Outdated
Comment thread testsuite/tests/cli/agent/up.rs Outdated
Comment thread testsuite/tests/cli/agent/up.rs Outdated
…test with real Gateway

- Read only the first line from stdin for --enrollment-string -
- Remove low-value JWT-leak-in-stderr test
- Add E2E test that spins up a real Gateway with agent tunnel enabled,
  signs a proper JWT with a generated provisioner key, and enrolls
  the agent via stdin
- Extend DgwConfig with provisioner_public_key_base64 and agent_tunnel
  fields for test configuration

Agent-Logs-Url: https://github.com/Devolutions/devolutions-gateway/sessions/4dace32b-140a-4a30-a73b-671a0bc27cf4

Co-authored-by: CBenoit <3809077+CBenoit@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 26, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gateway.example.com
    • Triggering command: /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent up --enrollment-string ****** /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/ebcd52e9457b6221-v3_ia5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/libaws_lc_0_40_0_crypto.a linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha256-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha512-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-vpaes-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont.o�� linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/b129d77c83f8bbf0-trampoline-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_mod_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_neg_p25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519_alt.o (dns block)
    • Triggering command: /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent up --enrollment-string - /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/ebcd52e9457b6221-v3_ia5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/libaws_lc_0_40_0_crypto.a linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha256-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-sha512-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-vpaes-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont.o�� linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/81d9a39ddc6b1c4e-x86_64-mont5.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/b129d77c83f8bbf0-trampoline-x86_64.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_madd_n25519_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_mod_n25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-bignum_neg_p25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519base_alt.o linux-gnu/debug/build/aws-lc-sys-14a06eddb9e6ae5a/out/020bc241f4dae036-curve25519_x25519_alt.o (dns block)
    • Triggering command: /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent /home/REDACTED/work/devolutions-gateway/devolutions-gateway/target/x86_64-REDACTED-linux-gnu/debug/devolutions-agent up --enrollment-string - -C debuginfo=2 --cfg feature=&#34;alloc&#34; --cfg feature=&#34;arithmetic&#34; --cfg feature=&#34;default&#34; k.0b�� u.0bqkji5.rcgu.o--log-target n.0bqkji5.rcgu.ojournal-or-kmsg d.0bqkji5.rcgu.o g.0bqkji5.rcgu.o/home/REDACTED/.rustup/toolchains/1.90.0-x86_64-REDACTED-linux-gnu/bin/rustc 2.0bqkji5.rcgu.o--crate-name 7b6221-v3_bcons.primefield 7b6221-v3_bitst.--edition=2024 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Comment thread testsuite/tests/cli/agent/up.rs Outdated
Comment thread testsuite/tests/cli/agent/up.rs Outdated
Comment thread testsuite/tests/cli/agent/up.rs
@CBenoit Benoît Cortier (CBenoit) changed the title fix(agent): avoid leaking tunnel enrollment JWT via process cmdline and MSI logs fix(agent,agent-installer): avoid leaking tunnel enrollment JWT via process cmdline and MSI logs May 26, 2026
Comment thread testsuite/tests/cli/agent/up.rs
…on, remove picky/time deps

Agent-Logs-Url: https://github.com/Devolutions/devolutions-gateway/sessions/dc1b1526-3e01-4852-b247-6e2a86932742

Co-authored-by: CBenoit <3809077+CBenoit@users.noreply.github.com>
Comment thread testsuite/src/dgw_config.rs Outdated
Comment thread testsuite/Cargo.toml Outdated
@CBenoit Benoît Cortier (CBenoit) marked this pull request as ready for review May 26, 2026 14:27
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.

LGTM

@CBenoit Benoît Cortier (CBenoit) enabled auto-merge (squash) May 26, 2026 14:30
Comment thread package/AgentWindowsManaged/Program.cs Outdated
// Prevent the enrollment JWT from being logged in verbose MSI logs (/L*v).
// `Hidden = true` only suppresses the property table dump; MsiHiddenProperties
// controls masking of CustomActionData expansion in verbose logs.
projectProperties.Add(new Property("MsiHiddenProperties", AgentProperties.AgentTunnelEnrollmentString));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like a hallucination. The property attribute "hidden" in WiX (which has a managed equivalent in WixSharp) automatically does this for us, we shouldn't specify it directly

Copy link
Copy Markdown
Member

@CBenoit Benoît Cortier (CBenoit) May 27, 2026

Choose a reason for hiding this comment

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

Oh… I should have double checked this more careful. I reverted this change

Comment thread package/AgentWindowsManaged/Program.cs Outdated
@CBenoit Benoît Cortier (CBenoit) changed the title fix(agent,agent-installer): avoid leaking tunnel enrollment JWT via process cmdline and MSI logs fix(agent,agent-installer): avoid leaking tunnel enrollment JWT via process cmdline May 27, 2026
@CBenoit Benoît Cortier (CBenoit) enabled auto-merge (squash) May 27, 2026 14:01
@CBenoit Benoît Cortier (CBenoit) merged commit 5abe183 into master May 27, 2026
42 checks passed
@CBenoit Benoît Cortier (CBenoit) deleted the copilot/stop-jwt-leak-and-remove-argv-risk branch May 27, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants