Repository navigation
agent-audit: loopback MCP gets the bind-address question, not TLS advice - #656
Merged
Merged
Conversation
A remote http:// MCP server keeps 'use https://'. A loopback one (localhost, 127.0.0.0/8, ::1) gets its own low-severity row: kit cannot see what the server binds to, so it asks whether it listens on 127.0.0.1 or requires a token. Also: the /^http:\/\// regexes that made lizard measure one function across the whole file are gone and the hook-directory scan is its own function, so every function is measured and under the limits; a stale keystore comment that said the policy hardware mandate is not wired is corrected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
CodeQL js/file-system-race on the moved hook scan: statSync(path) then readFileSync(path) lets the file change between the check and the read. The hook is now opened once (O_NONBLOCK where available, so a named pipe cannot hang the audit) and both the regular-file check and the read go through that descriptor. Symlinked hooks are still followed, as git runs them. The hook scan had no tests; two are added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
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.
Description
kit agent-audittold an MCP server athttp://localhost:9876/mcpto "use https://". On loopback, TLS is not the risk. The risk is what the server binds to (0.0.0.0exposes it to the LAN) and whether it asks for a token, and a client config cannot show either. Found while researching a self-hosted code-search MCP server whose quick start binds every port on all interfaces (sandstream/kit-research,docs/research/paparats-mcp-vs-kit.md).http://server keeps its row and the advice "use https:// MCP endpoints".localhost,*.localhost,127.0.0.0/8,::1) gets its ownlowwarn row: "kit cannot see what the server binds to: check it listens on 127.0.0.1, not 0.0.0.0, or requires a token".Three more fixes found on the way:
src/agent-audit.ts. The regex/^http:\/\//reads to lizard as a//comment. That madeauditMcpServersspan the whole file (it is baselined aslength=426) and hid every function after it,runAgentAuditincluded. Once measured,runAgentAuditis CCN 16. The regexes are now replaced withstartsWith, and the hook-directory scan is its own function (scanHookDirs). Every function is now measured and under CCN 15 and 80 lines..kit-baseline.jsonis not touched; the stale baseline entry simply stops matching.js/file-system-raceon the moved hook scan: astatSync(path)followed byreadFileSync(path). The hook is now opened once, withO_NONBLOCKwhere available so a named pipe cannot hang the audit. The regular-file check and the read both go through that descriptor. Symlinked hooks are still followed, because git runs them. The hook scan had no tests, and two are added.src/keystore/active.tssaid the.kit-policy.tomlhardware mandate is not wired. It is:policyRequiresHardwareis ORed with the env mandate inhardwareRequired. Only the comment changed.Type of Change
Related Issues
Changes Made
src/agent-audit.ts:isLoopbackUrl(exported);cleartextMcpRows;scanHookDirsandreadHookFile, extracted fromrunAgentAudit;auditMcpServersusesstartsWithinstead of a regex.src/agent-audit.test.ts:isLoopbackUrlcases, including the look-alikeslocalhost.evil.com,127.0.0.1.nip.ioand0.0.0.0;runAgentAudittest;src/keystore/active.ts: the comment only.CHANGELOG.md.Testing
Test Coverage
npm test: 7334 tests, 0 failures)Manual Testing
.mcp.jsonwith{"mcpServers":{"local":{"url":"http://localhost:9876/mcp"},"remote":{"url":"http://mcp.internal:8080"}}}.kit agent-audit.cleartext MCP in .mcp.json(remote only, "use https://") andloopback MCP over http in .mcp.json(the bind-address question).Breaking Changes
None / N/A. Both rows are
warn, so the exit code does not change. A loopback-only config used to produce amediumrow and now produces alowone.Checklist
npm test)adr checkandreview --stages skillpass, lizard reports no new findings, and CodeQL is clean on the current headScreenshots or Logs
N/A
Performance Impact
Migration Guide
N/A
Reviewer Notes
memory/pal-graph-cost.test.js, which this diff does not touch, while another PR's Windows jobs ran in parallel. The same shard passed on the current head.new URL. The hook read usesO_NONBLOCKonly where the platform defines it, which is not Windows. Linux was tested locally and Windows is covered by CI. Nothing here is macOS-specific.🤖 Generated with Claude Code