Skip to content

Devtools server crashes on malformed webhook JSON payloads #465

Description

@omerbek

Summary

The local SNS devtools server in devtools/node/httpserver.js parses every POST body with JSON.parse(body) inside handleBody() without catching malformed JSON.

A malformed or non-JSON POST body can therefore raise an uncaught exception and terminate the devtools process instead of logging/rejecting the invalid payload.

Impact

This affects local webhook/SNS debugging: one malformed request can take down the process and require a manual restart.

Relevant code

const handleBody = (body) => {
  const envelope = JSON.parse(body)
  validator.validate(envelope, (err) => {
    // ...
  })
}

Expected behavior

Malformed JSON should be handled explicitly, for example by logging a clear error and returning a 400 response or otherwise avoiding process termination.

Possible fix

Wrap JSON.parse in a try/catch and keep SNS validation behavior unchanged for valid JSON envelopes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions