|License Type||SaaS & On-Premise|
|Main Product Category||Node.js Agent|
How exactly does the Node agent block attacks?
Node.js throws a custom error which extends the language’s built-in Error. However, we need to make sure we don’t simply crash the app by doing this. The way we do this is framework specific.
In express, we inject an error handling middleware into the middleware stack for each router. When it sees our specific error, it throws away the response and sends a custom one with the block details (403: 'not in my house').
In hapi, we let the framework return the error. Hapi uses their own boom library to do error handling; when an Error gets passed into the response, it automatically wraps it in a "boom" which is a hybrid response/error object. These automatic "booms" are "500: server error" by default instead of 403s, so we hook into the boom library when we see it loaded by hapi and hijack the method used to wrap errors, so that we can watch for our custom error and configure the boom correctly before returning it to the framework.
Block at perimeter works a little differently. We filter for block-at-perim criteria before the request ever makes it to the framework, so we simply respond 403 to end the request then and there, and don’t have to worry about the way the frameworks handle errors.