Repository navigation
fix: allow only GET and HEAD on the read endpoints and refuse CONNECT (#78) - #80
Merged
Merged
Conversation
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
Closes #78.
All three routers had an early clause that allowed
/_ping,/version,/infoand any path starting with/eventsfor every method. SoPOST /_ping,DELETE /version,OPTIONS /_ping(the daemon's CORS preflight) andCONNECT /_pingwere forwarded to the daemon (outside--readonly), and/eventsxyzmatched too. In TS,CONNECTwas worse: the server had no'connect'listener, so Node silently dropped the connection, with no response and no audit entry.The design was reviewed by Claude Fable 5.1 before implementation; its changes (the property's wording, the CONNECT/upgrade order, TS socket handling and test approach, extra discriminating rows) are adopted.
What changes
GET/HEADon those endpoints reach the read passthrough exactly as before (with or without version prefix or query). Every other method falls through to the default deny,endpoint <METHOD> <path> is not allowed.OPTIONSis denied intentionally: it is the daemon's CORS preflight route and is not a read.CONNECTis refused first in every handler, before the Go proxy allows websocket attach (GET /containers/{name}/attach/ws), giving stdin access to containers #76 upgrade check: 403CONNECT is not allowed, audited (with the authority-form target, e.g.localhost:80, kept in the log). TS:refuseConnect, exported fromhandler.tsand wired inindex.tsviaserver.on("connect"). It swallows socket errors, writes a raw 403 withContent-LengthandConnection: close, then ends and destroys the socket, so an abandoned client cannot hang or crash the proxy.spec/router.qnt): propertyreadPassthroughOnlyForReads(everyallowReadis aGETorHEAD), flagALLOW_ANY_METHOD_PING, rows for/_ping, androuter_pre78showing the old gap. The handler-levelCONNECTrefusal is not modelled (METHODShas noCONNECT); the language and integration tests pin it.POST/DELETE/PUT/OPTIONS/PATCH/CONNECT/lowercaseconnectdenied;GET/HEADallowed;POST /eventsxyzdenied withGET /eventsxyzas a pin;POST /v1.45/_ping). Handler tests for origin- and authority-formCONNECTandCONNECT+Upgradeordering, transport never called. A TS real-server test reads the raw 403 overnet.connectand checks the audit entry. Seven integration checks.spec/README.md,deploy/test.sh.Review notes
bump=patch tag=v0.3.10.connectis an extension method, notCONNECT: Go and Rust deny it in the router (endpoint connect /_ping is not allowed) rather than the handler; Node's parser rejects it. Pinned by a table row.Verification
routerwithALLOW_ANY_METHOD_PING = truefailsreadPassthroughSoundTest,pingPostDeniedandpingDeleteDenied;router_pre78asserts the property fails.TestRouteReadEndpointMethodsrows such asRoute(POST, /_ping) = 1/"", want 0/"endpoint POST /_ping is not allowed", andTestHandlerRefusesConnect), and the new integration checks fail on all three (55 PASSED, 5 FAILEDeach), for example:404/200here: the proxy forwarded them.)make test-allGo 112, Rust 144, TS 163 (1 skipped);make lint-all,make test-spec,make verifypass; integrationALL 60 TESTS PASSEDfor Go, Rust and TS; socket suiteALL 15 TESTS PASSED.Type of change
Implementation(s) changed
Testing
make test-all)make verify,make test-spec)Checklist