Title: Set content type to `application/json` for `flask.make_response` with JSON data by pixeebot[bot] · Pull Request #8 · earonesty/python-github-webhooks · GitHub
Open Graph Title: Set content type to `application/json` for `flask.make_response` with JSON data by pixeebot[bot] · Pull Request #8 · earonesty/python-github-webhooks
X Title: Set content type to `application/json` for `flask.make_response` with JSON data by pixeebot[bot] · Pull Request #8 · earonesty/python-github-webhooks
Description: The default mimetype for make_response in Flask is 'text/html'. This is true even when the response contains JSON data. If the JSON contains (unsanitized) user-supplied input, a malicious user may supply HTML code which leaves the application vulnerable to cross-site scripting (XSS). This fix explicitly sets the response type to application/json when the response body is JSON data to avoid this vulnerability. Our changes look something like this: from flask import make_response, Flask import json app = Flask(__name__) @app.route("/test") def foo(request): json_response = json.dumps({ "user_input": request.GET.get("input") }) - return make_response(json_response) + return make_response(json_response, {'Content-Type':'application/json'}) More reading https://flask.palletsprojects.com/en/2.3.x/patterns/javascript/#return-json-from-views https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#output-encoding-for-javascript-contexts 🧚🤖 Powered by Pixeebot Feedback | Community | Docs | Codemod ID: pixee:python/flask-json-response-type
Open Graph Description: The default mimetype for make_response in Flask is 'text/html'. This is true even when the response contains JSON data. If the JSON contains (unsanitized) user-supplied input, a malicious u...
X Description: The default mimetype for make_response in Flask is 'text/html'. This is true even when the response contains JSON data. If the JSON contains (unsanitized) user-supplied input, a mal...
Opengraph URL: https://github.com/earonesty/python-github-webhooks/pull/8
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:dc7e73ee-ab58-9345-89a6-ae54f1a05cd7 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C016:D0177:7A9371:A24856:6A62A64F |
| html-safe-nonce | bae3fddc364493b5003a903a03e8589f0d14308a956bcf395a7302d579282272 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDE2OkQwMTc3OjdBOTM3MTpBMjQ4NTY6NkE2MkE2NEYiLCJ2aXNpdG9yX2lkIjoiMzM3MDk2MzY3MTY5OTMzNDczNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a21ad8ec93958eb739893e6f093b11ff6ec0ef996c408e3a6cd307e0a95d8ff3 |
| hovercard-subject-tag | pull_request:2050487119 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/earonesty/python-github-webhooks/pull/8/files |
| twitter:image | https://avatars.githubusercontent.com/in/193111?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/in/193111?s=400&v=4 |
| og:image:alt | The default mimetype for make_response in Flask is 'text/html'. This is true even when the response contains JSON data. If the JSON contains (unsanitized) user-supplied input, a malicious u... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a6443033349a18134b517627f043d4a59a5110337b879810c7229c2c7e28eda0 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/earonesty/python-github-webhooks git https://github.com/earonesty/python-github-webhooks.git |
| octolytics-dimension-user_id | 50769 |
| octolytics-dimension-user_login | earonesty |
| octolytics-dimension-repository_id | 140610530 |
| octolytics-dimension-repository_nwo | earonesty/python-github-webhooks |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 24353915 |
| octolytics-dimension-repository_parent_nwo | carlos-jenkins/python-github-webhooks |
| octolytics-dimension-repository_network_root_id | 24353915 |
| octolytics-dimension-repository_network_root_nwo | carlos-jenkins/python-github-webhooks |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d6c6cacbe32d3ddfd1796fbd1a39b8fb47b87daf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width