Repository navigation
Stop printing the credentials of URLs quoted from lockfiles in refusals and hosted warnings - #2445
Merged
Mikola Lysenko (mikolalysenko) merged 13 commits intoDec 2, 2026
Conversation
Refs #2287. Assisted-by: Claude Code
A vendored refusal quotes lock text: the source of a Cargo.lock entry, the key of a yarn.lock block, a registry. It is the `Cannot vendor` line, a `[would-refuse]` preview line and the `error` of a `--json` event, so a token in the userinfo of such a URL went to the terminal, the CI log and the stored document. `vendor::common::refused`, which every backend builds its refusals with, now redacts the URLs in its detail, as `VendorWarning::new` already does. The three refusals the npm flavor probe built by hand and the one the Maven backend rebuilt go through it. Both constructors use one helper, `redact_message`. Refs #2287. Assisted-by: Claude Code
`rollback`, `remove` and a vendored takeover put a hosted pin back on its registry entry, and refuse with the reason: the sources a nuget.config maps a package to, the registry a uv.lock or pylock.toml records, or the URL of a request that failed. Credentials in any of those were printed in the `Cannot restore` line and in the `error` of the `--json` event. `FormatResult::refuse` now redacts the URLs in its reason. The JSON lookups (the npm, PyPI and Packagist documents, which a mirror variable can point at a URL with credentials) redact their errors the way the byte downloads already do. Refs #2287. Assisted-by: Claude Code
A hosted rewriter names the lock entry it leaves alone: a yarn.lock block installed from git, a Poetry source, a requirements direct reference. With a token in that URL the warning carried it to stderr, to `warnings[].detail` of the `--json` document, and to the result of the in-memory engine. The warning is now redacted where it enters each reported type: `RunWarning::new` for the CLI (its stderr lines are printed from the same values), and `rewrite_warnings_json` and `EngineWarning::new` for the in-memory engine. A `RewriteWarning` itself keeps the lock's text, which the engine compares against lock keys. Refs #2287. Assisted-by: Claude Code
A wrapper whose `distributionUrl` names a distribution that is not unpacked yet is reported in the `gradle_maven_local_undetermined` note of every scan of the build. A distribution server that needs credentials takes them in that URL, so the note printed them. Refs #2287. Assisted-by: Claude Code
Three file-only projects each hold one token in a URL their package manager writes or reads: a yarn classic lock keyed by a git remote, a Cargo.lock git source and a requirements direct reference. `scan` and `get` run over them in hosted and vendored mode, plain, with `--json` and with `--dry-run`, and neither stream may carry the token. Every run must still name the entry, with the credential redacted. Refs #2287. Assisted-by: Claude Code
Mikola Lysenko (mikolalysenko)
pushed a commit
that referenced
this pull request
Dec 2, 2026
The run confirmed #2287 on main (11 of 11 runs print the token), claimed it and opened the draft, then lost its worker for four hours. Another run took the PR over, so this entry leaves the register to that run. Assisted-by: Claude Code
`redact_urls_in` looks back from a `://` for the start of the scheme and stepped one byte past the character it stopped on. With a character of more than one byte right before the scheme (a curly quote, an accented letter in a lock key or a manifest value) it then sliced inside that character and panicked. Vendor warnings and download errors already ran project text through it; the refusals and run warnings this branch redacts made the panic reachable from every scan of a Gradle build whose wrapper URL has such a character: exit 101 and no `--json` document, where main exits 0. The scan now steps over the whole character. Refs #2287. Assisted-by: Claude Code
`vex` reports a Socket-wired lock entry it cannot attribute and quotes the entry beside it: for a yarn classic lock, the key of a block that installs the same release from git. With a token in that remote the note printed it on stderr and in `warnings[].detail`. `note_warning`, which every advisory of `vex` is recorded through, built its `RunWarning` by hand and so skipped the constructor that redacts. It now calls `RunWarning::new`; the stderr lines are printed from the same values. Refs #2287. Assisted-by: Claude Code
`upstream_registry_fallback` names the project's registry without its userinfo and rewrote the cause to match. The cause of a failed lookup now arrives redacted, so the rewrite found nothing and the sentence read `http://host/…` beside `http://<redacted>@host/…`. The rewrite takes both spellings, and the warning reads as it does on main. The JSON lookup's test holds its port for the transport case instead of reusing one a dropped listener released, and checks each cause. Refs #2287. Assisted-by: Claude Code
`redact_url` collects the userinfo, the grant token and each secret query value of a URL and cuts them out in order. A value that is shown as one URL is whatever a project file holds, and when a `?` with a secret-named parameter comes before its `://` (`x?auth=https://u:p@h`) the userinfo lies inside the query value: the second cut started before the first one ended, and the slice panicked. `redact_urls_in` never hands it such text, so main reaches this only from callers that pass a setting whole. This branch added two: the Gradle wrapper's `distributionUrl` and the registry of the fallback warning. A span that starts inside an earlier one is now skipped, as the earlier one covers it. The fallback warning also names its registry with any query secret or grant token redacted, not only without its userinfo, so the cause cannot put one back. Refs #2287. Assisted-by: Claude Code
The spans of a text that is not a well-formed URL can overlap only in part: a userinfo or a grant token that runs past the end of a secret query value, or a query value that starts inside one. Skipping the later span left its tail in the output (`x?auth=https://user:PASS&WORD@h` kept `&WORD`). Overlapping spans are now cut together. Each of these inputs panicked before this branch. A JSON lookup redacts the URL it asked as the one URL it is, instead of scanning its own message for URLs, so a password that holds `)` or `'` is redacted there too. Its test uses such a password. The fallback warning's test asserts only after it has removed the variable it set. Refs #2287. Assisted-by: Claude Code
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
December 2, 2026 12:42
Collaborator
Author
|
bugbot run Generated by Claude Code |
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
Three messages name the `patchedDependencies` key of a `bun patch` made while the package resolved to its hosted tarball: the skip of a superseding hosted run, the refusal of a vendored takeover, and the rollback's note that the patch stops applying. The key is `<name>@<hosted URL>`, and the URL holds the grant token. Their tests pinned the key as written. The messages now go through the redacting constructors, so the token reads `<redacted>`; the name, the patch uuid and the file still say which entry is meant. The tests expect that form and check that the token is not printed. Refs #2287. Assisted-by: Claude Code
`rollback` and `remove` print the warnings of their hosted leg on stderr from the leg's own list and build the envelope's copy afterwards. The envelope's copy is redacted by its constructor; the stderr line was not, so a human run still printed the grant token in the key of a dropped `bun patch`, where `--json` showed `<redacted>`. `run_hosted_leg` now redacts its warnings once, where it finishes them, so both channels read the same. The test of that warning runs `rollback` and `remove` without `--json` as well. Refs #2287. Assisted-by: Claude Code
Mikola Lysenko (mikolalysenko)
pushed a commit
that referenced
this pull request
Dec 2, 2026
Wenxin Jiang (Wenxin-Jiang)
approved these changes
Dec 2, 2026
Tanmay Singla (Tanmay182003)
approved these changes
Dec 2, 2026
Mikola Lysenko (mikolalysenko)
deleted the
arch-refactor/2287-redact-quoted-lock-urls
branch
December 2, 2026 15:18
Mikola Lysenko (mikolalysenko)
pushed a commit
that referenced
this pull request
Dec 2, 2026
Brings in #2445, which changed `commands/vex.rs`, so that the omission phrase of a lock pin can be edited on its current text. Assisted-by: Claude Code
This was referenced Dec 2, 2026
Open
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.
LLM Description written by Claude Code
Fixes #2287.
Problem
A project's own files can hold a URL with a credential in it: a
yarn.lockblock keyed by a private git remote (git+https://x-access-token:<token>@github.com/…), aCargo.lockgit source, a requirements direct reference to a private mirror, a Poetry source, anuget.configsource, a Gradle wrapperdistributionUrl. When socket-patch refuses or skips such an entry it quotes the URL as written, so the token goes to the terminal, the CI log, the--jsondocument a pipeline stores, and the result of the in-memory hosted engine.utils/redact.rsstates the rule ("Every URL that reaches a human or a log … goes throughredact_urls_inorredact_urlfirst"), and vendor warnings have applied it in their constructor since #1026. Vendored refusals, hosted warnings,vex's notes and the refusals of the upstream restore had no such step, so each message that quotes a lock value was one more place to forget.It hurts anyone who runs
scan,get,vex,rollbackorremovein CI on a project that installs something from a private source.Evidence on
main(6280589)The new CLI tests, run against the binary built from
main: file-only projects that each hold the tokenS3CRETTOKEN0123456789in one URL, a wiremock patch API,scanandgetin both modes, andvex. 21 of 21 runs print the token.The eleven new unit tests of the constructors, with only the production lines put back to
main's text, all fail the same way. Three of them:On the branch the same 21 runs name each entry as
…https://<redacted>@github.com/acme/…and none prints the token.Fix
The text is redacted where it enters each message type, as
VendorWarning::newalready did, so a call site that quotes a lock value has nothing to remember:Cannot vendor …,[would-refuse],events[].error)vendor::common::refused, which every backend builds refusals withCannot restore …ofrollback,removeand a takeover)FormatResult::refusenuget.configsources and theuv.lock/pylock.tomlregistry of the issue's follow-upUpstreamClient::get_json_authorizedquotes the URL it asked throughredact_urlSOCKET_NPM_REGISTRY,SOCKET_PYPI_JSON_APIandSOCKET_PACKAGIST_URLwith credentialsWarning: …on stderr,warnings[].detail)RunWarning::newvex(Warning: …,warnings[].detail)note_warning, which built itsRunWarningby hand, now callsRunWarning::newrollbackandremove(Warning: …on stderr,warnings[])run_hosted_leg, once, where it finishes its list: both commands print stderr from that list before they build the envelopebun patchstops applying, whose key holds the hosted tarball's URL with its grant tokenwarnings[],projects[].redirect.warnings[])EngineWarning::newandhosted::render::rewrite_warnings_jsondistributionUrlThe vendor constructors and the new ones share one helper,
utils::redact::redact_message.A
RewriteWarningitself still holds the lock's own text: the engine matches it against lock keys (yarn_rewriter_named) and compares warnings for equality, so it is redacted where it is reported, not where it is built.Two crashes in the redactor, fixed here
Sending more project text through
utils/redact.rsreached two panics that are onmainfor the messages it already redacts. A run over 3,000,000 random strings:main's copy panics on 484,201 inputs ofredact_urls_in(shortesté://) and 16,761 ofredact_url(shortest?,key=://T@); the branch's on none.://. The scan for the scheme's start stepped one byte and then sliced inside the character. The first cut of this branch made it reachable from any scan of a Gradle build whose wrapper URL has such a character: exit 101 and no--jsondocument, wheremainexits 0.scheme_startnow steps over the whole character.?with a secret-named parameter before the://(x?auth=https://u:p@h). The userinfo then lies inside, or across the end of, a secret query value, and cutting the second span panicked. Overlapping spans are now cut as one.Each has a unit test that panics on
main's code.Deleted
The three
VendorOutcome::Refusedliterals of the npm flavor probe and the one the Maven backend rebuilt (they go throughrefused), theRunWarningliteral ofvex, and the inline copy of the redaction inVendorWarning::new.Behavior change
Message text only. In the messages above, the userinfo of a quoted URL, a Socket grant token and a secret query value read
<redacted>, as they already did in vendor warnings and download errors.One place where that shows in an existing contract of tests: three messages name the
patchedDependencieskey of abun patchmade on a hosted package (<name>@<hosted URL>), and three tests ofin_process_vendor_bun_takeoverpinned the key as written. The key now readsleft-pad@https://patch.socket.dev/patch/npm/left-pad/1.3.0/<redacted>/<uuid>/left-pad-1.3.0.tgz: the name, the patch uuid and the file still say which entry is meant. The tests expect that form and check that the token is not printed. Theupstream_registry_fallbackwarning names its registry as before (without userinfo), and now with a query secret or grant token redacted too. No code, exit status, JSON shape or file on disk changes.Risk
Low.
detailanderrorstrings are documented as human text. A script that matched the exact text of one of these messages, for a URL that held a credential, sees<redacted>in its place.Review
/code-review highran five times, by a subagent given the diff and the issue, with both binaries. Each finding was run before it was acted on.vex's discovery note still printed the token (note_warningbuilt its warning by hand)upstream_registry_fallbackspelled its registry two ways once the cause arrived redactedmain)or', and a URL nested in a querymain; filed #2448)slipped throughmain(a query secret with)in reqwest's own error text; a uuid-shaped package name after a Socket-served base)in_process_vendor_bun_takeover, a suite the local runs had left out, pinned abun patchkey with its grant tokenrollbackandremovestill printed that key on stderr, where--jsonwas now redactedrun_hosted_leg; the test runs both commands without--jsonrun_hosted_legnamesrollbackandremove, and the leg's two other callers (scan's unwind of a withdrawn pin,vendor --revert) get the same redaction. Not pushed, to keep the head CI ran onNot in this PR
)or', and the userinfo of a URL nested in a query #2448: the redactor's own gaps above. They are onmainfor every redacted message and need a change to how the end of a quoted URL is found.RunWarningandVendorOutcome::Refusedhave public fields. About fortyRunWarningliterals (most incommands/vendor.rs, which an open PR holds) and the(code, detail)pairs thatgetand the vendored legs print on stderr before they build a warning do not pass a constructor. No quoted URL was found in them by reading.CLI_CONTRACT.mdsays ofSOCKET_RUBYGEMS_URLthat credentials in it are "sent and never printed". That is now true of the npm, PyPI and Packagist mirror variables as well; the sentence can follow once the two open PRs that edit the contract land.Verification
Locally, as root in the sandbox. On 2041fa6, two small commits before the head:
cargo clippy --locked --workspace --all-features -- -D warnings): clean.scan,get,vex,cli,apply,rollback,remove,vendor,repair,update, the in-process redirect, vendor and rollback suites, the in-memory hosted suites and four e2e suites): 2,081 pass, 5 fail. The five are the write-failure tests that need a user root is not (in_process_redirect:partial_lockfile_write_failure_exits_1_and_writes_no_ledger,redirect_json_mode_write_failures_emit_error_envelope,vlt::scan_redirect_vlt_heal_invalidation_failure_warns;repair:repair_cleanup_failure_is_reported_in_json_and_silent_modes,repair_exits_zero_and_stays_quiet_when_lock_file_unremovable). They are the failures the routine's register lists for a root sandbox; they were not re-run onmainin this run, and they pass in CI.rollback,remove,scan,get,vex,in_process_vendor_bun_takeover, the three in-process rollback suites,remove_rollback_api_overrides).coverage (1)failed on the three tests above.bugbot runwith "Bugbot is paused — on-demand spend limit reached".Diff
git diff --stat origin/main: 24 files, +883 −64. Production: +103 −37 in 14 files. Tests: +780 −27.No
cfg(windows)orcfg(unix)code changed.Generated by Claude Code