Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure XSRF prefix for json responses #121

Open
alexanderkjeldaas opened this issue Sep 10, 2014 · 3 comments
Open

Configure XSRF prefix for json responses #121

alexanderkjeldaas opened this issue Sep 10, 2014 · 3 comments
Labels
info needed More information is needed security

Comments

@alexanderkjeldaas
Copy link

Angular will automatically strip ")]}',\n" from json responses.

https://docs.angularjs.org/api/ng/service/$http
http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx/

@sol
Copy link
Contributor

sol commented Sep 11, 2014

@alexanderkjeldaas What do you suggest to do here? Do you want a way to register a postprocessor for json responses? E.g.

tranformJSON :: (ByteString -> ByteString) -> ActionM ()

that can then be used like so:

main = scotty 3000 $ do

  tranformJSON (")]}',\n" <>)

  get "/" $ do
    json [23 :: Int, 42]

@alexanderkjeldaas
Copy link
Author

Yes, something like that. With a focus on ensuring that it is unlikely that an uprotected json response will be sent in a large application.

@sol
Copy link
Contributor

sol commented Sep 12, 2014

With a focus on ensuring that it is unlikely that an uprotected json response will be sent in a large application.

What do you have in mind here? AFAIK, sending JSON objectss is fine. So if the user already follows the convention to always wrap things in a top-level object, no mitigation is needed. I assumed it's on the users discretion to enable any form of mitigation.

An other approach would be to check if the provided JSON Value is an object. If it is not an object, we could wrap it (e.g. {"value" : ...}). Not sure if that is desirable?

@ocramz ocramz added security info needed More information is needed labels Sep 23, 2023
@ocramz ocramz mentioned this issue Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed More information is needed security
Projects
None yet
Development

No branches or pull requests

3 participants