Repository navigation
fix: keep the Java attach guidance and the port probe on loopback, with a guard - #1396
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.attach_to_processdescription, the Java adapter's attach hint, the workflow prompt and the debugging skill now giveaddress=127.0.0.1:<port>.127.0.0.1where they gave a bare port, which is every interface on a JDK 8 target. A comment that said Delve runs with--listen=:portis 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.tsholds a recorded list of:tools/:.listen(,inspector.open(,dgram.createSocket(, and in JavaServerSocket,InetSocketAddress,ServerSocketChannel.open(,createServerSocket(,startListening(. Each entry says what it binds and why, or why it opens no socket;0.0.0.0,[::], a--listenvalue that starts with a colon,address=*, and a non-loopbackaddress=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
127.0.0.1argument, and now fails in milliseconds instead of by timeout when the host is missing.Review
Two reviewers, a Gemini one with a mutation pass each round and a Claude Opus one reading, three rounds:
Verified
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