Enrolling to a CA that returns an empty response crashes the node process
When a certificate authority server returns an empty response during enrollment, the SDK throws an exception inside an event emitter that the calling application cannot catch. An attacker running a malicious CA could therefore crash any Node process using the SDK, denying service to other users.
- Triaged in 25 days
- Fixed in 57 days
- Paid in 41 days
- Disclosed after 3.4 years
If a CA server responds with an empty response during enrollment, an exception is thrown in the event emitter on end. This is an uncaughtException and causes the containing node process to exit.
To replicate:
With the attached files, run:
npm install
node badCa.js &
node index.js
This starts a simple malicious CA server that provides a response that triggers the exception. The index.js script tries 2 different scenarios:
-
- With a known bad URL, which throws an exception which can be caught by the client application
-
- With a malicious CA, which throws an exception which cannot be caught by the client application because of the EventEmitted behaviour in node.
From https://nodejs.org/api/events.html#events_error_events If an EventEmitter does not have at least one listener registered for the 'error' event, and an 'error' event is emitted, the error is thrown, a stack trace is printed, and the Node.js process exits.
Fix
Replace https://github.com/hyperledger/fabric-sdk-node/blob/c10865cfb20d063fdef4c7d96c25c1581f309e84/fabric-ca-client/lib/FabricCAClient.js#L457
util.format('Enrollment failed with HTTP status code', JSON.parse(data).statusCode)));
with
util.format('Enrollment failed with HTTP status code', response.statusCode)));
The same issue is present at https://github.com/hyperledger/fabric-sdk-node/blob/0d24cec10f7a3e0153fcf3f0158a89c5eaa0cfab/fabric-ca-client/lib/FabricCAClient.js#L318
Impact
This attack allows an attacker to cause any node client application using the fabric-ca-node SDK to exit. In scenarios where the SDK is used in a server-side application, this will have the effect of denying the use of that server to other users.
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
Likely the error handler parses the response body with JSON.parse without checking that the body is non-empty, and the resulting exception is raised inside an event emitter with no error listener.
Impact
An attacker can cause any node client application using the fabric-ca-node SDK to exit, and in server-side use this denies the service to other users.
What the attacker needed
Attacker controls or spoofs the CA server; client uses the fabric-ca-node SDK
The fix
The error message should use the response status code rather than parsing the empty body, and the same correction should be applied at the second location.
How it was found
- Install the dependencies for the sample project.
- Start the malicious CA server script in the background.
- Run the client script that attempts enrollment against the malicious CA.
- Observe that the exception cannot be caught and the node process exits.
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.
A program that talks to a certificate authority (a server that issues digital certificates) expects a reply. If the reply is empty, the library tries to read data that is not there and crashes. Because the crash happens in a background event handler, the surrounding application cannot catch it, so the whole process stops.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.