Repository navigation
Refuse a base URL with whitespace or control characters - #117
Open
vigninou-focas wants to merge 1 commit into
Open
vigninou-focas wants to merge 1 commit into
vigninou-focas wants to merge 1 commit into
Conversation
URL parsing strips surrounding whitespace and deletes tabs and newlines, so " https://proofline.sh", "https://proofline.sh\n" or a host containing a tab were accepted and silently rewritten. Refuse any character at or below U+0020, as the Python SDK does, naming baseUrl or PROOFLINE_BASE_URL without echoing the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
baseUrlandPROOFLINE_BASE_URLgo throughorigin(), which parses the value withnew URL(). URL parsing quietly cleans up its input: it strips leading and trailing spaces and control characters, and it deletes tabs and newlines anywhere in the string. So onmainthese values are all accepted:This affects anyone who sets the origin from a CI secret, a
.envfile,$(cat file)or a copy-paste. A stray trailing newline or space is the usual case. The client does not report the problem; it rewrites the value and sends the token to the rewritten origin. A value likehttps://proof\tline.shreaches a host that differs from the string that was configured. The README says a value that is not an HTTPS origin or a loopback HTTP origin "is refused by name". The Python SDK refuses all of these values, and the MCP bridge refuses the ones with surrounding whitespace.Change
origin()insrc/transport.tsnow refuses a value containing any character at or below U+0020 (space, tab, newline and the other C0 control characters) before parsing it. The refusal uses the existing message, so it names the setting and never repeats the value:The check sits beside
URL.canParse(value)in one condition, replacing thetry/catcharoundnew URL(). The function's other checks (HTTPS or loopback HTTP, no credentials, path, query or fragment) are unchanged.Only
src/transport.tsandtests/http.test.mjschange. No generated code, schemas, API contracts, dependencies, README text or package version are modified.Decisions
Parity with the Python SDK.
proofline/_transport.pybase_url()refusesany(ord(character) <= 32 for character in value), andtest_token_environment_and_https_origin_rejectionlists" https://example.com"among refused origins. This change applies the same rule, no more and no less. The MCP bridge also refuses a value with surrounding whitespace (raw !== raw.trim()).Why not stricter. I looked at Unicode whitespace and invisible characters. NBSP, U+2028 and DEL are already refused by URL parsing on
main. A byte-order mark, a soft hyphen or a zero-width space inside the host is still accepted and removed by hostname normalisation. Refusing those would make the TypeScript client stricter than the Python SDK, so I left them out; if the clients should refuse them, that is a change for both SDKs together.localhostis left alone. The CLI'sorigin.rsacceptshttp://localhost, while the Python SDK and the MCP bridge accept only literal loopback IP addresses. The clients disagree, so this change does not pick a side;http://localhost,http://127.0.0.1andhttp://[::1]behave as before.Follows #50. The check reuses the origin validation that #50 introduced for
PROOFLINE_BASE_URL: the samebaseUrl must be/PROOFLINE_BASE_URL must beprefixes, no value in the message, and an empty variable still counts as unset. A value that is only whitespace was already refused by name and still is.Verification
The test
an unusable PROOFLINE_BASE_URL is refused by name without echoing its valueis extended and renamed toan unusable baseUrl or PROOFLINE_BASE_URL is refused by name without echoing its value, since it now covers both settings. It adds four values, each checked for the option and for the variable, asserting aTypeErrorwhose message starts with the setting's name and does not contain the value:On
main'ssrc/transport.ts, all eight checks (four values, two settings) are accepted and the test fails:With the change, it passes. The test count stays at 106 because the cases extend an existing test.
The branch is one commit on
mainat ec8dd5d. I ran the steps of.github/workflows/ci.ymlin order under Node 22, with npm 12.2.0 and pnpm 11.25.0 installed as in CI. Every step exited 0:Notes on that run: Node was v22.23.4 (CI pins v22.23.2). pnpm 11.25.0 switches to 12.19.0 because of the
packageManagerfield, so the pnpm steps ran on 12.19.0, as they do in CI. Because the change was not yet committed, I checked generation freshness by comparing the working-tree diff before and afterpnpm generateinstead ofgit diff --exit-code. The same checks also pass on Node 24.22.2.Development environment
The work was done in an isolated GitHub Codespace. Before running anything, I audited the repository for supply-chain and local-machine risks: git hooks, scripts that touch the network or filesystem, CI workflows, lockfile resolutions and integrity hashes, and text addressed to AI agents. Dependencies were installed with
pnpm install --frozen-lockfile --ignore-scripts; no dependency was added. The CI versions of npm and pnpm were installed into a temporary directory, not globally, and no repository file was changed to run under Node 22.Not verified
Nothing was run against proofline.sh; all HTTP tests use the existing local server fixture. GitHub Actions has not run on this branch, and Node 22 was v22.23.4 rather than CI's v22.23.2.
All prompts from this development session are included below in a hidden comment, as AGENTS.md requires.
🤖 Generated with Claude Code