Skip to content

fix: keep the Java attach guidance and the port probe on loopback, with a guard - #1396

Merged
debugmcpdev merged 6 commits into
mainfrom
fix/loopback-guidance-and-probe
Nov 30, 2026
Merged

debugmcpdev merged 6 commits into
mainfrom
fix/loopback-guidance-and-probe

Conversation

@debugmcpdev

@debugmcpdev debugmcpdev commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1389.

What changes

Guidance. The text an agent reads before attaching to a JVM told it to start the JVM with address=*:<port>, which opens the unauthenticated JDWP port on every network interface.

  • The attach_to_process description, the Java adapter's attach hint, the workflow prompt and the debugging skill now give address=127.0.0.1:<port>.
  • The three general ones name the one case that needs more: a JVM in a Docker container reached through a published port, which is then published on the host's loopback. The skill says JDWP has no authentication and what loopback already serves (this machine, an in-pod sidecar, an SSH tunnel).
  • The Java docs, the skill reference and one example name 127.0.0.1 where they gave a bare port, which is every interface on a JDK 8 target. A comment that said Delve runs with --listen=:port is corrected.

The server's free-port probe. Each time a launch or an attach is prepared (a dry run included), it listened with no host, and so on every interface for an instant. It binds 127.0.0.1, the address every adapter then binds.

A guard. tests/core/unit/loopback-bindings.test.ts holds a recorded list of:

  • every listener by its spelling in the server's and adapters' sources, the Java bridge, the pi extension and tools/: .listen(, inspector.open(, dgram.createSocket(, and in Java ServerSocket, InetSocketAddress, ServerSocketChannel.open(, createServerSocket(, startListening(. Each entry says what it binds and why, or why it opens no socket;
  • every line there or in the skill text that writes a wildcard shape: 0.0.0.0, [::], a --listen value that starts with a colon, address=*, and a non-loopback address= on a line that names JDWP.

A new one fails until someone has looked at it and recorded it. So does a recorded line that no longer matches, which is how the guard dropped its own entry for the old Java launch line once #1387 was on main. It records 23 lines today.

The guard does not judge whether a listener looks safe. Its first two versions did, from one line of text, and two review rounds each found new ways to fool that (a literal in a callback, a nested call, a template, a fallback). What it does not see is filed as #1395: a host handed to a spawned debug adapter on its command line, and the line elsewhere that sets a recorded listener's host.

Tests

  • 55 recognition rows pin each clause of each rule.
  • 22 text-only mutants all fail the guard: a new listener in six forms (one of them a correct loopback one), the two old Java bridge lines, a recorded listener given a variable host, three wildcard spellings in text, and each clause of the guard deleted in turn.
  • The probe's unit test asserts the 127.0.0.1 argument, and now fails in milliseconds instead of by timeout when the host is missing.
  • A test keeps the three general guidance texts in step; the 24 tool-list snapshots follow the new description.

Review

Two reviewers, a Gemini one with a mutation pass each round and a Claude Opus one reading, three rounds:

  1. On the first version: nothing above minor; three surviving mutants and the same blind spots from both.
  2. On the tightened heuristic: four more surviving mutants from one reviewer, and from the other one finding above minor, in a guidance sentence added in that round (it sent an in-pod sidecar to a wildcard address).
  3. On the version here, with the judging removed and the sentence rewritten: nothing above minor from either; the earlier mutants all fail.

Verified

  • The guard, the probe test, the guidance test, the Java factory test, the snapshot test and the Python adapter tests on the merged head: 275 passed. Type check, lint, docs check and changelog check pass.
  • End-to-end for the probe change, which every session's launch goes through, at 931d7055: on Windows the all-languages tool test (101 cases) and the Python, JavaScript and Java smokes, 131 passed; on Linux the same (101 and 30 passed) and the guard and probe tests (113 passed).

Who wrote what

A GPT worker wrote the guidance change, the probe change and its test, the first version of the guard and its first tightening. The manager session (Claude) wrote the final form of the guard (record, do not judge), the Docker wording of the three guidance texts, the recorded reasons for the seven listeners, the changelog entry and this description.

🤖 Generated with Claude Code

https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs

cynarlab and others added 6 commits November 29, 2026 17:15
…th a guard (#1389)

The text an agent reads before attaching to a JVM told it to start the
JVM with address=*:<port>, which opens the unauthenticated JDWP port
on every interface. The attach_to_process description, the Java
adapter's attach hint, the workflow prompt and the debugging skill now
say address=127.0.0.1:<port>. The 24 tool-list snapshots follow.

The per-session free-port probe listened with no host, which binds
every interface for a tick. It binds 127.0.0.1, the address every
adapter then binds.

A guard in the unit suite scans the shipped sources and the
agent-facing text for address=*, 0.0.0.0 and a listen call that names
no loopback host, and compares what it finds with a recorded list of
reviewed lines, each with a reason. A new occurrence fails; so does a
recorded line that no longer matches.

Written by a GPT worker from the manager session's brief.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
After the rebase onto the launch fix (#1387), the guard's recorded
entry for the bridge's old wildcard line was stale, and the guard said
so. The entry is gone. The guard now also flags a Java
"new ServerSocket(" that names no loopback address, the form the
bridge's port probe had until that fix. Put back as text, both old
lines fail the guard.

The changelog entry is reworded in the house style.

Written by the manager session.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
…k guard (#1389)

Findings of two reviews (Gemini with a mutation pass, Claude Opus) on
the previous two commits.

Guidance. The three general attach texts gave a loopback address in a
section that also covers remote machines and containers, where a JVM
behind a published Docker port cannot be reached on its loopback. They
keep address=127.0.0.1:<port> and now say when to widen it and how to
publish a container's port on the host's loopback. The Java docs, the
skill reference and an example named a bare port, which is every
interface on a JDK 8 target: they name 127.0.0.1. A comment said Delve
runs with --listen=:port; the code passes 127.0.0.1.

Guard. Three reviewer mutants survived the first version. It now
- takes a call's arguments by matching parentheses, so loopback text
  after the call does not count and a nested call does not cut the
  arguments short;
- does not accept a literal behind a fallback, a ternary or a spread;
- judges a call that continues on the next line on the arguments it
  has already finished, so listen(0, '127.0.0.1', () => { passes
  without an entry and listen({ goes to review;
- knows the Java ServerSocket and InetSocketAddress constructors, [::],
  a --listen value that starts with a colon, address=* anywhere, and a
  non-loopback address= on a line that names JDWP;
- reads 0.0.0.0 as an address, not as a substring of 10.0.0.0/8;
- scans .js, .mjs and .cjs beside .ts, every package's java tree, the
  pi extension and tools;
- names the rule and the line number when it fails.
Three recorded reasons that did not say what their line does are
corrected. 79 classifier rows pin each clause; eleven text-only
mutants, among them the two old bridge lines and the three that had
survived, all fail it.

The probe's unit test failed by timeout when the probe lost its host;
its stand-in now calls the callback wherever it is, and the assertion
fails in milliseconds.

The guidance, the first tightening of the guard and the probe test
were written by the GPT worker. The manager session wrote the
finished-arguments rule, the JDWP context rule, their rows, and the
changelog entry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
…1389)

Second review round on the guard (Gemini with a mutation pass, Claude
Opus). Both found the same thing in different lines: the guard tried
to tell from one line of text whether a listen call binds loopback,
and a loopback literal can sit in a callback, a nested call, a
template, a fallback, or on a key that is not the host. Four of
Gemini's mutants survived; each patch of the heuristic opened the
next hole.

The premise was wrong, so it is gone. The guard no longer judges what
a listener binds. Every .listen( call and every Java ServerSocket or
InetSocketAddress constructor in scope is on the recorded list with
what it binds and why, and a new one fails until someone has looked at
it and written that down. The text rules are unchanged (0.0.0.0, [::],
a --listen value that starts with a colon, a wildcard or non-loopback
JDWP address=), except that 0.0.0.0 at the end of a sentence is now
seen. 23 recorded lines, seven of them listeners that the previous
version let through unrecorded because they looked right. 47
recognition rows; sixteen text-only mutants all fail it, among them a
correct-looking new loopback listener, a recorded listener given a
variable host, and the two old bridge lines.

Guidance. The sentence added in the previous commit sent an in-pod
sidecar, which shares the pod's loopback, to a wildcard address, and
gave no tunnel for another machine. The three general texts now name
the one case that needs more than loopback, a JVM in a Docker
container reached through a published port, and the skill says what
loopback already serves.

The changelog entry follows: the hint is unchanged, and the probe also
runs on a dry run.

Written by the manager session.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
Both reviewers confirmed the previous commit with nothing above minor.
Their remaining points, all recognition or wording:

- The guard also recognises inspector.open( and dgram.createSocket(,
  and in Java ServerSocketChannel.open(, createServerSocket( and
  startListening(. None exists in the tree today. A quoted '::' was
  tried as a wildcard spelling and dropped: pytest node ids are
  written with it.
- The header and the failure text no longer call every match a
  listening socket (DeadlineTree.listen and the MCP client's listen
  are on the list too), and the header names what the scan does not
  see: the line elsewhere that sets a recorded listener's host, and a
  host handed to a spawned debug adapter on its command line.
- The changelog entry says what the list holds by its spelling.
- One stale rule name in the exact-text test.

55 recognition rows; 22 text-only mutants all fail the guard.

Written by the manager session.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
Brings in the Java double-stop fix (#1393) and the debugpy log change
(#1392).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@debugmcpdev
debugmcpdev marked this pull request as ready for review November 30, 2026 00:02
@debugmcpdev
debugmcpdev merged commit ce574b5 into main Nov 30, 2026
18 checks passed
@debugmcpdev
debugmcpdev deleted the fix/loopback-guidance-and-probe branch November 30, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loopback hygiene: the Java attach guidance says address=*:<port>, and the per-session port probe listens on every interface

2 participants