Visitar URL original
build: enable safe CA search by default (Windows) by vszakats · Pull Request #23277 · curl/curl · GitHub
Skip to content

build: enable safe CA search by default (Windows) - #23277

Open
vszakats wants to merge 17 commits into
curl:masterfrom
vszakats:safe-ca
Open

vszakats wants to merge 17 commits into
curl:masterfrom
vszakats:safe-ca

Conversation

@vszakats

@vszakats vszakats commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Previous default was to search for a CA bundle (curl-ca-bundle.crt) in
a list of directories, including CWD and PATH, which allowed an
attacker to place a CA bundle there and the curl tool picking it up.
(Unless Native CA was enabled at build time, which disables on-disk CA
bundle searches by default.)

Change the default to search for a CA bundle in the curl tool directory
only.

Note: This is a breaking change for curl builds using a non-Schannel TLS
backend, with Native CA and embedded CA disabled and with a
curl-ca-bundle.crt CA bundle file missing from the directory of
curl.exe. To remedy, copy or download a valid CA bundle into the
curl.exe directory.

To keep old (insecure) behavior, build curl with:

  • autotools: --disable-ca-search-safe
  • cmake: -DCURL_CA_SEARCH_SAFE=OFF

Safe alternatives are Native CA, embedded CA, or Schannel if the
use-case allows.

Also:

  • make sure to disable safe search option by default if native CA is
    enabled. To keep existing behavior.
  • drop the option to enable safe search for Windows UWP builds.
    To keep existing behavior of not doing on-disk search, and to
    simplify.
  • remove disable-CA-search option for UWP builds. It's a no op,
    (unsafe) search is not supported on UWP because the necessary Win32
    API (SearchPath()) is not provided by the OS.

Reported-by: Joshua Rogers
Follow-up to 22652a5 #14582


https://github.com/curl/curl/pull/23277/files?w=1

curl-for-win has been shipping with CA bundle embedded since 8.10.0
(2024-09-11). It first did an unsafe search, and if not found a CA
bundle fell back to the embedded one. Since 8.19.0 (2026-03-11)
curl-for-win ships with Native CA and on-disk CA search disabled.
It also had safe CA search enabled in daily builds since 8.10.0-dev.

  • maybe add Unicode support to tool_execpath()? or keep disabled
    in Unicode builds (which would be a shame IMO).
  • perhaps break out the tool_execpath() patch into a separate PR. → tool_util: add Unicode support to tool_execpath() #23287
  • rebase on tool_util: add Unicode support to tool_execpath() #23287.
  • maybe keep safe search disabled for UWP, where the pre-existing
    behavior was: no search (because the necessary Win32 API is
    not available for UWP). Kind of corner or corner case, there seems
    to be almost (?) nobody using UWP, and especially nobody using
    the curl tool in UWP mode.

@vszakats vszakats added TLS Windows Windows-specific labels Oct 6, 2026
@github-actions github-actions Bot added build CI Continuous Integration labels Oct 6, 2026
@jay

jay commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

In my opinion this isn't a vulnerability in curl and limiting the search path by default is likely to break some scripts using the documented behavior. --cacert currently says:

(Windows) curl automatically looks for a CA certs file named 'curl-ca-bundle.crt', either in the same directory as curl.exe, or in the Current Working Directory, or in any folder along your PATH.

That and the next paragraph explaining the build option would need to be updated to explain it is now limited by default. I'm not really against this but not really for it either.

edit: also you will need to update this section in SSLCERTS

This comment was marked as outdated.

vszakats added a commit to vszakats/curl that referenced this pull request Oct 6, 2026
@vszakats
vszakats force-pushed the safe-ca branch 2 times, most recently from daf3e91 to 5faace5 Compare October 6, 2026 10:34
@vszakats
vszakats requested a balanced review from Copilot October 6, 2026 11:03

This comment was marked as outdated.

@vszakats
vszakats requested a balanced review from Copilot October 6, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as low quality.

vszakats added a commit to vszakats/curl that referenced this pull request Oct 6, 2026
To fix opening `.curlrc`/`_curlrc` next to the curl tool, and to make
the CA safe search built-time option work as expected when the curl tool
resides on a non-ASCII path.

Follow-up to d40f4e1
Follow-up to 78882e4

Cherry-picked from curl#23277
vszakats added a commit that referenced this pull request Oct 6, 2026
To fix opening `.curlrc`/`_curlrc` next to the curl tool, and to make
the CA safe search built-time option find `curl-ca-bundle.crt` as
expected when the curl tool resides on a non-ASCII path when using
a Unicode-enabled build.

The CA safe search build-time option is disabled by default. The issue
has been discovered while working on enabling it by default.

Follow-up to d40f4e1
Follow-up to 78882e4

Cherry-picked from #23277

Closes #23287
MegaManSec and others added 17 commits October 6, 2026 22:50
CURL_CA_NATIVE defaults OFF, so CURL_DISABLE_CA_SEARCH also defaults
OFF, and CURL_CA_SEARCH_SAFE previously defaulted OFF too. That left
the unsafe curl-ca-bundle.crt lookup via SearchPath() (application
directory, CWD, Windows directories, then every %PATH% entry) enabled
by default in Windows CMake builds. A local attacker able to place
curl-ca-bundle.crt in the current directory or an earlier
attacker-writable PATH directory could get an ordinary curl
invocation to trust an attacker-controlled root CA.

Default CURL_CA_SEARCH_SAFE to ON so the existing safe search (limited
to the curl tool's own directory) is used unless a user explicitly
opts back into the legacy CWD/PATH search with
-DCURL_CA_SEARCH_SAFE=OFF.

Reported-by: Joshua Rogers
Native Windows builds enabled the unsafe SearchPath()-based CA bundle
discovery by default, unless the native CA store was requested with
--enable-ca-native. SearchPath() checks the application directory and
the current working directory before the Windows system directories
and %PATH%, so a local attacker able to place curl-ca-bundle.crt in a
victim's current directory, or an earlier %PATH% entry, could make
curl trust an attacker-controlled root CA without --cacert or
--insecure ever being used.

Default --enable-ca-search-safe to on, so the tool directory only
search (CURL_CA_SEARCH_SAFE) is used unless a builder opts out with
--disable-ca-search-safe. This takes precedence over the unsafe
CWD/PATH search regardless of --enable-ca-search, so the old default
behavior now requires an explicit --disable-ca-search-safe.

Reported-by: Joshua Rogers

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No blocking issues were identified; only a minor documentation clarification remains.

Review effort: Lite
Findings: None

Resolved since last review (1)

@vszakats

vszakats commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

I addressed the missing documentation updates. Also fixed a worker function
used in safe-search codepath that lacked Unicode support (#23287). Ironed
out legit UWP concerns raised by the LLM, and fixed to not enable safe-search
by default if Native CA is enabled.

@jay

jay commented Oct 11, 2026

Copy link
Copy Markdown
Member

This is another one I suggest wait until the next feature window.

@vszakats

vszakats commented Oct 11, 2026 •

Copy link
Copy Markdown
Member Author

This is another one I suggest wait until the next feature window.

Agree, this one is definitely for the next cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build CI Continuous Integration cmdline tool TLS Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

4 participants