Skip to content

fix(javascript): omit TLS sockets whose secureProtocol Node rejects - #10530

Open
Plastic-time wants to merge 5 commits into
morluto:mainfrom
Plastic-time:rrfz/omit-tls-secure-protocol-refusals
Open

Plastic-time wants to merge 5 commits into
morluto:mainfrom
Plastic-time:rrfz/omit-tls-secure-protocol-refusals

Conversation

@Plastic-time

@Plastic-time Plastic-time commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

JavaScript static analysis reported a socket acquisition for tls.connect calls that Node rejects because of secureProtocol. These calls no longer produce a resourceOperations acquisition, the same as a rejected minVersion.

Fixes #10524

Problem and expected behavior

Measured in Node 24.22.1 with tls.connect({ port: 9, host: "127.0.0.1", ... }):

Options Result
secureProtocol "TLS_method", "TLSv1_method", "TLSv1_1_method", "TLSv1_2_method", "SSLv23_method", and their _client/_server forms socket
secureProtocol "bogus", "", "SSLv3_method", "SSLv2_method", "TLSv1_3_method", "DTLS_method", "tls_method", "TLS_METHOD" ERR_TLS_INVALID_PROTOCOL_METHOD
secureProtocol 5, true, {}, null alone socket (only strings are checked)
truthy secureProtocol beside a minVersion or maxVersion that is not null or undefined ERR_TLS_PROTOCOL_VERSION_CONFLICT
"TLS_method" beside minVersion: null or maxVersion: undefined; 0 beside a minVersion socket
any of these with a truthy secureContext socket
net.connect({ secureProtocol: "bogus" }) socket

Change and scope

  • rejectsTlsProtocolVersionLiteral now ends with rejectsSecureProtocolLiteral, which reads secureProtocol through the same effective reader. That reader already handles merged option objects, accessors, __proto__ and the truthy-secureContext bypass.
  • The accepted names are a closed, case-sensitive set, like TLS_PROTOCOL_VERSIONS.
  • The conflict rule needs a proven truthy secureProtocol and a version member proven to be neither null nor undefined. Unknown values stay.

Contribution scope: ordinary fix within existing boundaries; maintainer scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: rejectsTlsProtocolVersionLiteral in javascriptSemanticResources.ts.

  • Contribution scope fit and linked maintainer decision: not applicable.

  • CLI and MCP/tool-catalog contract: none.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: fewer false socket facts; undecided calls are unchanged.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added: src/domain/javascript/javascriptSemanticAnalysis.tls_secure_protocol_literal.test.ts, one row per rejected and accepted form above.
  • Base reproduction: the new file on main source: 13 failed / 14 passed. With this change: 27 passed.
  • The existing tls_protocol_version_literal tests still pass (128 passed for both files).

Validation performed

Windows 11 Home 10.0.26200 x64, Node 24.22.1, base 9e24b36.

  • npx vitest run src/domain/javascript/javascriptSemanticAnalysis.tls_secure_protocol_literal.test.ts on main source: 13 failed / 14 passed; with this change: 27 passed.
  • npx vitest run src/domain/javascript src/application/javascript: 217 files, 6409 passed / 7 skipped.
  • Review follow-up (d131e32): an exactly read method name, including a no-substitution template, decides its own truthiness, so secureProtocol: `TLS_method` beside a version member reaches the conflict check.
  • Merged main fe80d52 in c6ad59c. Main's 91297ca moved the option reading into the shared socketOptionReader; the only conflict was a doc comment, and rejectsSecureProtocolLiteral reads through the same reader. After the merge: the new file on main source 13 failed / 14 passed, with this change 27 passed; src/domain/javascript src/application/javascript 218 files, 6502 passed / 7 skipped.
  • Review follow-up (0beb435): the shared staticJavaScriptTruthiness reader now decides a regular-expression literal and a class expression as truthy, so secureProtocol: /x/ or class {} beside a version member reaches the conflict check. The new file now has 29 rows, all passing; src/domain and src/application show no new failures.
  • npm run check:fast: passed (typecheck, lint)
  • git merge-tree against the open PRs that edit javascriptSemanticResources.ts: clean with every one that merges cleanly with main (fix(javascript): judge an options-object socket port like a positional one #9693, fix(javascript): resolve FileHandle releases after reassignment #10258, fix(js): degrade release resolution when the released method is replaced on the receiver #10473).

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Node 24.22.1 on Windows 11. The method-name list comes from Node's bundled OpenSSL; Linux was not measured.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: analysis only; the measurements targeted 127.0.0.1:9.

Author readiness

Human owner: @Plastic-time

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

tls.connect builds its secure context before it opens a socket. A string
secureProtocol outside Node's method names throws
ERR_TLS_INVALID_PROTOCOL_METHOD, and a truthy secureProtocol beside a
minVersion or maxVersion throws ERR_TLS_PROTOCOL_VERSION_CONFLICT. Apply
the same secureContext bypass as the version members.
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

The PR stops reporting socket acquisitions for tls.connect calls that Node rejects because of secureProtocol.

  • TLS socket analysis skips calls that Node rejects before opening a socket.

Reviews (4) · Last reviewed commit: "fix(javascript): treat class and regular..." · Reviewed by Greptile

@Plastic-time
Plastic-time marked this pull request as ready for review November 14, 2026 11:42
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T11:42:43.509937Z
We couldn’t complete this review. Comment @codex review to try again.
d1af1c1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

…ts text

A no-substitution template is read exactly, so a template method name beside
a version member now reaches the conflict check.
…protocol-refusals

# Conflicts:
#	src/domain/javascript/javascriptSemanticResources.ts
Both evaluate to a fresh object, so the shared truthiness reader can decide
them like object, array and function literals. A secureProtocol written as
/x/ or class {} beside a version member now reaches the conflict check.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] JavaScript analysis reports TLS sockets whose secureProtocol Node rejects

1 participant