Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Unformatted JSON-RPC request crashes the application #6026

Closed
nazarhussain opened this issue Nov 25, 2020 · 0 comments · Fixed by #6029
Closed

Unformatted JSON-RPC request crashes the application #6026

nazarhussain opened this issue Nov 25, 2020 · 0 comments · Fixed by #6029
Assignees
Milestone

Comments

@nazarhussain
Copy link
Contributor

Expected behavior

If application receive unformatted or invalid JSON format request as JSON-RPC request. It should validate, show the error and keep running.

Actual behavior

If application receives a request which is invalid JSON then it crashes with below error.

15:40:35 FATAL lisk-framework: System error: unhandledRejection (module=lisk:app)
Message: Unexpected end of JSON input
 Trace: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Function.fromJSONRPCRequest (~/.config/yarn/global/node_modules/lisk-framework/dist-node/controller/action.js:15:72)
    at ~/.config/yarn/global/node_modules/lisk-framework/dist-node/controller/bus.js:206:54
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
15:40:35 INFO lisk-framework: Application shutdown started (module=lisk:app)
{
 "errorCode": 1,
 "message": "Unexpected end of JSON input"
}

The root cause of the issue is following code.

https://github.com/LiskHQ/lisk-sdk/blob/7c8644c8bdbfa84c2f14d1a658accb8cf46bb981/framework/src/controller/action.ts#L58

The same can be produced with an event as well. But since application don't receive external notifications so its safe. But application is accepting external action invocation calls so this issue can crash any application.

Steps to reproduce

  • Run the lisk-core with command lisk-core start --network devnet --api-ws
  • Or you can use any other application as well
  • Use this command to install a command line utility brew install websocat
  • Connect to the node websocat ws://localhost:8080/ws
  • If you see an empty prompt, means you are connected to web socket server
  • The prompt accepts any input that will be sent as request to server
  • Press new line that means we are sending empty string as request to server
  • This will fail the request parsing and crashes the application

Which version(s) does this affect? (Environment, OS, etc...)

5.0.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants