Skip to content

tls: avoid mutable push in checkServerIdentity - #67899

Open
rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:tls-check-identity-no-push
Open

rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:tls-check-identity-no-push

Conversation

@rozzilla

Copy link
Copy Markdown
Contributor

tls.checkServerIdentity() collects the certificate's DNS names and IP
addresses with .push() on private arrays, so replacing
Array.prototype.push changes the hostname check. This uses indexed
assignments instead and adds a test case for a branch no test reached.

Partial: the arrays are still read with .forEach(), .includes(),
.some() and .join().

Same approach as #67748, #67751 and #67752.

checkServerIdentity() and its alt name splitter collected the
certificate's DNS names and IP addresses with .push() on private
arrays, which looks up Array.prototype.push at call time. Replacing
that method from user code changed which names the hostname check
saw. Use indexed assignments instead.

Add a test case for an escaped alt name that follows an unescaped
one, a path no existing test reached.

Assisted-by: Claude Code
Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. tls Issues and PRs related to the tls subsystem. labels Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.57%. Comparing base (91f8170) to head (59262de).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67899      +/-   ##
==========================================
- Coverage   90.58%   90.57%   -0.02%     
==========================================
  Files         802      802              
  Lines      286659   286659              
  Branches    55370    55373       +3     
==========================================
- Hits       259676   259643      -33     
- Misses      17083    17128      +45     
+ Partials     9900     9888      -12     
Files with missing lines Coverage Δ
lib/tls.js 95.18% <100.00%> (+1.06%) ⬆️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

needs-ci PRs that need a full CI run. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants