Skip to content

CURLOPT_INTERFACE fix connection reuse match - #23326

Closed
icing wants to merge 3 commits into
curl:masterfrom
icing:opt_interface-conn-match
Closed

icing wants to merge 3 commits into
curl:masterfrom
icing:opt_interface-conn-match

Conversation

@icing

@icing icing commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Remember the full option string at the connection for use in reuse matching and cf-socket binding.

Parse the string when set for syntax check, but remember the unparsed version and use that in connection matching. For connection reuse, interface options must full match (both ways).

Parse that string again when the socket is set up.

icing added 2 commits October 9, 2026 09:51
Remember the full option string at the connection for use
in reuse matching and cf-socket binding.

Parse the string when set for syntax check, but remember
the unparsed version and use that in connection matching.

Parse that string again when the socket is set up.
@icing
icing requested a review from bagder October 9, 2026 08:18
@bagder
bagder requested a balanced review from Copilot October 9, 2026 08:37

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.

🟡 Changes recommended

The new early return disables CURLOPT_LOCALPORT binding when no interface is configured.

2 open findings
What changed in this PR

Updates CURLOPT_INTERFACE handling so connection reuse compares the complete option string and socket binding parses it when needed.

Changes:

  • Stores the original interface option on connections.
  • Requires exact interface matches for reuse.
  • Defers interface parsing until socket binding.
File Description
lib/​urldata.h Consolidates interface option storage.
lib/​url.c Updates connection allocation, cleanup, and reuse matching.
lib/​setopt.c Validates and stores the original option string.
lib/​cf-socket.c Supports validation-only parsing and deferred binding parsing.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/cf-socket.c Resolved
Comment thread lib/url.c Resolved
- conn match: localportrange only takes effect when localport is set
- cf-socket: do not early exit out when no interface_op is set
@icing
icing requested a review from bagder October 9, 2026 09:17
@bagder bagder closed this in d37d79d Oct 9, 2026
dkarpov1970 pushed a commit to dkarpov1970/curl that referenced this pull request Nov 18, 2026
Remember the full option string at the connection for use in reuse
matching and cf-socket binding.

Parse the string when set for syntax check, but remember the unparsed
version and use that in connection matching.

Parse that string again when the socket is set up.

Closes curl#23326

Backport notes:

- CVE-2026-107929 (local interface connection reuse mixup): the
  matching change is kept whole.

- The release lacks CURL_EASY_STR_SET() (c8df3de). CURLOPT_INTERFACE
  still parses into STRING_DEVICE, STRING_INTERFACE and
  STRING_BINDHOST, and also keeps the raw string in the new
  STRING_INTERFACE_OPT, which conn->interface_opts holds and
  url_match_connect_config() compares.

- Dropped the lib/cf-socket.c change: the release binds from the
  strings setopt already parsed.

(cherry picked from commit d37d79d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants