Skip to content

fix(security): the osv, internetdb, radar and cloudflare api clients dial through the egress-checked factory at the public level - #2509

Merged
dan-petty merged 31 commits into
mainfrom
fix/2430-public-api-clients-egress-factory
Oct 28, 2026
Merged

dan-petty merged 31 commits into
mainfrom
fix/2430-public-api-clients-egress-factory

Conversation

@dan-petty

@dan-petty dan-petty commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

The clients of four fixed public APIs get their HTTP client from the egress-checked factory (devops_cli.http.client) at the public level: the OSV lookup (api.osv.dev), the Shodan InternetDB lookup (internetdb.shodan.io), the Cloudflare Radar lookup and the Cloudflare API client (api.cloudflare.com). Before, each client built a raw httpx2.Client. httpx2 resolved the API host at the socket and dialled each answer with no check. Thus a bad or rebinding DNS answer could send the request to a loopback, private or link-local address. For the Cloudflare clients, the request also sent the Cloudflare API token to that address.

  • Each client resolves its API host one time, at the connect, and dials only a public address. ai.allow_private_network does not change this level. Cloud metadata addresses are refused at every level. The factory checks each redirect hop in the same way. The timeouts do not change.
  • A refused lookup of OSV, InternetDB or Radar gives the same result as a failed connect.
  • A refused request of the Cloudflare API client raises SSRFBlockedError. The exit seam of new_typer() (fix(cli): every command reports a DevOpsCLIError through one exit seam #2502) reports this DevOpsCLIError for each command of the cloudflare, dns, tunnel and access groups. Thus each devops cloudflare command prints the message and exits with code 2, with no traceback.
  • The transport argument of CloudflareRadarClient is deleted. No caller gave it, and the factory takes no transport.
  • The four clients do not use a proxy from HTTP_PROXY, HTTPS_PROXY or ALL_PROXY, because no factory client does. On a workstation that gets to the internet only through a proxy, the lookups give the result of a failed connect, and the devops cloudflare commands fail.
  • README.md names the moved clients. The new capability public-api-egress holds the requirements.

This change is part 3 of the split of #1381. Part 5 (#2437) deletes _resolve_host_ips and _enforce_non_private_ssrf. The outcome ok of a failed InternetDB lookup is a separate defect, #2504.

Closes #2430

Change: openspec/changes/archive/2026-10-28-2430-public-api-clients-egress-factory/

…flare api clients to the egress factory

The change 2430-public-api-clients-egress-factory plans part 3 of the
split of #1381. The OSV, Shodan InternetDB, Cloudflare Radar and
Cloudflare API clients get their HTTP client from the egress-checked
factory at the public level.
…ublic api

test_each_caller_dials_at_its_level gets a row for the OSV, Shodan
InternetDB, Cloudflare Radar and Cloudflare API clients, with and without
ai.allow_private_network. The test resolves api.osv.dev,
internetdb.shodan.io and api.cloudflare.com. Each row expects the public
level and no host name at the socket. On the code before the move, each
raw client gives the host name to the socket, so all eight rows fail.
… egress-checked factory at the public level

OSVClient, ShodanInternetDBClient and CloudflareRadarClient get their
HTTP client from new_http_client at the public level, with the 1 s
connect timeout that they had. Each client resolves its API host one
time, at the connect, and dials only public addresses, with or without
ai.allow_private_network. A refused lookup gives a failed result, as a
failed connect does.

The transport argument of CloudflareRadarClient goes, with the raw
client that it built. No caller gave it, and the factory takes no
transport.
…cked factory at the public level

CloudflareClient._request gets its HTTP client from new_http_client at
the public level, with the 30 s read timeout that it had. The client
resolves api.cloudflare.com one time, at the connect, and dials only
public addresses, with or without ai.allow_private_network. Thus a bad
DNS answer cannot send the Cloudflare API token to a loopback, private
or link-local address. A refused address raises SSRFBlockedError at the
connect, and tenacity does not retry it.
…ss-checked factory builds

The SSRF protections of README.md name the OSV, Shodan InternetDB and
Cloudflare Radar lookups and the Cloudflare API client among the factory
clients. They also name the fixed public APIs among the clients that
dial only public addresses, whatever the configuration says.
… address

A command of each `devops cloudflare` group runs against
api.cloudflare.com, whose DNS answer is 10.0.0.1. The client refuses
the address at the connect. The test expects the command to print the
message of SSRFBlockedError and to exit with its exit code, 2, with no
traceback. Before the fix, each command let the error go up, and the
user got a traceback in place of a report.
… with no traceback

The Cloudflare API client dials only public addresses, and a refused
address raises SSRFBlockedError at the connect. Each command catches
only CloudflareError, so the refusal left the command as an uncaught
exception, and the user got a traceback. The four cloudflare command
groups now give exit_on=SSRFBlockedError to new_typer. Each command
prints the message of the error and exits with its exit code, 2, as
the other command groups do for their own error type.
…each client and the loss of the environment proxy

The design said that each lookup client gives a failed result for a
refused lookup and does not cache it, and that a devops cloudflare
command reports SSRFBlockedError with its error code. Neither was true.
The design now names the result of each client: OSV gives failed and
caches nothing, Radar gives failed and keeps the record in its
in-memory cache, and InternetDB gives the outcome ok and keeps the
record. The outcome ok is a defect from before this change, and #2504
fixes it. The cloudflare command groups now report the refusal, and
the spec delta has a requirement for it.

The proposal and the design also record that the four clients no
longer use HTTP_PROXY, HTTPS_PROXY or ALL_PROXY, because httpx2 reads
them only for a client without a transport.
@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 28, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results on the branch, after the rebase onto origin/main at 0137f231:

  • uv run devops ci test tests/test_http_egress.py tests/test_vulnerability_lookup.py tests/test_security_threat_intel.py tests/test_cloudflare_commands.py: 271 passed.
  • uv run devops ci test tests/test_builtin_tools.py tests/test_dependency_remediator.py tests/test_service_status.py (the other tests that import the changed modules): 89 passed.
  • uv run devops ci docs: all documentation files are up to date.
  • The rebase had conflicts in tests/test_http_egress.py and README.md with fix(k8s): the grafana, prometheus, argo cd and loki clients dial through the egress-checked factory, and their pre-flight address checks go #2497 (the Grafana, Prometheus, Argo CD and Loki clients). The resolution keeps the rows and the README names of both changes.

Fail-to-pass: uv run devops ci fail-to-pass --base origin/main --title "<the title of this pull request>" exits 0. On the base, 12 tests failed, and 199 other tests in tests/test_cloudflare_commands.py and tests/test_http_egress.py passed. All pass on the branch.

  • 8 rows of test_each_caller_dials_at_its_level: osv, shodan internetdb, cloudflare radar and cloudflare api, each with and without the flag. On the base, each raw client gave its host name to the socket.
  • 4 rows of test_cli_cloudflare_refused_address_is_reported (status, dns, tunnel and access). On the base, each command exited with code 1, and its output did not show the message of SSRFBlockedError.
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[shodan internetdb-with-flag] (AssertionError: assert (<EgressLevel...b.shodan.io']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare api-with-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare api-without-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare radar-with-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[osv-without-flag] (AssertionError: assert (<EgressLevel...api.osv.dev']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[shodan internetdb-without-flag] (AssertionError: assert (<EgressLevel...b.shodan.io']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare radar-without-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[osv-with-flag] (AssertionError: assert (<EgressLevel...api.osv.dev']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[tunnel] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[access] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[dns] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[status] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
12 failed on base (12 failed and 199 passed in tests/test_cloudflare_commands.py, tests/test_http_egress.py; 0 errored).
Elapsed: 17s

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 19:20
dan-petty and others added 16 commits October 28, 2026 13:38
…ll in the cluster is sent at most two times (#2500)

## What

- `k8s/devops/roadmap-service/deployment.yaml` sets `replicas: 1`. Its
comment names the identity the Service acts as (GitHub App
`devops-cli-service`, ADR 0015) and points to the stop switch in
`k8s/README.md`, "Roadmap service".
- `k8s/devops/configmap.example.yaml` sets `ai.max_retries: 1`. The
render of `devops k8s deploy-stack` replaces only the `service` section,
so the value gets to ConfigMap `devops-cli-config` when deploy-stack
runs. Argo CD does not apply that ConfigMap.
- `k8s/README.md`, "Roadmap service", replaces the note that held the
Service at `replicas: 0` with a go-live check and a stop switch. The
go-live check first runs `devops k8s deploy-stack --stack devops` from
`main`, reads `max_retries: 1` from the live ConfigMap, and restarts the
pod, because on a cluster that Argo CD manages deploy-stack applies the
ConfigMap but does not restart the pod. Then it checks the pod,
`up{job="roadmap-service"}`, a test ping to a hook, and the first hour
inside the 500 requests/h budget. The stop switch suspends the
installation, turns off automated sync for `bootstrap`, `cluster` and
`devops`, scales to 0, deletes the running `devops-cli` Jobs, and turns
off the hooks. The go-live check sends a fired alert of the rule group
`roadmap-service` to its row in "Alerts".
- "LLM Gateway" says that the template sets the retry count for the
in-cluster services and that deploy-stack applies it. The install check
of "Argo Workflows" no longer says that `roadmap-service` is at 0
replicas.
- The new capability `roadmap-service-deployment` holds the two
requirements.

## Why

The labels item (#2399) that the hold waited on has merged, and the App
`devops-cli-service` holds the Service's identity. Argo CD self-heals
the deployment, so only a change in git starts the Service.
`devops-background` serves one request at a time, and with the default
`ai.max_retries` of 4 a model call can be sent 5 times; with 1 it is
sent at most two times. `k8s/devops/kustomization.yaml` lists no
ConfigMap, so the retry count gets to the pod only after a deploy-stack
run and a restart.

The stop switch pauses Argo CD with `spec.syncPolicy.automated.enabled:
false`, the field that `devops k8s volume move` and "Pausing an
Application" use, not with `automated: null`, which also removes `prune`
and `selfHeal` from the live object.

## Merge condition

A person merges this only after the work of #2473 (scoped installation
tokens) and #2472 (alert rules) has merged, and each managed
repository's webhook sends only the Issues event.

Closes #2494
#2502)

Every `devops` command now reports a `DevOpsCLIError` in one way. The
wrapper of `new_typer()` (`OTelTyper.command`) reports each
`DevOpsCLIError` that a command raises: it prints the error's message in
one error line, with any Rich markup in it escaped, and exits with the
error's `exit_code`, with no traceback. `OTelTyper.callback` does the
same for a callback that runs as a command (`devops benchmark`, `devops
dashboard`).

Before, a command reported the error in four ways: `exit_on=` on 18
apps, 41 `exit_on_error` blocks, 21 hand-rolled `raise
typer.Exit(exc.exit_code)` handlers, or not at all. A `DevOpsCLIError`
that no block caught ended the command with a traceback and status 1,
not with its own status. `devops docker sandbox --dry-run` on a refused
workspace was one example.

- `OTelTyper` loses `exit_on`, and `exit_on_error` becomes the private
`_report_devops_error` of the wrapper.
- The `exit_on=` arguments, the `exit_on_error` blocks and the
hand-rolled handlers are deleted, with `_print_cloudflare_error` and
`_print_valkey_error`, which had no caller left.
- `commands/config.py` builds its app with `new_typer()`, so its
commands pass through the seam and get the `cli.<command>` span, which
holds no parameter value.
- A Cloudflare, Valkey, sandbox-logs or SBOM error prints its own
message, without the text that its handler put before it ("Valkey ping
failed: "). The exit status of each error class stays the same.
- An exception that is not a `DevOpsCLIError` propagates as before.
- Tests: a command and a callback that raise an error with markup exit
with its status in one line; every registered command app is an
`OTelTyper`; a source invariant refuses `exit_on=`, `exit_on_error` and
a hand-rolled `typer.Exit(exc.exit_code)` under `commands/`.
- `ARCHITECTURE.md` and `CONTRIBUTING.md` describe the seam.

This is part 1 of #1006. Part 2, #2490, moves the error codes onto the
exception classes.

Closes #2487

Change: `openspec/changes/archive/2026-10-28-2487-one-exit-seam/`
…son, and refine neutralizes comment openers, www links and cross-repository references (#2507)

Refine could set Status Ready on an issue that any GitHub account opened
on a public managed repository. Intake gives a Priority to every open
issue, and a refine round did not look at the `author_association` of
the author. Build agents take Ready items as work, so text from an
outside account could steer agent work. Refine also wrote the text of
the model into the issue body and its comment with three forms that
GitHub does not show as text: an unclosed `<!--` hid the rest of the
body, and a `<!-- devops-roadmap-record {...} -->` in the text of the
model became the job record (`split_record` returned `{"Status":
"Ready"}`); a bare `www.` link became a link; and an `owner/repo#N`
reference became a link with a backlink on the issue of the other
repository.

- `Item` carries `author_association`, which the issue listing already
gives, so the check costs no request.
- Without `--item`, a round leaves an item whose author is not OWNER,
MEMBER or COLLABORATOR (`CONST_ROADMAP_TRUSTED_AUTHORS`, which intake
also uses) waiting on a person. The item takes no place under `--limit`,
the round makes no model call for it, and the report names the
association and `--item <number>`. An item with no association is
treated the same way. `--item` refines the item whoever opened it.
- `sanitize_text` changes the `<` of `<!` and `<?` into `&lt;` after it
strips the tags, so a stripped tag cannot build an opener again. It puts
a bare `www.` link that the URLs of the investigation do not hold, and
an `owner/repo#N` reference, in a code span, as it does for handles and
URLs. `render_proposal_section` adds its own `checked-at` comment after
it sanitizes the text.
- The in-memory store opens an issue for the owner unless a test gives
another association, because GitHub gives an association for every
issue.
- The help text of `devops roadmap refine` and `--item` names the rule,
and the generated documents follow it. The reply schema and the prompts
do not change.
- The archived change
`openspec/changes/archive/2026-10-28-2478-refine-outside-author` holds
the evidence and the rejected alternatives, and adds two requirements to
the `roadmap-refine` spec.

Closes #2478
…a valid finding here (#2508)

A review's kube-linter scan excludes `dangling-service`, and its Semgrep
scan excludes
`python.lang.security.audit.non-literal-import.non-literal-import` and
`python.lang.security.audit.exec-detected.exec-detected` by rule id. In
the labelled reviews of this repository, every finding of these rules
was false:

- `dangling-service`: 12 candidates in S3 to S5 and 17 labelled findings
in S11 to S21. A review runs kube-linter on one manifest at a time, so
kube-linter does not see the pods that a Service selects in a sibling
file or a Helm release (#1045 measured that one run over all manifests
still reports it for Helm-deployed pods).
- `non-literal-import`: 21 candidates in S3 to S5 and 4 labelled
findings in S11 to S21. The imported names came from literals, static
maps or `__getattr__`.
- `exec-detected`: 1 candidate in S5, a test that runs a documented
snippet.

What changes:

- The exclusions use each tool's own mechanism: kube-linter's
`checks.exclude` in the config that a review hands it, and Semgrep's
`--exclude-rule` flag. The repository holds only the rule ids, never
registry rule text.
- Each exclusion is an entry of a table beside its adapter, with its
reason: `_REVIEW_EXCLUDED_CHECKS` in `security/kubelinter.py` and
`_REVIEW_EXCLUDED_RULES` in `security/semgrep.py`. `build_semgrep_cmd`
gets an `exclude_rules` parameter, and only a review's isolated scan of
materialized targets passes it.
- `logger-credential-disclosure` stays enabled, because one of its
findings was valid (`commands/config.py:514`, the secrets-audit defect
of #1022).
- A scan outside a review, such as `devops scan sast` or `devops k8s
security-audit`, runs every rule of its config.
- `CONST_REVIEW_SCAN_KUBELINTER_CONFIG` leaves `config/constants.py`,
because one module reads it. The dead `non-literal-import` suppression
on `telemetry/memory_profiler.py` in `.devops/review.toml` is deleted,
and `docs/SELF_IMPROVEMENT.md` names the two tables.
- A replay test applies the exclusions that a review's scans are handed
to the labelled S3 to S5 candidates (a new trimmed fixture, each label
citing its section of the S5 evaluation) and to the S11 to S21 labels of
#1138. It drops no valid finding.
- The Semgrep run of the adapter contract suite is recorded again with
the real Semgrep 1.179.0 and the new command.

Closes #1024

Change:
`openspec/changes/archive/2026-10-28-1024-review-scanner-rule-exclusions/`
…nterpreter keys that make a child run code (#2510)

The subprocess environment guard accepted the zsh and interpreter keys
that make a child load or run code that its caller did not choose. With
`ZDOTDIR`, `PYTHONPATH`, `NODE_OPTIONS`, `PERL5OPT` or `RUBYOPT` in the
override of a caller, the child ran a file or a module from a directory
that the caller chose. An isolated child also got the `PYTHONPATH` and
`PYTHONHOME` of the person, so a Python child, for example Semgrep or
mypy, imported a `sitecustomize` module from that directory.

- `CONST_CODE_LOADING_ENV_PATTERNS` adds the zsh keys (`ZDOTDIR`,
`FPATH`, `NULLCMD`, `READNULLCMD`), the Python keys (`PYTHONPATH`,
`PYTHONHOME`, `PYTHONSTARTUP`, `PYTHONUSERBASE`, `PYTHONPLATLIBDIR`,
`PYTHONPYCACHEPREFIX`), the Node.js keys (`NODE_OPTIONS`, `NODE_PATH`,
`NODE_COMPILE_CACHE`, `NODE_REPL_EXTERNAL_MODULE`), the Perl keys
(`PERL5OPT`, `PERL5LIB`, `PERLLIB`, `PERL5DB`), the Ruby keys
(`RUBYOPT`, `RUBYLIB`) and the Java keys (`JAVA_TOOL_OPTIONS`,
`JDK_JAVA_OPTIONS`, `_JAVA_OPTIONS`, `CLASSPATH`). The keys come from
the default `env_delete` table of sudo and from the manual page of each
shell and interpreter. A comment above each family names its source.
- `build_subprocess_env` refuses a caller override of each of these
keys, in upper or lower case, with isolation on and off. It raises the
same `SecurityError` as for the loader and bash keys.
- `DEFAULT_ALLOWED_ENV_VARS` removes `PYTHONPATH` and `PYTHONHOME`. Thus
an isolated child gets no refused key from the environment, unless the
caller names the key in `extra_allowed_keys`.
- `PYTHONUNBUFFERED`, `PYTHONDONTWRITEBYTECODE` and `NODE_ENV` load no
code, and they still reach the child.
- The child environment bullet of `ARCHITECTURE.md` names the refused
families. It also names the keys that make a child run code and still
reach it: `HOME`, the git keys (#2483) and the library keys, for example
`OPENSSL_CONF` (#2503).
- The `subprocess-environment` spec adds the new keys and the
requirement that an isolated child gets no refused key from the
environment.

Closes #2429

Change:
`openspec/changes/archive/2026-10-28-2429-refuse-interpreter-code-env-keys/`
…s in the hour, and a lane of a new pod can stall (#2514)

A review of #2496 found that the rule group `roadmap-service` misses
real incidents, and a check of the same rules found a false alert.

- `RoadmapServiceJobsFailing`, `RoadmapServiceGitHubRequestsHigh` and
`RoadmapServiceModelRequestsHigh` count each series of the last hour in
one way: `(last_over_time(x[1h]) unless last_over_time(x[1h] offset 1h))
or increase(x[1h])`. A series with no sample in the hour before started
in the hour, so its last value is all of its count. Prometheus gets no
zero sample at the start of a series (#2506), and `increase()` does not
count the first value. Before this change, the two request rules missed
a stream that the collector starts again, for example when the Service
comes back after an hour: 520 GitHub requests and 415 model requests in
an hour gave no alert.
- The old correction of `RoadmapServiceJobsFailing` read the series one
hour ago with the 5-minute lookback. A sparse error series from before
the hour added all of its count ("8 model jobs" for 2 failed jobs), and
a new series with one sample gave no result. The new count reads neither
of these wrongly. On the samples of the cluster for 30 days, the old and
the new expressions fire at the same steps, and at the incident of
2026-10-10 both find the 16 failing repository and lane pairs.
- `RepoWorker.start` sets the gauge
`devops_cli_service_job_start_timestamp_seconds` of its lane to the time
the worker starts. Before this change, a lane of a new pod had no series
until its first job, so `RoadmapServiceLaneStalled` stayed silent after
a rollout when the lane started no job.
- `k8s/README.md`, "Roadmap service", "Alerts", says how the counts read
a new series and when the 2 hours of a new pod start.
- `tests/fixtures/prometheus_rules/roadmap_service_tests.yaml` has a
promtool case for each gap, `tests/test_k8s_monitoring_alerting.py` pins
the expressions, and `tests/test_server_service.py` checks the gauge at
the start of a worker.

Closes #2505
…lure ledger, and a rate limit or a suspended installation stops every worker (#2515)

The roadmap Service kept its halt, its hourly budget window and its
failure ledger in memory, so a restart after a refusal started again at
full speed. A rate limit stopped only the thread that got it, and the
other workers sent requests during the wait. A suspended App
installation whose token was still valid did not halt the Service.
Requests sent after a refusal are the behavior most likely to make
GitHub block the App.

- The Service keeps `service-halt.json`, `service-budget.json` and
`service-failures.json` in the `roadmap` directory of the data
directory, beside the `schedule.json` of each repository, on volume
`roadmap-service-home`. A restart reads them back. A record that cannot
be read stops the start and names the file.
- A halt stays after a restart until a person removes
`service-halt.json` and restarts the Service. A start that finds the
halt counts the refusal once, so the alert
`RoadmapServiceIdentityRefused` holds through a restart. The alert's
description, its promtool test and `k8s/README.md` say how to clear a
halt.
- The budget keeps the end of each round and the requests sent since the
round before, so a new process can count from any value. The ledger keys
a failure by a SHA-256 digest of the round's input.
- `devops serve --service` builds the lane jobs with
`service_jobs(state_dir)`. `SERVICE_JOBS` and `SERVICE_FAILURES` are
deleted.
- A rate-limit wait in the GitHub session or in `run_gh` holds every
request of the identity, from all threads, until the wait ends
(`GitHubRateLimiter.hold_requests`).
- The gh-output table reads "installation has been suspended" and
"suspended your access" as a refused identity. The HTTP classifier reads
a 403 to a write whose answer has no `x-ratelimit-*` header as a refused
identity.

The roadmap store writes through `gh api`, which shows no response
header, and the Service sends no write through the session. So the
header rule covers writes through the session, and the Service's own
writes depend on the gh-output phrases. The OpenSpec design records why
the change does not add `-i` to the store's writes.

Change:
`openspec/changes/archive/2026-10-28-2474-service-state-survives-restart/`

Closes #2474
…ntic-settings sources (#2518)

Every setting now resolves in one order, which `setting_sources` in
`src/devops_cli/config/settings.py` declares once as pydantic-settings
sources: its variable, then the project config file, then the global
config file. A setting that no source holds keeps the default of its
field. Before, `load_settings` merged the two files with `_deep_merge`,
built `Settings` with `model_validate`, which reads no source, and then
set each variable with `dotted_set`. `_resolve_data_config` rebuilt the
`data` section with rules of its own, and `telemetry_from_environment`
applied a partial copy of the variable step.

- `SettingVariables` reads the variables that the settings fields
declare (#2444), with the list parsing of `devops config set`. When
`DEVOPS_CLI_DATA_DIR` is set, it also moves each data path that no
variable of its own sets into that directory, as before.
- `MappingSource` holds one config file as one load read it. The cache
of the files and the YAML error that quotes no text of the file (#1468)
stay. A null in the project file is still no value.
- `load_settings` builds `Settings(_build_sources=...)`, so
pydantic-settings merges the sources and validates the result one time.
`telemetry_from_environment` uses the same variable source.
- A value from a variable that does not validate still stops the load
with `Environment variable <name> cannot set <key>: ...` (#992). A key
that a section refuses still gets its file and line (#2201).
- `Settings(...)` built in code holds its arguments and the defaults,
and reads no variable and no file. Before, it read some variables, such
as `DEVOPS_CLI_DOMAIN`, through the default environment source of
pydantic-settings, which `load_settings` did not read.
- A credential keeps its own chain, declared in
`security.secrets.build_default_resolver`: the OS keyring, Vault, its
variable, then the config file.
- Deleted: `_apply_env_overrides`, `_resolve_data_config`,
`_deep_merge`, `_read_config_layers`, `_merged_config_data`,
`_DEFAULT_CHILD_DATA_MAP` and `env_prefix`.

These results change:

- Only the value that a setting takes is checked. A config file value
that a variable replaces no longer stops the load.
- A config file that sets only another field of `ai.tasks.embedding`,
such as its timeout, keeps the embedding model. Before, the task's model
became None, and the embedding task used the chat model `ai.model`. The
embedding task has its own override class, `AIEmbeddingTaskOverride`,
whose `model` defaults to the embedding model.
- A config file that does not hold a mapping of keys to values stops the
load with an error that names the file. Before, the load ended in an
`AttributeError`.

`docs/CONFIGURATION.md` says where the order is declared and states
these rules.

Closes #2445

Change: `openspec/changes/archive/2026-10-28-2445-settings-sources/`
…lve each host one time, through the egress check (#2521)

The Prometheus scrape of the workload sandbox and the builders of the
whitelist NetworkPolicy resolve each host name one time, through the
resolve-and-check function of the egress policy (`vet_addresses` in
`devops_cli.http.egress`). Before, the scrape checked its URL with a
pre-flight `validate_url_egress` call, which resolved the name. Then the
factory client resolved the name again at the connect. A rebinding DNS
server could give a different address at each lookup. The public
whitelist validator also resolved each name, and then the policy builder
resolved the name again with a direct `socket.getaddrinfo` call and
classified the answers itself. This change is part 4 of the split of
#1381.

The callers and their levels:

- Metrics scrape (`scrape_prometheus_metrics`): loopback level. The
pre-flight address check and its loopback shortcut go.
`_validate_scrape_url` keeps only the checks that read the URL: the
scheme is http or https, and the URL names a host. An address refusal
comes from the connect, and the scrape reports it as a failed scrape
request. The error of the scrape does not start with "SSRF validation
blocked scrape URL" any more.
- Public whitelist builder (`_resolve_public_dns`): public level.
- Local whitelist builder (`_resolve_local_dns`): private level. Then
each address must be private or loopback, and not link-local, as before.
Thus the local whitelist continues to refuse a link-local answer such as
169.254.1.2, which the private level admits.
- Public whitelist validator (`_validate_public_whitelist_item`): no
lookup (`is_loopback_or_private_host(host, resolve_dns=False)`). The
policy builder makes the one lookup, and refuses a name that answers an
address that is not public.

`ai.allow_private_network` changes none of these levels.

Each builder gives `vet_addresses` the port of its whitelist entry. Thus
the builders also refuse a cloud metadata name before the lookup, and a
scoped IPv6 answer such as `2606:4700::1%2`. The public builder admitted
that answer before. The builders continue to sort the address blocks, so
the same answers give the same manifest.

The docstring of each builder names its time-of-check gap. The
NetworkPolicy holds the addresses of one lookup. A later lookup in the
pod can give a different address. The policy does not allow that
address, so the pod cannot connect to it.

A refusal of a whitelist builder is a `SandboxValidationError`. It names
the host, the refused answer when there is one, and the reason, and the
refusal of `vet_addresses` is its cause. The message of
`SSRFBlockedError` masks the host, so it does not tell the person which
entry the builder refused. A failed lookup (`httpcore2.ConnectError`)
changes into a `SandboxValidationError` in the same way. The refusals of
an IP address or CIDR in the four builder functions also raise
`SandboxValidationError`, not a bare `ValueError`.
`SandboxValidationError` is a `ValueError`, so `devops sandbox
network-policy` exits 1 and prints no policy, as before.

`test_each_caller_dials_at_its_level` has a row for the metrics scrape,
with and without `ai.allow_private_network`.
`test_a_scrape_looks_up_its_host_once` and
`test_the_whitelist_policy_looks_up_each_name_once` count the lookups.
`test_the_whitelist_policy_refuses_an_answer_outside_its_level` gives
each builder a cloud metadata name, a cloud metadata answer, a scoped
IPv6 answer and an answer outside its level, and the local builder also
a link-local answer.
`test_a_whitelist_name_that_does_not_resolve_is_refused` and
`test_network_policy_exits_1_naming_a_whitelist_name_whose_answer_it_refuses`
check the error and the exit status. The swallowed-failures ceiling of
`sandbox/metrics.py` goes down to 1. The new capability `sandbox-egress`
holds the requirements. `README.md` names the sandbox metrics scrape
among the clients of the egress-checked factory.

Part 5 of the split (#2437) deletes `_resolve_host_ips` and
`_enforce_non_private_ssrf`, changes the check of the container engine
endpoint, and writes the general statement that every HTTP client is
checked at the connect.

Closes #2431

Change:
`openspec/changes/archive/2026-10-28-2431-sandbox-vet-addresses/`
…ce account token (#2522)

Most pods that the repository deploys mounted a Kubernetes API token
that they did not use. An attacker in one of these containers got a
valid cluster identity. The internet-facing `cloudflared` pods were
among them, and their NetworkPolicy allows the API server. A later
RoleBinding to the `default` ServiceAccount of a namespace would give
its rights to each pod of that namespace, with no warning.

- The pod templates of `cloudflared`, `gpu-feature-discovery`,
`llm-gateway`, `portkey`, `valkey`, `valkey-runs` and the nine Ollama
tiers set `automountServiceAccountToken: false`.
- The chart values turn the token off for Loki, Tempo, the OpenTelemetry
collector, Alertmanager, the Argo CD repo server and Redis, and Gitea.
Gitea uses the ServiceAccount of its chart, which has no token.
- A test in `tests/invariants/test_k8s_manifests.py` reads each pod that
a manifest under `k8s/` declares, and each pod that a chart of an Argo
CD Application makes. Each pod mounts no token, or a role binds its
ServiceAccount, or the table `_TOKEN_EXCEPTIONS` names it with a reason.
Qdrant is an exception, because its chart has no value for the token
(`qdrant/qdrant-helm#506`). The CoreDNS patch is an exception, because
k3s owns its Deployment.
- The test fails on a chart or a chart version that it does not know,
and on a stale exception. It also fails on an Application value or a
kustomization patch that its readers do not see.
- The readers of the `k8s/` tree move into `tests/support/k8s_tree.py`,
and `tests/test_k8s_local_path_placement.py` uses them too. Its table of
exemptions moves from `src/devops_cli/config/constants.py` into that
test, its one reader.
- `k8s/README.md` (Service Account Tokens) documents the rule and the
exceptions.

Trivy and kube-linter, which the gate runs, have no check for a pod that
does not set the token field. Kubescape has one, but the repository does
not pin it, and it does not render the charts of the Applications.

Closes #1652

Change:
`openspec/changes/archive/2026-10-28-1652-no-unused-service-account-token/`
🤖 I have created a release *beep* *boop*
---


##
[0.11.0](v0.10.1...v0.11.0)
(2026-10-28)


### Features

* **monitoring:** the roadmap Service's identity refusals, failing and
stalled jobs, restarts, and GitHub and model request volume raise alerts
([#2496](#2496))
([0137f23](0137f23)),
closes [#2472](#2472)
* **service:** roadmap-service runs at one replica, and each model call
in the cluster is sent at most two times
([#2500](#2500))
([2d32dae](2d32dae)),
closes [#2494](#2494)


### Bug Fixes

* **cli:** every command reports a DevOpsCLIError through one exit seam
([#2502](#2502))
([eadd55f](eadd55f)),
closes [#2487](#2487)
* **github:** pr monitor waits until the checks settle and names every
blocker, and pr ready reads the merge-readiness verdict
([#2498](#2498))
([43326ea](43326ea))
* **k8s:** a pod that does not call the Kubernetes API mounts no service
account token
([#2522](#2522))
([305d3ba](305d3ba))
* **k8s:** the cloudflared tunnel replicas prefer different nodes and
keep one up through a drain
([#2499](#2499))
([d4edaf6](d4edaf6)),
closes [#1023](#1023)
* **k8s:** the grafana, prometheus, argo cd and loki clients dial
through the egress-checked factory, and their pre-flight address checks
go ([#2497](#2497))
([e7ca1d5](e7ca1d5))
* **monitoring:** the roadmap Service alerts count a series that starts
in the hour, and a lane of a new pod can stall
([#2514](#2514))
([c7692b2](c7692b2)),
closes [#2505](#2505)
* **review:** a review's scanners leave out the rules that never gave a
valid finding here
([#2508](#2508))
([fe953ac](fe953ac))
* **roadmap:** a refine round leaves an outside account issue to a
person, and refine neutralizes comment openers, www links and
cross-repository references
([#2507](#2507))
([e6230dc](e6230dc)),
closes [#2478](#2478)
* **sandbox:** the metrics scrape and the whitelist NetworkPolicy
resolve each host one time, through the egress check
([#2521](#2521))
([7c01426](7c01426))
* **security:** the subprocess environment guard refuses the zsh and
interpreter keys that make a child run code
([#2510](#2510))
([459621a](459621a))
* **service:** a restart keeps the halt, the budget window and the
failure ledger, and a rate limit or a suspended installation stops every
worker ([#2515](#2515))
([3630de1](3630de1)),
closes [#2474](#2474)


### Code Refactoring

* **config:** settings resolve in one declared order through
pydantic-settings sources
([#2518](#2518))
([6a5447a](6a5447a)),
closes [#2445](#2445)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
…flare api clients to the egress factory

The change 2430-public-api-clients-egress-factory plans part 3 of the
split of #1381. The OSV, Shodan InternetDB, Cloudflare Radar and
Cloudflare API clients get their HTTP client from the egress-checked
factory at the public level.
…ublic api

test_each_caller_dials_at_its_level gets a row for the OSV, Shodan
InternetDB, Cloudflare Radar and Cloudflare API clients, with and without
ai.allow_private_network. The test resolves api.osv.dev,
internetdb.shodan.io and api.cloudflare.com. Each row expects the public
level and no host name at the socket. On the code before the move, each
raw client gives the host name to the socket, so all eight rows fail.
… egress-checked factory at the public level

OSVClient, ShodanInternetDBClient and CloudflareRadarClient get their
HTTP client from new_http_client at the public level, with the 1 s
connect timeout that they had. Each client resolves its API host one
time, at the connect, and dials only public addresses, with or without
ai.allow_private_network. A refused lookup gives a failed result, as a
failed connect does.

The transport argument of CloudflareRadarClient goes, with the raw
client that it built. No caller gave it, and the factory takes no
transport.
…cked factory at the public level

CloudflareClient._request gets its HTTP client from new_http_client at
the public level, with the 30 s read timeout that it had. The client
resolves api.cloudflare.com one time, at the connect, and dials only
public addresses, with or without ai.allow_private_network. Thus a bad
DNS answer cannot send the Cloudflare API token to a loopback, private
or link-local address. A refused address raises SSRFBlockedError at the
connect, and tenacity does not retry it.
…ss-checked factory builds

The SSRF protections of README.md name the OSV, Shodan InternetDB and
Cloudflare Radar lookups and the Cloudflare API client among the factory
clients. They also name the fixed public APIs among the clients that
dial only public addresses, whatever the configuration says.
… address

A command of each `devops cloudflare` group runs against
api.cloudflare.com, whose DNS answer is 10.0.0.1. The client refuses
the address at the connect and raises SSRFBlockedError. The test expects
the command to print the message of SSRFBlockedError and to exit with
its exit code, 2, with no traceback, and expects no dial to 10.0.0.1.
The exit seam of OTelTyper.command (#2502) reports the error. Before the
client fix, the client sent the request with no address check, and the
command exited with code 1, so the rows fail on that code.
…each client and the loss of the environment proxy

The design said that each lookup client gives a failed result for a
refused lookup and does not cache it, and that a devops cloudflare
command reports SSRFBlockedError with its error code. Neither was true.
The design now names the result of each client: OSV gives failed and
caches nothing, Radar gives failed and keeps the record in its
in-memory cache, and InternetDB gives the outcome ok and keeps the
record. The outcome ok is a defect from before this change, and #2504
fixes it. The cloudflare command groups now report the refusal, and
the spec delta has a requirement for it.

The proposal and the design also record that the four clients no
longer use HTTP_PROXY, HTTPS_PROXY or ALL_PROXY, because httpx2 reads
them only for a client without a transport.
…flare api host name

The dial element of test_cli_cloudflare_refused_address_is_reported
counted only a dial to 10.0.0.1. A raw httpx2 client gives the host
name api.cloudflare.com to the socket, and the socket resolves it to
10.0.0.1 with no check. Thus the element was empty also on the code
before the fix, and it did not find the request to the private address.

The element now counts a dial to 10.0.0.1 or to api.cloudflare.com, as
test_http_egress.py does with _CALLER_HOSTS. On the code before the
move of the Cloudflare API client, each row gives
['api.cloudflare.com'] for this element. On the fixed code, it gives [].
…efused cloudflare request

The exit seam of new_typer() (#2502) reports each DevOpsCLIError that a
command raises. SSRFBlockedError is a DevOpsCLIError. Thus a
`devops cloudflare` command prints the refusal and exits with code 2,
with no traceback, and commands/cloudflare.py does not change. The
design decision, the rejected alternative, the proposal and the task of
2430 name the seam. The requirement of public-api-egress stays the same.

The feasibility record names the new base, 305d3ba, and records that
the socket gets neither 10.0.0.1 nor api.cloudflare.com on the fixed
code, and the host name on the code before the move.
…o main

The branch was rebased onto main after #2502 deleted exit_on. This merge keeps the old commits of the remote branch, so that the push does not rewrite the remote history. The merge uses the strategy ours: the tree is the tree of the rebased branch.
@dan-petty

Copy link
Copy Markdown
Owner Author

The branch is now on origin/main at 5c4d24ee. I rebased it after #2502 deleted exit_on from new_typer().

  • The cloudflare, dns, tunnel and access command groups do not give exit_on to new_typer() now. commands/cloudflare.py does not change in this pull request.
  • The exit seam of new_typer() (fix(cli): every command reports a DevOpsCLIError through one exit seam #2502) reports a refused address. A command of each group prints the SSRF blocked message and exits with code 2, with no traceback. Each row of test_cli_cloudflare_refused_address_is_reported (status, dns, tunnel, access) checks this. The row also checks that the socket gets neither the refused address nor the host name api.cloudflare.com.
  • The records are updated. The proposal, the design and the tasks of the archived change, and the body of this pull request, name the exit seam of fix(cli): every command reports a DevOpsCLIError through one exit seam #2502 in place of exit_on.
  • The push: the permission system of the agent refused a force push. Thus merge commit 344adba9 joins the old head 60abcc19 with the strategy ours. The tree of 344adba9 is the same as the tree of the rebased head dbaa3839. The diff against main is the diff of the rebased branch. The squash merge keeps only this diff.

Test results on head 344adba9:

  • uv run devops ci test tests/test_cloudflare_commands.py tests/test_http_egress.py tests/test_vulnerability_lookup.py: 262 passed.
  • uv run devops ci test tests/test_security_threat_intel.py tests/test_builtin_tools.py tests/test_dependency_remediator.py tests/test_service_status.py (the other tests that import the changed modules): 100 passed.
  • The pre-push hook (devops ci, fast static checks) passed.

Fail-to-pass: uv run devops ci fail-to-pass --base origin/main exits 0. On the base, 12 tests failed, and 201 other tests in tests/test_cloudflare_commands.py and tests/test_http_egress.py passed. All pass on the branch.

  • 8 rows of test_each_caller_dials_at_its_level: osv, shodan internetdb, cloudflare radar and cloudflare api, each with and without the flag. On the base, each raw client gave its host name to the socket.
  • 4 rows of test_cli_cloudflare_refused_address_is_reported (status, dns, tunnel, access). On the base, each command exited with code 1, and its output did not show the message of SSRFBlockedError.
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[dns] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[status] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[tunnel] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
  failed on base: tests.test_cloudflare_commands::test_cli_cloudflare_refused_address_is_reported[access] (AssertionError: assert (1, <class 'S...'>, False, []) == (2, <class 'S...t'>, True, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare radar-without-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[shodan internetdb-without-flag] (AssertionError: assert (<EgressLevel...b.shodan.io']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[osv-with-flag] (AssertionError: assert (<EgressLevel...api.osv.dev']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare radar-with-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare api-with-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[cloudflare api-without-flag] (AssertionError: assert (<EgressLevel...udflare.com']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[osv-without-flag] (AssertionError: assert (<EgressLevel...api.osv.dev']) == (<EgressLevel...'public'>, []))
  failed on base: tests.test_http_egress::test_each_caller_dials_at_its_level[shodan internetdb-with-flag] (AssertionError: assert (<EgressLevel...b.shodan.io']) == (<EgressLevel...'public'>, []))
12 failed on base (12 failed and 201 passed in tests/test_cloudflare_commands.py, tests/test_http_egress.py; 0 errored).

@dan-petty
dan-petty merged commit 0379f21 into main Oct 28, 2026
20 checks passed
@dan-petty
dan-petty deleted the fix/2430-public-api-clients-egress-factory branch October 28, 2026 20:17
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.11.1](v0.11.0...v0.11.1)
(2026-10-28)


### Bug Fixes

* **config:** devops config audit-keys scans each config file that the
settings merge
([#2516](#2516))
([57541df](57541df))
* **security:** the osv, internetdb, radar and cloudflare api clients
dial through the egress-checked factory at the public level
([#2509](#2509))
([0379f21](0379f21))


### Code Refactoring

* **k8s:** KubernetesService is the Kubernetes API seam, with a shared
fake cluster and its contract suite
([#2527](#2527))
([0f6b9af](0f6b9af)),
closes [#1315](#1315)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty added a commit that referenced this pull request Nov 13, 2026
`devops pr check-readiness` read the changed files from the pulls files
endpoint. That list keeps the old base after a merge commit moves the
merge base, so PR #2509 got a false not-grounded blocker from 184 files
in place of 11. The readiness read and the implement draft read now
compare the tip of the base branch with the head commit, also for a
fork. They do not use the payload `base.sha`, because GitHub does not
move it. A compare answer at the GitHub limit of 300 files gives one
blocker that names the limit, and only the rules that read the file list
skip it.

`devops pr monitor` reads the pull request state on each poll and stops
at once on a merged or closed pull request. It prints `PR #N is merged.`
(exit 0) or `PR #N is closed.` (exit 2), with no check count and no
ready line. The implement watch also stops on a closed pull request.

Closes #2530

Change:
`openspec/changes/archive/2026-11-13-2530-readiness-compare-from-base-branch/`

---------

Co-authored-by: devops-cli-service[bot] <349441588+devops-cli-service[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): the osv, internetdb, radar and cloudflare api clients dial through the egress-checked factory at the public level

1 participant