Repository navigation
fix: re-derive an inherited install-pinned SSL_CERT_FILE on restart - #15746
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Description's "Not a goal" still names round-4's Suggestions
[DESIGN-REVIEWED] d462f8b Description read[DESCRIPTION-READ] 7f7af7f5a77ef6518bce5b8f7e7c60de10068cf1ce25a0eb1cc68050f91b8d5e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/security/redaction.py:1004 -- document-link exemption leaks embedded bare credentials
Adjudication (Opus 5) — is blocking on each finding proportionate?F1 — harm: UNBOUNDED class (credential text reaching dashboard/channel output); the defect is real and is the residual the code itself records at Conditions confirmed in this run: the run must carry a key-shaped 40-char window ( Rarity: no system writer can place a real credential in that slot — a Google-generated id is random, and a random window is not a credential; it takes deliberate authoring of a fake-but-valid doc URL. Against a deliberate author this exemption grants nothing new: 🏷️ Fenced finding(s) machine-flagged as likely edge caseThe security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.
False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the premise that the managed-venv update engine prunes nothing: every existing install upgrades through this change pre-marker, so a pruning upgrade reproduces the outage once before provenance exists. Not justified as shipped
What this change shipsInventory (6 items) — 5 justifiedIntent: FIX — after an in-app restart across an upgrade, TLS keeps working instead of pointing at a CA bundle the upgrade deleted (#15713, red run on base quoted).
Sibling count for the root cause (install-pinned runtime export inherited across reexec): 1 — [FIRST-PRINCIPLES-REVIEWED] d462f8b Description read[DESCRIPTION-READ] 964a1e48642968c78c18aea232271658c9a00ba26b115b7baa254f22b23f02b7 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
5756672 to
7b6a0e6
Compare
7b6a0e6 to
a2e230b
Compare
a2e230b to
a2d48cb
Compare
What: `_ensure_ssl_certs` no longer takes its operator-override early return
on a `SSL_CERT_FILE` / `REQUESTS_CA_BUNDLE` value that the runtime itself
exported. `_export_ca_bundle` publishes the provenance of each variable it
assigns beside it -- `KIROCREW_EXPORTED_SSL_CERT_FILE` and
`KIROCREW_EXPORTED_REQUESTS_CA_BUNDLE`, runtime-written, never operator-set,
each holding the value assigned and each published only on assignment:
`REQUESTS_CA_BUNDLE` is only defaulted, so an operator's value found there
gets no marker even when it equals the bundle this install derives. One
marker shared by both variables would have vouched for an operator's
`REQUESTS_CA_BUNDLE` pinned at `$(python -m certifi)` of this very install
and moved their pin on the next upgrade restart; per variable, a successor
re-derives exactly what its predecessor assigned. `_inherited_export_reason`
reads a variable as the runtime's in exactly one case: it equals its own
marker. Such values are dropped from both variables before the operator check
and trust is derived for this install in the clean-start order
(`_derive_trust`, the unchanged discovery body), with one WARNING line that
names the value and the reason. Nothing else is provenance -- not the path's
shape, and not the directory it lies in, Kiro Crew's own install trees
included: any other value is an operator's and is left untouched, present or
gone, with one warning when the file cannot be found. That warning now also
names the way out for the one value this leaves unrecognised, a predecessor's
export from before the provenance existed ("if an earlier Kiro Crew install
exported this value, start it from a clean environment"): kept, it works while
its file exists and fails closed, loudly, once the predecessor's tree is gone,
until one clean start -- after which this runtime publishes the provenance and
every later restart is recognised. The prelude reads no data home and imports
nothing beyond itself. Windows is unchanged: the prelude exports nothing
there, so nothing there can be the runtime's.
Why: on a host with no system CA bundle (the macOS desktop bundle,
standalone and source installs) the prelude exports certifi's bundle, a path
inside the running install's site-packages. The in-app restart seams
(`platform_compat.reexec_launcher` / `reexec_python_module` behind the
dashboard's update and restart actions, `service.live_target.maybe_reexec`
for a live-target cutover) hand the successor this process's environment, so
the successor saw the predecessor's value, returned early, and kept pointing
at the previous install's bundle; once an upgrade or an installer re-run
deleted that tree every TLS handshake failed until a restart from a clean
environment. The rule is the one #15607 proposes for `LLAMA_CPP_LIB_PATH`,
and the marker is the issue's own second approach: a value the runtime
exported is transitional, not an operator's, and the runtime says so itself
-- per variable, because provenance is of an assignment, not of a path. No
inference from the path can stand in for that: an operator who pinned a
certifi bundle of their own holds a working policy while the file exists and
a fail-closed one once it does not; an operator can place a restricted bundle
inside this runtime's own venv, and a tree the installers delete takes that
pin with it, leaving a fail-closed state that is theirs; on macOS an explicit
bundle also excludes the Keychain's CAs. Re-deriving over any of these widens
trust past what the operator chose, so the prelude never does. The cost is
the pre-provenance predecessor whose tree is deleted while its lineage is
still unmarked -- the installer re-run retiring `<data home>/venv` under a
running gateway, followed by an in-app restart; the update engine prunes
nothing -- which fails closed once with the cause and the remedy in the log.
Red-first: `test/test_ssl_certs.py::TestInheritedInstallPinnedBundle` (first
run 5 of 8 red on main, including the two-bootstrap restart against a pruned
bundle; the marker-only rule's dead-pin-kept parameters and the two-module
import pin red on the head that still inferred ownership from the path; the
per-variable test -- an operator's `REQUESTS_CA_BUNDLE` at the derived path
kept across an upgrade restart -- red on the shared-marker head; 13 tests on
this head). Spec: `docs/system-specs/common/platform-compat.md`, section
"TLS trust bootstrap across an in-app restart".
Fixes #15713
a2d48cb to
d462f8b
Compare
|
|
|
CI note for head
Attempt 2 (15:02Z) passed both; this head is green. |
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. A value is treated as the runtime's own only when it exactly equals its per-variable marker; a forged marker can only cause a drop-and-re-derive, and the replacement always comes from _derive_trust (system cafile, _CA_CANDIDATES, certifi), so trust can never be pointed at a new file and verification is never lowered (bad/missing bundle still fails closed). Operator values without a marker are kept, REQUESTS_CA_BUNDLE never gets a marker, Windows is skipped.
Please fix before merge: the body's Not a goal and Backwards compatibility sections still name a single KIROCREW_EXPORTED_CA_BUNDLE, but the code writes KIROCREW_EXPORTED_SSL_CERT_FILE and KIROCREW_EXPORTED_REQUESTS_CA_BUNDLE (_ssl_compat.py:262,265). Test gaps: macOS inherited-export path, a mismatched marker that must be kept, certifi ImportError leaving the variable unset.
|
Frozen sections updated at the maintainer's request (2026-10-01): three sentences now name the shipped contract -- the two per-variable markers and the current restart seams. No scope change. |
Problem / Motivation
Goal: After an in-app restart that crosses an upgrade, Kiro Crew keeps making TLS connections instead of pointing at a CA bundle the upgrade deleted.
On a host with no system CA bundle (the macOS desktop bundle, standalone and source installs) the startup prelude
_ssl_compat._ensure_ssl_certsexportsSSL_CERT_FILE/REQUESTS_CA_BUNDLEset tocertifi.where(), a path inside the running install's own site-packages. The in-app restart successors inherit that environment (os.execvinplatform_compat.reexec_launcher/reexec_python_module,os.execvewith the inherited environment inservice/live_target.maybe_reexec), so the successor's own prelude sees the predecessor's value, takes the "an operator set this" early return, and keeps pointing at the previous install's bundle. Once an upgrade prunes that tree every TLS handshake fails (FileNotFoundError,SSLError: Could not find a suitable TLS CA certificate bundle) until the operator restarts from a clean environment.Why it matters
Every operator who upgrades through the in-app update path on a host without a system bundle is hit, and the failure looks like a broken network rather than a stale environment variable: the gateway cannot reach any HTTPS endpoint, nothing in the UI names the cause, and the only remedy is a restart from a fresh shell. Until then the gateway and every child it spawns (kiro-cli, Node MCP servers) are offline for TLS.
Not a goal
SSL_CERT_FILEis honoured: a value the runtime did not export keeps its highest-precedence behaviour unchanged, including a certifi bundle the operator chose themselves.LLAMA_CPP_LIB_PATH, the sibling of this cause class: fix(embeddings): keep LLAMA_CPP_LIB_PATH out of the process environment #15607 owns it.KIROCREW_EXPORTED_SSL_CERT_FILEandKIROCREW_EXPORTED_REQUESTS_CA_BUNDLE, are written by the runtime for the runtime, likeKIROCREW_BOUND_PORT.platform_compat.reexec_launcher/reexec_python_module,service/live_target.maybe_reexec): they are right to pass the environment through.What changed (motivation → approach → change)
Symptom: a restart successor keeps a deleted install's CA bundle path. Cause:
_ensure_ssl_certsinsrc/kiro_crew/_ssl_compat.pycannot tell its own exported value, inherited from a predecessor, from an operator override, and returns early on both. Approach: the rule #15607 proposes forLLAMA_CPP_LIB_PATH— a value the runtime exported is transitional, not an operator's — with the runtime saying so itself, since the export must stay in the environment for the children (#15713's second approach)._export_ca_bundlewritesSSL_CERT_FILE, defaultsREQUESTS_CA_BUNDLE, and publishes one marker per variable it assigned —KIROCREW_EXPORTED_SSL_CERT_FILE,KIROCREW_EXPORTED_REQUESTS_CA_BUNDLE— holding the value assigned; an operator'sREQUESTS_CA_BUNDLEfound already set gets none, even at the very path this install derives. A successor re-derives a variable because its own marker names it, never for how the path looks or where it lies._inherited_export_reasonis the one classifier: yes in exactly one case, the variable equals its own marker. Nothing else is provenance — not the path's shape, not the directory, Kiro Crew's own install trees included._derive_trustruns the unchanged clean-start order; oneWARNINGnames each changed value and its reason. Windows is unchanged.WARNINGnaming the way out — "if an earlier Kiro Crew install exported this value, start it from a clean environment". Producing case, one-time: an installer re-run retires<data home>/venvunder a running gateway, then an in-app restart; one clean start heals it.docs/system-specs/common/platform-compat.md, section "TLS trust bootstrap across an in-app restart".Review rounds. Round 1 recognised a pre-marker predecessor by its path's certifi shape, round 2 by ownership of the runtime's install trees, round 3 by positively named trees; GPT blocked each on one span (
88b185d089a6): an operator's own pin can look, or sit, exactly like ours. Three prints of one position is the same-span stall; round 4 removed the inference (GPT's fix line). The fourth print was a new, real item: one marker shared by both variables vouched for an operator'sREQUESTS_CA_BUNDLEpinned at this install's own certifi path; round 5 makes provenance per variable. Opus's items are closed (seam names fixed in round 2; bridge items removed with it). Base8ae5dff6ee; every CI job on the round-4 head was green.Backwards compatibility
Compatible: nothing main accepts stops working. An operator's
SSL_CERT_FILEof any shape behaves exactly as before, present or gone (a missing file now draws one warning). Windows behaviour is byte-identical. No configuration, flag or operator-set variable is added or removed;KIROCREW_EXPORTED_CA_BUNDLEis written and read by the runtime only, and a child that ignores it loses nothing.Tests
test/test_ssl_certs.py::TestInheritedInstallPinnedBundle(13 tests, 12 functions), written first. The first red run onmainat7038f5fc9b, before the review rounds reshaped the rule, was 5 of 8 red:Each later rule was red first as well: round 2's ownership tests failed 11 of 19 on the round-1 module, round 3's narrowed-ownership tests 4 of 22 on the round-2 module, and round 4's marker-only tests — the final file run against the round-3 module
a2e230b51ein a detached scratch worktree — failed the two dead-pin-kept parameters (the bridge re-derived them, and the warning lacked the clean-environment clause) and the two-module import pin (the bridge importedkiro_crew.config.paths). Round 5's per-variable test, run against the shared-marker modulea2d48cb9d4the same way, failed: the successor dropped the operator'sREQUESTS_CA_BUNDLEand moved it to the new bundle (6 of 13 red on that module — the new test plus every test that pins the per-variable marker names, which that module never wrote):What each test locks in on the final head:
test_restart_after_an_upgrade_re_derives_the_pruned_predecessor_bundle: the issue's reproduction, two bootstraps with the first run's environment carried into the second against a pruned bundle; both variables and the provenance end on the new install's bundle, and exactly oneinheritedline is logged, at WARNING, naming the provenance marker as the reason.test_predecessor_bundle_that_still_exists_is_still_re_derived: a still-present predecessor bundle with provenance is re-derived too (the file's presence does not make it an operator's).test_dead_pin_without_provenance_is_kept_even_inside_a_former_install_tree(2 parameters): the documented cost — a dead pin without the marker inside the retired<data home>/venvor a versioned sibling of the managed venv is kept byte for byte, nothing is exported, noinheritedline is logged, and the one WARNING names the file and the clean-environment way out.test_prelude_imports_nothing_beyond_itself: a fresh interpreter running the prelude loads exactlykiro_crewandkiro_crew._ssl_compat— not the config package,platform_compat, the update engine or any HTTPS client — the same on every platform.test_runtime_export_yields_to_a_system_bundle: re-deriving follows the clean-start order, the provenance is dropped with the value, and an operator's ownREQUESTS_CA_BUNDLEbeside it is untouched.test_operator_certifi_bundle_on_macos_keeps_its_exclusion: the GPT lane's round-1 blocking case; an operator's existing certifi pin without provenance is untouched and the Security.framework injection stays off.test_operator_bundle_not_install_shaped_is_untouched: an operator's corporate bundle keeps the early return, nothing exported, nothing logged.test_operator_bundle_that_is_missing_is_respected_with_one_warning: a missing operator file is respected and warned about once.test_stale_requests_bundle_beside_an_operator_ssl_cert_file_is_dropped: the runtime'sREQUESTS_CA_BUNDLEis dropped before the operator check and the operator'sSSL_CERT_FILEis honoured as before.test_operator_requests_ca_bundle_at_the_derived_path_survives_a_restart: the GPT lane's round-4 blocking case — an operator'sREQUESTS_CA_BUNDLEset to this install's own certifi path with noSSL_CERT_FILE; the first bootstrap derives that path and marks onlySSL_CERT_FILE, and the upgrade restart re-derivesSSL_CERT_FILEwhile the operator's variable keeps its value, unmarked and unlogged.test_own_export_seen_again_in_the_same_process_is_kept_silently: both entry points running the prelude in one process reproduce the same export with nothing logged (also the restart-onto-the-same-install case).test_win32_leaves_an_inherited_or_operator_value_alone: Windows never touches the value, even with a stray provenance beside it.The three that passed on
mainin the first run pin behaviour this change must not alter. Paths in the tests are built fromtmp_path, so they are native on the Windows and macOS shards. Run locally on this head:python -m pytest test/test_ssl_certs.py test/test_main_entrypoint_cov80.py test/test_sandbox_argv.py -n0(the files that touch the prelude), 259 passed, 4 skipped; black ratchet, isort, flake8, the subprocess-encoding gate, mypy on the module, docs-lint, the comment-history gate and the harness-parity gate all green on this head;push_guard.py --base main --require-single-on-baseSAFE.Manual verification
N/A — unit coverage sufficient: the two-bootstrap test executes the real
_ensure_ssl_certstwice with the first run's environment carried into the second, which is exactly what the exec-based restart seams do to the prelude, and those seams are unchanged; the fresh-interpreter test runs the real prelude as a separate process and pins what it imports. Not run here: an in-app upgrade restart on a macOS desktop bundle (the Design lane's one-time host check) — this fleet has no macOS host; the behaviour it would confirm is the two-bootstrap case above.Screenshots / video
N/A — no user-visible change; the diff touches the backend startup prelude, its tests and a spec.
Related Issues
Fixes #15713
Related: #15607 (same cause class,
LLAMA_CPP_LIB_PATH; it excludes this module on purpose and its First Principles review counted this module as the remaining sibling).Pattern harvest
Rule candidate: review-prompt
Pattern: an early return on an inherited environment value that the runtime itself exported — a value a Kiro Crew process writes for its children is indistinguishable downstream from an operator override unless the writer publishes its provenance beside it, and an exec-based restart successor honours it as one.
Siblings of the same shape, not changed here:
embeddings.py:LLAMA_CPP_LIB_PATH, fixed by fix(embeddings): keep LLAMA_CPP_LIB_PATH out of the process environment #15607 with the rule this PR mirrors.port_resolution.py::resolve_client_port_src: readsKIROCREW_BOUND_PORTback as the"bound"source and treats it as stable for the process lifetime; the gateway exports that variable at bind time (dashboard/server.py) and overwrites it on its own bind, so a successor carries the predecessor's port only in the window before it binds. Whether that window has a consequence is not verified here.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement