Skip to content

quic: crash when incoming unidirectional stream has no onstream handler #64030

@efekrskl

Description

@efekrskl

When a QUIC server accepts a session without .onstream, and the client connects with a unidirectional stream with a body, Node crashes with SIGSEGV

If I use a bidirectional stream instead, it works. If I create the unidirectional stream without a body, it also does not crash.

Expected behaviour would be to safely destroy or at least not crash.

Repro:

import {readFileSync} from 'node:fs';
import {createPrivateKey} from 'node:crypto';
import {listen, connect} from 'node:quic';

const key = createPrivateKey(readFileSync(new URL('./key.pem', import.meta.url)));
const cert = readFileSync(new URL('./cert.pem', import.meta.url));

const serverEndpoint = await listen(async (session) => {
  await session.opened;
  console.log('Server session opened');

  // Intentionally do not install .onstream
}, {
  sni: {'*': {keys: [key], certs: [cert]}},
  alpn: ['repro'],
});

const clientSession = await connect(serverEndpoint.address, {
  servername: 'localhost',
  alpn: 'repro',
  ca: cert,
});

await clientSession.opened;
console.log('Client session opened');

await clientSession.createUnidirectionalStream({
  body: 'something something darkside'
});

console.log('Unidirectional stream created');

Outputs

(node:99156) ExperimentalWarning: quic is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Client session opened
Unidirectional stream created
Server session opened
(node:99156) Warning: A new stream was received but no onstream callback was provided
(node:99156) Warning: A new stream was received but no onstream callback was provided
(node:99156) Warning: A new stream was received but no onstream callback was provided
fish: Job 1, './out/Release/node --experiment…' terminated by signal SIGSEGV (Address boundary error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    quicIssues and PRs related to the QUIC implementation / HTTP/3.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions