diff --git a/src/nodenorm/handlers/base.py b/src/nodenorm/handlers/base.py index c070773..aafa4a6 100644 --- a/src/nodenorm/handlers/base.py +++ b/src/nodenorm/handlers/base.py @@ -2,6 +2,7 @@ import json +import tornado.escape from biothings.web.handlers import BaseHandler from tornado.web import HTTPError @@ -53,3 +54,13 @@ def load_json_body(self): return json.loads(self.request.body) except (json.JSONDecodeError, UnicodeDecodeError) as error: raise HTTPError(detail=f"The body is not valid JSON: {error}", status_code=400) + + def write(self, chunk): + # Tornado refuses a top-level list ("Lists not accepted for security reasons"), a guard + # against JSON hijacking through