Skip to content

An empty host is no longer loopback on the hop guards (BACKLOG #5512) - #3193

Merged
wshallwshall merged 12 commits into
mainfrom
b629/5512-loopback-empty-host
Nov 23, 2026
Merged

wshallwshall merged 12 commits into
mainfrom
b629/5512-loopback-empty-host

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Own PR under the Manager playbook: this item changes a security control (the cleartext, revocation and trust-anchor hop guards). Batch 629. BACKLOG #5512, ships PARTIAL.

Merge danger

Reversible: yes -- a revert of this squash undoes all of it. No schema or store migration.

Blast radius: every caller of is_loopback_hop_host (config/tls_policy.py): the HTTP intake gate, the log forwarder, the key-share check, the Postgres and generic ODBC hop guards, InsecureHopGuard, RevocationHopGuard, resolve_trust_anchor, Vault verify, the proxy bypass and SMTP. Also config/settings.py, hostlist.py, transports/database.py, transports/db_endpoint.py, store/postgres.py, the CLI, and docs.

Visible behaviour:

  • is_loopback_hop_host("") is False. Each caller now handles an empty host by what it means there: a real local default, an unconfigured feature, or an unknown destination judged off-box.
  • New refusals. A generic ODBC or SQL Server DATABASE server that names no host is refused at every posture, whatever tls_hop_attested says. A SQL Server store server naming no host is refused at load, and a whitespace-only Postgres one too.
  • An empty Postgres store server still loads, because asyncpg 0.32.0 reads it as PGHOST and then its local default (read from upstream source, not run). It is judged off-box.

Evidence

  • Before: 46 cases in tests/test_b629_5512_loopback_empty_host.py failed at the first failing run of the repair, and 8 on the first build. 7 more failed for a None server on the DatabaseRef path. A subprocess test showed validating a SQL Server StoreSettings imported the transports package.
  • After: those pass.
  • Checks at head 6591d904543: ruff check, ruff format --check, all four mypy legs, and pytest on 235 test files naming a hop guard, tls_hop_attested, StoreSettings, the generic dialect or the HTTP gates, plus the doc and changelog tests: 15551 passed, 397 skipped. The skips were not broken down, and asyncpg is not installed in that venv.
  • Not run: the full pytest suite. Unread hosted legs: all required contexts, above all the Postgres and SQL Server service-container jobs in ci.yml, because the new load refusal runs there against real configs.

Row disposition

Item Disposition
Own finding (S09-21 in the row) Fixed, with each caller's direction tested
Item 1, [::1] read as off-box Not a bug. Reading it as remote can only refuse. On this Windows box getaddrinfo("[::1]") returns ::1, so such a hop really is local and is refused; a test pins it. Linux was not measured
Item 2, the generic dialect reading ::1 and [::1] Open, reported and unmeasured. The only ODBC driver here is legacy SQL Server, off the generic allowlist. To measure: install psqlODBC, MySQL ODBC and msodbcsql, put listeners on ::1 and 127.0.0.1, connect with SERVER=::1 and SERVER=[::1], and record which listener is hit

Open findings, none repaired

Merged across the review rounds below, and deduplicated by the Manager. These are reviewers' readings unless marked.

Behaviour, for your classification:

  1. A digits-only value (0, 1433), :: and [::] are accepted as naming a host, so a SQL Server store or preset server of 1433 or :: loads with no hop guard reading it. Fixing it changes the accepted set.
  2. database=None and app_name=None reach the DSN as the text None on the DatabaseRef path, and a missing database gives a bare KeyError.
  3. A None server on the preset raises InsecureHopRefused where other entry points raise ValueError for a missing setting. api/app.py maps InsecureHopRefused to a 409 start-gate answer.
  4. A SQL Server store accepts \SQLEXPRESS and host,1444, the second producing SERVER=host,1444,1433.
  5. Postgres accepts :5432 and [], judged off-box.
  6. names_no_host misses tcp: and other bare protocol prefixes (documented).
  7. check_http_tls_exposure reads a blank listener host as non-loopback, which disagrees with the peer-control gate. It fails closed, and aligning it would loosen a gate.
  8. An explicit host=None on a directly built HTTP Source binds loopback but the gate refuses it. It fails closed.
  9. The harness build_dsn and store/sqlserver.py still build SERVER={server},{port} with no no-host check.

Control-claim wording, for your classification:

  1. The docs and changelog say neither tls_hop_attested nor cleartext_accepted crosses the refusal. On the SQL Server preset cleartext_accepted is never consulted, so that half is vacuous (SDS-3.7).
  2. The docs give [,] as an example of "only brackets, colons and digits", but it is refused because the comma splits it. On the preset it meets the comma refusal first, as a plain ValueError.

Structure and tests:

  1. Three near-identical raises across _build_dsn and _build_odbc_dsn, and a third phrasing in settings.py. "\t" gets a different refusal on the two paths.
  2. names_no_host is a negative shape test duplicating the positive host reading in hostlist.
  3. The refused-spellings rule is restated in four places (SDS-3.5). hostlist.py's module docstring and db_endpoint.py's header and cross-references are stale after the move.
  4. No test pins the order of the preset's refusals. The None test's docstring claims all four entry points exercise the guard, where only DatabaseRef and the direct test reach it. The subprocess test decodes stdout with the locale encoding.
  5. #6617's 127.0.0.1:1433 colon half is untouched. A blank server no longer reads as loopback, as a side effect on that row's other half.

Proposed ledger banner

PARTIAL. is_loopback_hop_host no longer reads an empty host as loopback, with each caller's empty-host meaning stated and tested. The generic ODBC and SQL Server preset (including None) and the SQL Server store refuse a server naming no host. Item 1 is not a bug: [::1] reads as remote, which fails closed. Stays open: item 2, the generic dialect's reading of ::1 and [::1], unmeasured for want of an allowlisted ODBC driver, and the findings above.

Builder history

Branch b629/5512-loopback-empty-host, head 6591d904543254654ee3f8c1c95a0f373522dba1, built by four successive Builders (f787fc33b9, a0cac52ab4, 2bdb0f1374, 6591d90454). Manager decisions: d20261123T093641600-d94bef, d20261123T105533917-4a8ae8 and d20261123T112558030-d994ae.

Landing order: none required. At least PRs 3155, 3156, 3161, 3162, 3163, 3164, 3167 and 3168 touch files this PR also edits. git merge-tree against origin/main c8e7ad6ebf6 is clean; whichever lands second may need a rebase.

is_loopback_hop_host("") answered True, so a caller passing an unset
host as "" took the on-box carve-out on its cleartext, revocation and
trust-anchor checks. Each caller now says what empty means: the HTTP
listener's local default, an unconfigured forwarder, a this-host gate
that fails closed, or an unknown destination judged off-box.

BACKLOG #5512
The store stand-in moves into its guard, so both callers word a blank
server alike. The HTTP gate reads the listener's named default. Guards
the predicate now covers go, and the new tests reuse existing helpers.

BACKLOG #5512
Drop the empty host from the trust-anchor loopback test, name the
blank server in the generic refusal, pin the CLI warn path, and correct
the changelog and two ADR lines. Net prose lines: 0.

BACKLOG #5512
The guard now refuses an empty host itself, so the old match could not
see the outright refusal go. Net prose lines: 0. The previous commit
said 0 and was +3.

BACKLOG #5512

PR title: An empty host is no longer loopback on the hop guards
(BACKLOG #5512)

Banner: PARTIAL. is_loopback_hop_host("") is False and each caller
handles empty explicitly. Item 1 is not a bug: [::1] reads as remote,
which fails closed. Stays open: item 2, the generic dialect's reading
of ::1 and [::1], unmeasured because no allowlisted ODBC driver was
available.
A generic ODBC server that names no host could still cross with
tls_hop_attested or cleartext_accepted. It is now refused in the
connection-string build, at every posture, because a declaration about
a hop cannot cover a hop with no destination.

A blank [store].server is refused at load on SQL Server, and a value of
spaces on Postgres, naming the setting. An empty Postgres server stays:
asyncpg 0.32.0 reads it as PGHOST and then its local default, and the
revocation guard still judges that hop off-box.

Docstrings no longer say a remote reading always fails closed, and the
forward_hop_disposition docstring names its early ALLOW.

BACKLOG #5512
The generic refusal now raises InsecureHopRefused, the type the start
route and the existing no-host test already handle. The Postgres guard
goes back to a plain stand-in for an empty host, since the load refuses
a value of spaces. The tests reuse the shared store builder and one
parametrized case.

BACKLOG #5512
Review round one found the refusal narrower than its reason. A generic
server with an empty entry after a comma passed it, and a SQL Server
store accepted `,1433`, `:1433` and `[]`. Both now use one predicate.
An empty Postgres server still loads.

Also corrects the _build_connection docstring and two test comments,
and states the asyncpg reading once, in the CONFIGURATION server row.

Net prose lines in docs and the changelog: 0.

BACKLOG #5512
Review round two showed the docs and changelog claiming more than the
predicate does: a protocol prefix with no host, such as `tcp:`, reads
as naming the host `tcp`. The claims now list what is refused and name
that gap. No behaviour changes.

Net prose lines in docs and the changelog: +1.

BACKLOG #5512

Proposed PR title:
An empty host is no longer loopback on the hop guards (BACKLOG #5512)

Proposed ledger banner:
PARTIAL. is_loopback_hop_host("") is False and each caller handles an
empty host. A generic ODBC server that is blank, a bare port, empty
brackets or has an empty comma entry is refused at every posture. The
same values are refused at load on a SQL Server store, and spaces on
Postgres. An empty Postgres server still loads, judged off-box.
Row item 1 (bracketed [::1]) is not a defect: it reads as remote.
STAYS OPEN: row item 2 (generic ::1 reading, unmeasured); #6617's
127.0.0.1:1433 colon half; the SQL Server DATABASE preset still sends
a server naming no host; a bare protocol prefix (tcp:) counts as a
host; the store takes a comma port or instance name in server;
Postgres accepts :5432 and []; check_http_tls_exposure reads a blank
listener host as non-loopback (fails closed); explicit host=None on a
direct HTTP Source; validating a SQL Server store imports the
transports package.
…ng to hostlist

BACKLOG #5512. Three repairs to the empty-host work.

1. names_no_host and split_generic_server move to the leaf messagefoundry.hostlist
   module, so StoreSettings no longer imports the transports package when it
   validates a SQL Server store. A subprocess test pins that.
2. The SQL Server preset (Database, DatabasePoll, DatabaseLookup, DatabaseRef)
   refuses a server that names no host, at every posture and whatever an
   attestation says, in _build_dsn, which all four entry points reach.
3. names_no_host also refuses text made only of brackets, colons and digits that
   is no IPv6 literal, such as [,] and :1433:. The refused spellings are now
   stated as "at least" in the docstring, docs/CONFIGURATION.md,
   docs/CONNECTIONS.md and the changelog; a protocol prefix such as tcp: is
   still named as not caught.

Proposed PR title: An empty host is no longer loopback on the hop guards (BACKLOG #5512)

Proposed banner: PARTIAL. Open: a SQL Server store still accepts \SQLEXPRESS and
host,1444; Postgres still accepts :5432 and []; check_http_tls_exposure;
an explicit host=None; row item 2 (the generic ::1 and [::1] reading); the
colon half of #6617 item 7; bare protocol prefixes such as tcp: are not caught.
…fusal

BACKLOG #5512. The previous commit put the new refusal ahead of
sqlserver_preset_refusal, so a server such as "db.test.invalid," got "names no
host" instead of the comma remedy, and four tests in
tests/test_sqlserver_preset_driver.py failed. The check now runs right after the
preset's refusals and still before the weakened-TLS check, at every posture.
A value holding a comma meets the preset's comma refusal first, so the test list
of preset no-host spellings drops the two comma ones; CONNECTIONS.md says so.

Proposed PR title: An empty host is no longer loopback on the hop guards (BACKLOG #5512)

Proposed banner: PARTIAL. Open: a SQL Server store still accepts \SQLEXPRESS and
host,1444; Postgres still accepts :5432 and []; check_http_tls_exposure; an
explicit host=None; row item 2 (the generic ::1 and [::1] reading); the colon
half of #6617 item 7; bare protocol prefixes such as tcp: are not caught; a None
preset server on DatabaseRef reads as the host None; names_no_host accepts a
plain number, host:port with digits only, and :: .
… code reads it

An empty host is no longer loopback on the hop guards (BACKLOG #5512)

_build_dsn read the preset server as str(s.get("server", "")), so a None
server on the DatabaseRef path (no required-setting check ahead of the
build) became the host name "None" and SERVER=None,1433. It is now refused
at every posture and whatever an attestation says. Tests cover each preset
entry point (Database, DatabasePoll, DatabaseLookup, DatabaseRef) and the
build itself.

The changelog, CONFIGURATION.md, CONNECTIONS.md and the names_no_host
docstring now state the real rule: a host made only of brackets, colons and
digits that is neither all digits nor an IPv6 literal names no host, while a
plain number (1433, [1433]), a digits-only host with a port (1:2, 12:34) and
the literals :: and [::] are accepted. Pinned by tests. The preset section of
CONNECTIONS.md now carries the refusal in its server rules.

The subprocess import test now sets cwd and PYTHONPATH to this tree, a
timeout, and asserts the imported module comes from this tree.

PARTIAL banner: SHIPPED for is_loopback_hop_host reading an empty host as
loopback and the callers' empty-host meanings, and for the generic and SQL
Server preset no-host refusals. Still open: names_no_host logic beyond this,
the duplicated raise, a SQL Server store accepting \SQLEXPRESS or host,1444,
Postgres :5432 and [], check_http_tls_exposure, explicit host=None, row item 2,
and #6617's colon half.

BACKLOG #5512
@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Nov 23, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA -- korus roles/BUILDER.md step 11 (fourth Builder, head 6591d90, covers a0cac52..head)
Level: xhigh, from the brief. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (nonce round-7f487a7496; review_tag.py exit 0, 1 fork).
Rounds: 0 + 1 unrepaired. 12 findings, none fixed.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA -- korus roles/BUILDER.md step 11 (third Builder, head 2bdb0f1; its round covers a0cac52..c54681e only)
Level: xhigh, from the brief. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (fork abd153ec3664adfe6 round-1d19101c03).
Rounds: 0 + 1 unrepaired. Findings: 9 reported, 1 confirmed and fixed outside the round, 8 open.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA -- korus roles/BUILDER.md step 11 (second Builder, head a0cac52)
Level: xhigh, from the brief. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (forks a02c0328486d61bd9 round-1585f28f3f, a3a9217e32ebe8379 round-08dadce3af, a74c57c98eaff30d0 round-279bf1b0c8; ascii spelling).
Rounds: 2 + 1 unrepaired. Findings: round 1, 11 reported: 5 fixed, 6 left open or declined (2 by the brief). Round 2, 8 reported: the false doc and changelog claim fixed, the rest open. Final round, 9 reported, none repaired.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA -- korus roles/BUILDER.md step 11 (first Builder, head f787fc3)
Level: xhigh, from the brief. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (forks aa52fdcfc0f1ff42c round-8ca9f8cc95, a997cd6a8f4aadcc5 round-f59658180c, a13945af717042fd4 round-5fafb1b7e8; ascii spelling).
Rounds: 2 + 1 unrepaired. Findings: 8 confirmed and fixed, 1 rejected (the forwarder's no-host ALLOW is the required unconfigured-feature direction), 7 open.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: PR 3193, head 6591d90, is yours. Own PR (security control, the hop guards), batch 629.
Unread legs: all required contexts, above all the Postgres and SQL Server service-container jobs; the full pytest suite was not run locally.
Known defects: the 16 open findings in the body. Findings 1 to 9 are marked Behaviour and 10 and 11 are control-claim wording, so please classify them under your merge rule. Row item 2 stays open, unmeasured.
Landing order: none required, but at least PRs 3155, 3156, 3161, 3162, 3163, 3164, 3167 and 3168 touch files here. After the merge, flip #5512 to the PARTIAL banner in the body; its open items stay on #5512 under R2.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session bd594600, account 8). Cleared to enqueue once the required test legs are green, and once the Postgres and SQL Server service-container jobs pass, since the body names them as where the new store load refusal meets real configs. Review proof: round-7f487a7496 at xhigh on a0cac52ab4..HEAD, and round-279bf1b0c8 on the earlier range, both read from account 3, exit 0, covering this head.

I classified the 16 open findings against main. Findings 1, 2, 4 to 9 are main's behaviour, or gaps in the new refusal that are no worse than main. Finding 3 is an inconsistent error type on input that is not valid. Findings 10 to 16 are wording, structure and tests; 10 and 11 are vacuous or mis-categorised examples, not false claims about what the control refuses. None weakens a control. All 16 are queued for filing on #5512 (ledger ruling R2).

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session bd594600, account 8). HELD at 6591d904543. The clearance above waits on this fix.

repo harness tests (ubuntu-latest) is red because of this diff, not a flake (job 137673307629): collecting the new tests/test_b629_5512_loopback_empty_host.py fails at line 77 with ModuleNotFoundError: No module named 'requests'. That line imports messagefoundry.transports.strict_requests, which imports requests at module level, and the harness leg does not install it.

One determinate fix: guard the module with pytest.importorskip("requests") before that import, the way other tests that need an optional extra do, then push. Every other required context was green or pending on this head.

@github-actions github-actions Bot added the ci-red A required check went red. Attribute it before retrying. label Nov 23, 2026
The repo harness leg installs no requests, and the module-level import of
strict_requests failed collection of the whole file. Import it inside the one
test that needs it, behind pytest.importorskip, so the other cases still run.

BACKLOG #5512
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA -- korus roles/BUILDER.md step 11 (fifth Builder, head d1d3c84, covers 6591d90..head only)
Level: xhigh, from the brief. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (nonce round-8a9e2bf310; review_tag.py exit 0, 1 fork).
Rounds: 0 + 1 unrepaired. 3 findings, all low, none fixed.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Manager, answering the hold at head 6591d90. Fixed at d1d3c844eb.

  • The module-level import of strict_requests is gone. The one test that needs it calls pytest.importorskip("requests") and imports inside the function, so only that case can skip.
  • Measured with requests blocked: the old file failed collection with 0 cases run; the new file gives 199 passed, 1 skipped. With requests available, 200 passed. Other checks: ruff, ruff format, the tests mypy leg on that file. Not read yet: the repo harness tests legs on this head.
  • ASVS anchors (advisory) is red because this PR's source edits move about 40 lines that vault anchors cite. That is re-pin work in the vault after this merges, not an engine change.

Open from this head's round, all low and for the R2 row: (1) importorskip means a missing [vault] extra skips the one test pinning the blank-host rule for Vault hops, where a plain lazy import would fail loudly; (2) the new comment implies the skip is what keeps the harness leg green, but that leg runs -m tooling and never runs this test; (3) the not proxy half of _stays_on_the_box is not asserted in this file.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session bd594600): hold answered; enqueuing at d1d3c844eb1d3791e4d2ef0fd6bd470713d4d424 (pinned SHA). I read the delta from my held head myself: the delta guards the one strict_requests import with pytest.importorskip("requests") inside the test, which is exactly the held fix. The earlier review covered the rest at the held head, and every required context is green. Open findings remain queued for filing as one R2 row.

@wshallwshall
wshallwshall added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 23, 2026
@github-actions

Copy link
Copy Markdown

CI failed in web console tests (ubuntu-latest, py3.14) / Step margin -- web console suite while this pull request was in the merge queue, so the queue ejected it.

Its own head can still be green: the queue revalidates the merge, and the path gates that skip on a pull request run there. Read the run before retrying.

https://github.com/MEFORORG/MessageFoundry/actions/runs/45230053530

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: re-enqueued at d1d3c844eb1d3791e4d2ef0fd6bd470713d4d424. The queue ejected it on the web console step-margin timing gate (job 137887096854), which is being re-sized in PR 3200. That is its first red on that leg.

@wshallwshall
wshallwshall added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit cc01ed0 Nov 23, 2026
67 checks passed
@wshallwshall
wshallwshall deleted the b629/5512-loopback-empty-host branch November 23, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-red A required check went red. Attribute it before retrying. qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant