java-topology/whitepaper/outreach/netty-0001.md
russell@unturf.com 652608142a feat: close outreach doc gap — 276 docs (batches 11-16)
All projects with patches now have outreach docs. 276 new docs covering
CWE-407, CWE-312, CWE-362 across C, C++, Java, Python, Go, Rust, C#,
PHP, Ruby, JavaScript, Dart, Erlang, R, and more.

Outreach gap: 276 -> 0.
2026-04-15 13:57:42 -04:00

2.4 KiB
Raw Permalink Blame History

Netty — CWE-407 Disclosure Brief (netty-0001 ALPN)

2026-04-13 · Patch available — awaiting upstream merge

Finding

One O(S × P) defect in Netty's ALPN protocol negotiation. Patched. JdkBaseApplicationProtocolNegotiator uses List.contains() for protocol matching during TLS handshakes.

The Defect

netty-0001 (PATCHED — MEDIUM): handler/src/main/java/io/netty/handler/ssl/JdkBaseApplicationProtocolNegotiator.java:144

// In NoFailProtocolSelector.select() — fires per TLS handshake:
public String select(List<String> protocols) throws Exception {
    for (String p : supportedProtocols) {
        if (protocols.contains(p)) {  // O(P) linear scan per supported protocol
            return p;
        }
    }
}

// In NoFailProtocolSelectionListener.selected() — fires per TLS handshake:
if (supportedProtocols.contains(protocol)) {  // O(S) linear scan

protocols is List<String>. contains() is O(P). With S supported protocols and P offered protocols, select() costs O(S × P) per handshake. selected() costs O(S) per handshake.

Complexity Proof

At S=10 supported, P=10 offered protocols:

  • Defective: 10 × 10 = 100 string comparisons per handshake
  • Fixed: 10 × O(1) = 10 HashSet lookups per handshake
  • 10× op reduction per TLS handshake.

Impact

Netty is the most widely used Java networking framework. ALPN negotiation fires on every TLS handshake. High-traffic HTTPS servers process millions of handshakes per day. While the absolute per-handshake cost is small, it compounds at scale.

The Fix

Convert List<String> to HashSet<String> for O(1) lookup:

// Before
if (protocols.contains(p)) {  // O(P)

// After
Set<String> protocolSet = new HashSet<>(protocols);
if (protocolSet.contains(p)) {  // O(1)

Patch

Fix available: defects/netty-0001/patch/netty-0001-alpn-list-contains.patch

Touches JdkBaseApplicationProtocolNegotiator.java. 10× speedup per TLS handshake.

What We Ask

A patch is ready for review.

  1. Confirm receipt and assign a GitHub issue reference (netty/netty).
  2. Assess severity — fires on every TLS handshake with ALPN negotiation.
  3. Coordinate a disclosure date — we are targeting 90 days from first contact.
  4. We will credit the Netty team in the public disclosure. Preferred acknowledgment format welcome.

Contact: see cover email. This brief is confidential until coordinated disclosure.