Skip to content
Crypto Disclosed report Intermediate

libcurl WebSocket handshake accepts any Sec-WebSocket-Accept

libcurl's WebSocket client did not check the Sec-WebSocket-Accept value returned by the server, so any 101 response completed the upgrade. A spoofed or malicious intermediary could therefore finish the handshake without knowing the client's nonce and inject frames.

pwnie Follow

Originally disclosed on HackerOne

  • Disclosed after 31 hours

Summary: libcurl upgrades to WebSocket without validating Sec-WebSocket-Accept, allowing a spoofed 101 response to complete the handshake and inject frames; AI assistance was used to draft this report.

Steps to Reproduce:

  1. Clone and build curl from source: git clone --depth=1 https://github.com/curl/curl /tmp/curl && cd /tmp/curl && autoreconf -fi && ./configure --disable-shared --without-ssl --without-libpsl --disable-dependency-tracking && make -j4 && make -C docs/examples websocket.
  2. Run a TCP server that replies with a fixed wrong Sec-WebSocket-Accept value and a text frame, without reading the request (example: HTTP/1.1 101 Switching Protocols + Upgrade: websocket + Connection: Upgrade + Sec-WebSocket-Accept: WRONGKEY + a single WS text frame "hello").
  3. In another terminal, run the example client: /tmp/curl/docs/examples/websocket ws://127.0.0.1:9000/.
  4. Observe output like "ws: received TEXT frame 'hello'" even though the server used Sec-WebSocket-Accept: WRONGKEY; the client should have rejected the handshake but accepts it.

Impact: Handshake integrity is broken: a spoofed or malicious intermediary can complete the WebSocket upgrade without knowing the client’s nonce, enabling protocol confusion or data injection for libcurl-based WebSocket clients. This violates RFC 6455’s challenge-response protection and allows blind 101 responses to be accepted.

Impact

Look at original report impact

The original report as published on HackerOne, by pwnie. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The client skipped the RFC 6455 challenge-response check, accepting any Sec-WebSocket-Accept value instead of verifying it against the nonce it sent.

Impact

A spoofed or malicious intermediary could complete the WebSocket upgrade without knowing the client's nonce, enabling protocol confusion or data injection for libcurl-based clients.

What the attacker needed

Libcurl-based WebSocket client; attacker controls or intercepts the server

How it was found

  1. Build curl from source and the websocket example client.
  2. Run a TCP server that sends a 101 response with a wrong Sec-WebSocket-Accept value and a text frame.
  3. Run the example client against that server.
  4. See the client print the received text frame instead of rejecting the handshake.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program opens a WebSocket, the server must prove it saw a random value the client sent by returning a matching code. libcurl never compared the two, so a fake server or someone in the middle could pretend to be the real one. The client then accepted data from that party as if it were the genuine server.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by pwnie

View all

2 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.