Skip to content

fix(security): the devcontainer no longer starts the git daemon stub meant for argo cd, which served every clone under repos/ without authentication on port 9418 #1122

Closed

Description

@dan-petty

Problem

Checked: release/v0.2.25 at e9973c7 (every cited line is the same at 132ecc5), on 2026-10-03.

Owner direction (2026-10-03). "The git daemon is a stub that was meant to enable simple argocd integration." Its removal is its own item. Nothing in the repository reads from git:// (the only git:// text is a review-report test fixture, tests/test_review_report_summary.py:59 and :342), and Argo CD does not use it.

Argo CD does not use it. Every Application reads https://github.com/dan-petty/devops-cli.git (k8s/argocd/apps/root-app.yaml:12, infra-apps.yaml:12 and :36, llm-apps.yaml:12), as it has since 22bba04 (#38, v0.2.11). The daemon could not have served Argo CD's path anyway: it exports k8s/, which is not a repository.

What it does instead.

  • devops devcontainer post-start starts it by default: step 7 (src/devops_cli/commands/devcontainer.py:1180-1183) reads DEVOPS_GIT_DAEMON_AUTOSTART, which defaults to true and is set to "true" in both devcontainer configs.
  • It runs git daemon --reuseaddr --detach --export-all over k8s/ and repos/, or over the paths in DEVOPS_GIT_DAEMON_PATHS (:1221-1262). With no --listen, git daemon binds every address of the container on 9418.
  • --export-all serves every clone under the gitignored repos/, private ones included, with no authentication, to anything that can reach the container's network.
  • Both devcontainer configs forward 9418 to the workstation (.devcontainer/devcontainer.json:74-82; template src/devops_cli/templates/devcontainer.json.j2:81, :108-111 and :113-122). In the template's non-minikube branch, 9418 is the only forwarded port, so every devcontainer devops-cli generates for another project forwards it too.
  • Sharing clones between containers (feat(devcontainer): configure ollama extension for vllm 16gib service with gpt-oss:20b #722's "container repository synchronization") is what feat(repos): Add a gitea remote to every clone under repos/ #1090's Gitea remotes do, with authentication. Removing the daemon does not wait for them, because nothing uses it today.
  • The pre-1.0 policy allows no obsolete shims (CLAUDE.md).

Every reference. Found with git grep -n -i -E 'git[ _-]?daemon|9418|DEVOPS_GIT_DAEMON' -- ':!CHANGELOG.md' ':!changelog.d' ':!docs/agent/tasks' ':!uv.lock':

  • The code.
    • src/devops_cli/commands/devcontainer.py:1180-1183: step 7 of post-start.
    • devcontainer.py:1199-1262: _git_daemon_pid_file, _is_git_daemon_running and _start_git_daemon, with DEVOPS_GIT_DAEMON_PATHS read at :1231.
  • The devcontainer template.
    • src/devops_cli/templates/devcontainer.json.j2:45: DEVOPS_GIT_DAEMON_AUTOSTART.
    • Template :81 and :108-111: 9418 in the minikube branch.
    • Template :113-122: the non-minikube branch, which forwards only 9418.
  • This repository's devcontainer. .devcontainer/devcontainer.json:45 and :74-82.
  • The bootstrap-gitops docstring. src/devops_cli/commands/argo.py:342 ("Bootstrap local GitOps project orchestration via ArgoCD and the Git daemon."), generated into docs/commands/argo.md:201 and docs/CLI_REFERENCE.md:1857. The command applies the root Application (argo.py:378-386) and never touched the daemon.
  • Docs. docs/DEVCONTAINER_USAGE.md:86-94: an example forwardPorts and portsAttributes with only 9418.
  • Argo CD's policy. k8s/argocd/networkpolicy.yaml:67 (the comment) and :81 (egress to 9418), and tests/test_k8s_network_policies.py:112-114, which asserts 9418 is open. The file is not applied in the homelab (feat(k8s): argo cd keeps the homelab cluster at the current release branch, with automated sync, prune and self-heal that never delete data #755 leaves it unsynced), but it would reopen the port when it is.
  • Tests. tests/test_devcontainer.py:713-769 and :1244-1282 test the daemon. Lines :29, :158, :388, :434 and :916 switch it off.
  • Agent instructions. AGENTS.md:412 ("local git daemons"). This is the only copy of the line; no generator template carries it.
  • Not the daemon. tests/test_reference_extractor.py:562 and :581 use git-daemon.pid only as a file name that the domain extractor must not report.
  • History, which stays. CHANGELOG.md, changelog.d/961.md, and the task files for feat(devcontainer): configure ollama extension for vllm 16gib service with gpt-oss:20b #722 and fix(cli): argo ignores the namespace, and workspace, devcontainer, port-forward, tls, drift-report and label state handling #961.

Acceptance criteria

In the gate. Tests are offline and use structural tuple assertions. New tests add under 1 s, checked with uv run pytest tests/test_devcontainer.py tests/test_k8s_network_policies.py --durations=0.

  • Daemon gone.
    • Step 7 of post-start is deleted, along with _git_daemon_pid_file, _is_git_daemon_running and _start_git_daemon (devcontainer.py:1180-1183 and :1199-1262). The later steps are renumbered.
    • Nothing reads DEVOPS_GIT_DAEMON_AUTOSTART or DEVOPS_GIT_DAEMON_PATHS.
    • A post-start test with a recording run_subprocess stub asserts that no call starts with ["git", "daemon"], with neither variable set.
  • Daemon tests gone. tests/test_devcontainer.py:713-769 and :1244-1282 are deleted, along with the five DEVOPS_GIT_DAEMON_AUTOSTART setenv lines.
  • Devcontainer config.
    • The template no longer sets DEVOPS_GIT_DAEMON_AUTOSTART. The minikube branch drops 9418 from forwardPorts (and the comma after 11434) and from portsAttributes.
    • The non-minikube branch (:113-122) is removed, leaving {% if minikube %}…{% endif %}.
    • .devcontainer/devcontainer.json drops :45 and :74-82.
    • A test renders the template with minikube on and off. Both outputs parse as JSON, and neither contains the variable or port 9418.
  • Argo CD's policy.
    • k8s/argocd/networkpolicy.yaml:81 drops port 9418, and the comment at :67 drops "Git daemon 9418".
    • tests/test_k8s_network_policies.py asserts 443 and 22 as before, and that 9418 is absent.
  • Docs.
    • Docstring. The bootstrap-gitops docstring says what the command does: it applies the GitOps root Application. Regenerate docs/commands/argo.md and docs/CLI_REFERENCE.md with devops docs generate, and devops docs check passes.
    • DEVCONTAINER_USAGE.md. The example drops its forwardPorts and portsAttributes block.
    • AGENTS.md:412 drops "local git daemons". Edit the line in place, because it exists only there. Do not run devops ai agents in this PR: until docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 lands, it rewrites AGENTS.md.
  • Nothing left. The git grep above prints only tests/test_reference_extractor.py:562 and :581, and the new absence assertions (the template test and the Argo CD policy test, which name 9418 and DEVOPS_GIT_DAEMON_AUTOSTART to assert they are gone).
  • Changelog. changelog.d/<issue>.md under ### Removed: the daemon, both variables and the port forward. It says that clones under repos/ are no longer served without authentication. CHANGELOG.md is not edited, and devops pr check-readiness passes.
  • uv run devops ci passes within its 5-minute budget.

Checks a person runs (a rebuilt devcontainer):

  • Pending a person, Daemon gone: after rebuilding the devcontainer, ss -ltn | grep -c ':9418 ' prints 0, and pgrep -x git-daemon prints nothing.
  • Pending a person, No forward: VS Code's Ports view lists no 9418.

Key questions

  • Does anything still use the daemon? Decided (owner, 2026-10-03): no. "The git daemon is a stub that was meant to enable simple argocd integration." Nothing in the repository reads from git://, and Argo CD has read GitHub since v0.2.11.
  • Does the removal wait for Gitea? Decided (owner, 2026-10-03): it is its own item. Proposed: no dependency. feat(repos): Add a gitea remote to every clone under repos/ #1090 gives authenticated clone sharing through Gitea, but nothing relies on the daemon in the meantime.
  • Keep an opt-in variable for anyone who wants it? Proposed: no. An opt-in would keep the code, tests and port forward that this item removes, and the pre-1.0 policy allows no obsolete shims. Anyone who needs a git daemon can still run git daemon by hand.
  • Why also change Argo CD's policy file, which the homelab does not apply? Proposed: fix(k8s): deploy-stack applies the monitoring namespace perimeter #913's follow-up will apply it. The port should not come back with it, and the test should stop requiring it. Ports 22 and 443 stay: Argo CD may read repositories over SSH or HTTPS.
  • What about the stale /tmp/git-daemon.pid? Proposed: leave it.
  • Devcontainers generated before this change? Proposed: they keep their own devcontainer.json until they are regenerated. Without the post-start step, nothing starts the daemon after the next rebuild, and their 9418 forward points at nothing. The changelog tells their owners to drop the forward.

Strategic alignment

Activity

  1. added
    type/security
    scope/security
    priority/p2-medium
    on Oct 3, 2026
  2. added this to the v0.2.31 milestone on Oct 8, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.31 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: finding identity v2, URL credential masking, tests that leave no state, the Docker endpoint check and the Argo CD/OTel perimeters. Position 9 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    The '#913 follow-up' this item names is #1371 (v0.2.31), which applies k8s/argocd/networkpolicy.yaml; whichever lands second rebases on the file. Found by the 2026-10-08 backlog review.

  5. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1477, merged into release/v0.2.31 as fb3bad1.

    Resolves #1122

    13 file(s) changed.

    How it was verified

    Check runs at 734a08b:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1122-remove-git-daemon.md:

    • Daemon gone.
      • Step 7 of post-start is deleted, along with _git_daemon_pid_file, _is_git_daemon_running and _start_git_daemon (src/devops_cli/commands/devcontainer.py). Later post-start steps are renumbered.
      • Nothing reads DEVOPS_GIT_DAEMON_AUTOSTART or DEVOPS_GIT_DAEMON_PATHS.
      • A post-start test with a recording run_subprocess stub asserts that no call starts with ["git", "daemon"], with neither variable set (test_post_start_never_starts_git_daemon).
    • Daemon tests gone. Tests for the daemon in tests/test_devcontainer.py and the five DEVOPS_GIT_DAEMON_AUTOSTART setenv lines are deleted.
    • Devcontainer config.
      • The template no longer sets DEVOPS_GIT_DAEMON_AUTOSTART. The minikube branch drops 9418 from forwardPorts and portsAttributes.
      • The non-minikube branch is removed, leaving {% if minikube %}…{% endif %}.
      • .devcontainer/devcontainer.json drops DEVOPS_GIT_DAEMON_AUTOSTART, forwardPorts, and portsAttributes.
      • A test renders the template with minikube on and off. Both outputs parse as JSON, and neither contains the variable or port 9418 (test_devcontainer_template_contains_no_git_daemon).
    • Argo CD's policy.
      • k8s/argocd/networkpolicy.yaml drops port 9418, and the comment drops "Git daemon 9418".
      • tests/test_k8s_network_policies.py asserts 443 and 22, and asserts that 9418 is absent.
    • Docs.
      • Docstring. The bootstrap-gitops docstring states what the command does (applies the GitOps root Application). Regenerated docs/commands/argo.md and docs/CLI_REFERENCE.md with devops docs generate, and devops docs check passes.
      • DEVCONTAINER_USAGE.md. The example drops its forwardPorts and portsAttributes block.
      • AGENTS.md. Drops "local git daemons" in-place.
    • Nothing left. Grep confirms no unreferenced git daemon or 9418 occurrences remain across codebase.
    • Changelog. changelog.d/1122.md records the removal under ### Removed. CHANGELOG.md and docs/ROADMAP.md are not edited.
    • uv run devops ci passes.

    Pending a person:

    • Daemon gone: after rebuilding the devcontainer, ss -ltn | grep -c ':9418 ' prints 0, and pgrep -x git-daemon prints nothing.
    • No forward: VS Code's Ports view lists no 9418.
  6. added a commit that references this issue on Oct 9, 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

    priority/p2-mediumscope/securitytype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions