Witnet Network Bug Bounty: DOS Bug from Harsh Jain
A node accepted many tiny handshake messages without closing the connection, so a malicious peer could flood it with messages and consume resources. The attacker could overload the node and prevent the handshake timeout from terminating the connection.
Published on medium.com
For those unaware, Witnet is a Decentralised Permissionless Oracle Network planning to release Mainnet in the middle of October this year. Currently they are doing regress testing and running a Testnet Incentive Program, including a Bug Bounty Program.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Witnet is a decentralised, permissionless oracle network that, at the time of this write-up, was preparing for a mainnet release in the middle of October. The project was running regression testing and a Testnet Incentive Program that included a bug bounty program.
A Witnet node joins the network by talking to its peers. To consolidate a connection, a new node exchanges VERSION and VERACK messages with a peer. If that exchange does not happen within the handshake timeout duration, another thread terminates the connection. Even if a message is erroneous, the connection stays live for at least the handshake timeout period.
Witnet nodes communicate using PROTOBUF encoded messages. The wire format is simple: the first four bytes give the length of the message, L, and the next L bytes are the actual message. The smallest possible message is therefore 4 bytes, 0x00000000, where zero is the length of the actual message.
Setup
The researcher had been running a Witnet node from the start of the testnet. Alongside operating the node, he read the code and studied how nodes communicate with each other. No special tooling, accounts or roles beyond a node on the testnet are described.
Finding it
While reading the handshake logic, the researcher noticed a mismatch between how long a connection lives and how much work a peer can force the node to do during that time. The connection is only torn down by a separate thread once the handshake timeout expires, and an erroneous message does not shorten that window: the connection remains live for at least the full timeout period.
That raised a question: if the number of messages can be increased by decreasing their individual size, a peer can overload the node with a large number of messages and even consume the resources of the thread that terminates the connection.
The PROTOBUF framing makes this possible. Because the four-byte length prefix is the whole of a minimal message, a peer can send 0x00000000 repeatedly, and each four-byte frame is a complete message with an empty body.
Exploitation
Step 1: Work out the message rate
The researcher calculated what a modest link could deliver. For 1 Mbps of data from a malicious node, peers receive around 32000 messages per second, since each message is 32 bits. That is a huge number of messages to process in one second.
Step 2: Keep the connection open with empty messages
By sending many minimal messages, the attacker keeps feeding the node work during the handshake window. The node requires substantial resources to process the flood, and the handshake timeout function is not called. The connection is not closed, and the node waits for the timeout duration before terminating it.

Step 3: Report it
The bug was raised because the connection was not closed and nodes would wait for the timeout duration before terminating it. It was responsibly disclosed on 31 July.
Root cause
Connection teardown is tied to a timeout handled by a separate thread, and the connection stays live for at least that period. A peer that never completes the VERSION/VERACK exchange but keeps sending validly framed messages forces the node to keep parsing them for the whole timeout window. Because the minimum message is only four bytes, a 1 Mbps link delivers around 32000 messages per second, a huge number to process in one second.
Impact
A malicious node can overload its peers with a large number of messages and consume the resources of the thread that terminates the connection. The team acknowledged the DOS possibility: peers can be overloaded with messages and the timeout thread's resources consumed, because the connection stays open until the handshake timeout expires. The report does not quantify the effect beyond resource consumption on the node and the timeout thread.
Fix
The Witnet team acknowledged the DOS possibility and fixed it within a week. The fix is in pull request 1444 of the witnet-rust repository:
https://github.com/witnet/witnet-rust/pull/1444
The report does not describe the contents of the change.
Variants to test
- Length-prefixed protocols with a tiny minimum frame. Send the smallest valid frame repeatedly during a handshake or session setup and watch CPU and memory on the peer. A positive result is sustained resource use that scales with bandwidth rather than with any message-count limit.
- Handshake windows enforced only by timeout. Open a connection, never complete the handshake, and keep sending valid frames. A positive result is a connection that stays alive for the full timeout while the peer keeps processing every frame.
- Zero-length payloads. Where a protocol allows a zero-length body, check whether empty messages are counted, rate-limited or dropped. A positive result is empty messages being parsed at full speed with no throttling.
- Teardown thread starvation. Flood a node during the timeout window and observe whether the connection is closed on schedule. A positive result is a teardown that is delayed or missed because the terminating thread cannot keep up.
What happened, in plain words
Witnet is a network of computers that work together to provide information to other software, without any single company in charge. At the time of this write-up, the project was getting ready to launch its main network in the middle of October. While preparing, the team was running tests and a programme that paid people for finding problems, called a bug bounty programme.
A computer that joins this network is called a node. Before two nodes can talk properly, they introduce themselves by swapping two short messages, VERSION and VERACK. This introduction is called a handshake, much like two people saying hello before a conversation. If the introduction does not finish within a set time, called the handshake timeout, a separate part of the program (a thread) closes the connection.
The researcher, Harsh Jain, had been running a Witnet node since the test network started. He also read the code and watched how nodes talked to each other. Even an erroneous message keeps the connection alive for at least the full timeout period. That gave him an idea: if you make each message as small as possible, you can send a huge number of them in that window, and the node has to deal with every one.
Witnet nodes send messages in a format called PROTOBUF. Each message starts with four bytes that say how long the real message is, and then the real message follows. The smallest possible message is therefore just four bytes, 0x00000000, where the zero means the real message is empty.
At a modest connection speed of 1 Mbps, a malicious node can deliver around 32000 of these tiny messages every second. That is an enormous amount of work for the receiving node in one second, and the handshake timeout function is not called. The connection stays open, and the node waits out the whole timeout before ending it.
This is a denial of service bug: an attacker does not steal data or break in, but makes a service so busy that it cannot do its normal job. The researcher reported it responsibly on 31 July. The team acknowledged the DOS possibility and fixed it within a week.
Background: what Witnet is and how nodes greet each other
Witnet describes itself as a decentralised, permissionless oracle network. An oracle is a service that feeds real-world information, such as prices or weather, into software that cannot fetch it itself. Decentralised means no single company runs it; many independent computers take part. Permissionless means anyone can join without asking for approval.
Each of those computers is a node. When a new node wants to join, it talks to other nodes, called peers. To settle a connection, the two sides exchange two messages:
- VERSION: roughly "hello, here is who I am and what I speak".
- VERACK: roughly "acknowledged, I heard you".
This back-and-forth is the handshake. If it does not complete within a fixed time, the handshake timeout, a separate thread closes the connection. A thread is one line of work inside a program; a program can run several at once, like several shop assistants serving different customers. The important detail here is that even an erroneous message does not shorten that window: the connection stays live for at least the full timeout period.
How the messages are packaged
Witnet nodes use PROTOBUF encoded messages. Protobuf is a way of packing data into a compact binary form so that two programs can exchange it efficiently. On the wire, the format is simple:
- The first four bytes give the length of the message, called L.
- The next L bytes are the actual message.
So the smallest possible message is four bytes long: 0x00000000. The four bytes say the real message has length zero, and there is nothing after them. In computing, a byte is a small unit of data, and 0x at the start is simply a way of writing numbers in hexadecimal, a base-16 counting system often used for raw data.
How the researcher found it
He had been running a Witnet node from the start of the test network. Alongside operating it, he read the code and studied how nodes communicate. No special tools, accounts or roles beyond a node on the test network are described.
While reading the handshake logic, he spotted a mismatch. On one side, a connection lives until the handshake timeout expires, and only a separate thread ends it. On the other side, the node keeps processing whatever messages arrive during that time. An erroneous message does not shorten the window, so the connection remains live for at least the full timeout period.
That led to a question: if the number of messages can be increased by decreasing their individual size, a peer can overload the node with a large number of messages and even consume the resources of the thread that terminates the connection.
The message format makes this possible. Because the four-byte length prefix is the whole of a minimal message, a peer can send 0x00000000 over and over, and each frame is a complete message with an empty body.
Step by step: how the attack works
Step 1: Work out the message rate
The researcher calculated what a modest link could deliver. For 1 Mbps of data from a malicious node, peers receive around 32000 messages per second, since each message is 32 bits. A bit is the smallest unit of data, a 0 or a 1, and Mbps means megabits per second, a common measure of connection speed. Thirty-two thousand messages in one second is a huge number to process.
Step 2: Keep the connection open with empty messages
By sending many minimal messages, the attacker keeps feeding the node work during the handshake window. The node needs substantial resources to process the flood, and the handshake timeout function is not called. The connection is not closed, and the node waits for the timeout duration before terminating it.
0x00000000
This is the smallest possible message: four bytes of length information saying the real message is empty. Sent once, it is harmless. Sent tens of thousands of times per second, it becomes a flood of work.

Step 3: Report it
The bug was raised because the connection was not closed and nodes would wait for the timeout duration before terminating it. It was responsibly disclosed on 31 July. Responsible disclosure means telling the vendor privately first, giving them time to fix the problem before it becomes public.
Why it worked
Connection teardown is tied to a timeout handled by a separate thread, and the connection stays live for at least that period. A peer that never completes the VERSION/VERACK exchange but keeps sending validly framed messages forces the node to keep parsing them for the whole timeout window.
Because the minimum message is only four bytes, a 1 Mbps link delivers around 32000 messages per second. A small amount of traffic therefore translates into a very large amount of parsing work.
A useful comparison is a shop with a single security guard who checks every customer at the door. The guard is told to close the shop if nobody has bought anything within ten minutes. An attacker walks in and out of the door thousands of times a minute, forcing the guard to check them each time. The guard is so busy that the ten-minute rule never gets a chance to run.
What the impact was
A malicious node can overload its peers with a large number of messages and consume the resources of the thread that terminates the connection. The team acknowledged the DOS possibility: peers can be overloaded with messages and the timeout thread's resources consumed, because the connection stays open until the handshake timeout expires. The report does not quantify the effect beyond resource consumption on the node and the timeout thread.
The fix
The Witnet team acknowledged the DOS possibility and fixed it within a week. The fix is in pull request 1444 of the witnet-rust repository:
https://github.com/witnet/witnet-rust/pull/1444
A pull request is a proposed change to a code repository, which the maintainers review before merging. The report does not describe the contents of the change.
Similar things to test
If you are learning to look for this kind of bug, here are four variations worth trying. Each one follows the same idea: find a place where a small amount of input causes a large amount of work.
- Length-prefixed protocols with a tiny minimum frame. Send the smallest valid frame repeatedly during a handshake or session setup and watch CPU and memory on the peer. A positive result is sustained resource use that scales with bandwidth rather than with any message-count limit.
- Handshake windows enforced only by timeout. Open a connection, never complete the handshake, and keep sending valid frames. A positive result is a connection that stays alive for the full timeout while the peer keeps processing every frame.
- Zero-length payloads. Where a protocol allows a zero-length body, check whether empty messages are counted, rate-limited or dropped. A positive result is empty messages being parsed at full speed with no throttling.
- Teardown thread starvation. Flood a node during the timeout window and observe whether the connection is closed on schedule. A positive result is a teardown that is delayed or missed because the terminating thread cannot keep up.
Glossary
- Node: a computer that takes part in a network, here a Witnet node that talks to other nodes.
- Peer: another node that your node is connected to and exchanges messages with.
- Oracle network: a service that supplies real-world data to software, run by many independent computers rather than one company.
- Decentralised: run by many participants with no single central authority.
- Permissionless: open to anyone to join without needing approval.
- Mainnet: the live, production version of a blockchain network, as opposed to a test network.
- Testnet: a test version of a network used for experiments and bug hunting before launch.
- Bug bounty programme: a scheme that pays people for finding and reporting security problems.
- Handshake: the opening exchange where two computers introduce themselves and agree to talk.
- VERSION / VERACK: the two messages exchanged during the Witnet handshake, roughly "hello" and "acknowledged".
- Handshake timeout: the fixed time within which the handshake must finish, after which the connection is closed.
- Thread: one line of work inside a program; several can run at once.
- PROTOBUF: a compact binary format for encoding messages between programs.
- Byte: a small unit of data, usually eight bits.
- Bit: the smallest unit of data, a 0 or a 1.
- Mbps: megabits per second, a measure of connection speed.
- Hexadecimal: a base-16 way of writing numbers, often used for raw data and written with a
0xprefix. - Length prefix: the leading part of a message that states how long the rest of the message is.
- Frame: one complete unit of data as it travels over a connection.
- Payload: the actual content of a message, as opposed to its packaging.
- Parsing: reading and interpreting incoming data so the program can act on it.
- Rate limit: a cap on how many messages or requests are accepted in a given time.
- Denial of service (DoS): an attack that makes a service too busy to work properly, without stealing data or breaking in.
- Resource consumption: the CPU, memory and other capacity a program uses to do its work.
- Thread starvation: when one thread is so busy that it cannot do its scheduled job, such as closing a connection on time.
- Responsible disclosure: reporting a security problem privately to the vendor first, so it can be fixed before it becomes public.
- Pull request: a proposed change to a code repository that maintainers review before merging.
- Repository: a storage location for a project's code and its history.
- Regression testing: re-running tests to make sure recent changes have not broken anything that used to work.