Giter Site home page Giter Site logo

Ignore CORS about crumb HOT 12 CLOSED

hueniverse avatar hueniverse commented on August 13, 2024
Ignore CORS

from crumb.

Comments (12)

stongo avatar stongo commented on August 13, 2024

Crumb protection is not being skipped when CORS is turned on. The crumb cookie will only be set for domains listed in the allowOrigins setting, but crumb protection will still be enabled for all requests. The whole purpose of the security fix was to not leak the crumb token to unauthorized Cross Origin requests.
If crumb is not currently behaving like this, it is a bug.
Will verify today.

from crumb.

hueniverse avatar hueniverse commented on August 13, 2024

We might need to expose the Origin match utility in hapi then to do this properly.

from crumb.

hueniverse avatar hueniverse commented on August 13, 2024

Does it just not set the cookie or also doesn't validate the form if no cookie is set?

from crumb.

stongo avatar stongo commented on August 13, 2024

@hueniverse if a CORS request is from an unknown Origin, the generate function isn't called and a cookie isn't returned.
That is the only code affected by CORS
Where is the Origin match utility in HAPI? I would be happy to integrate that

from crumb.

hueniverse avatar hueniverse commented on August 13, 2024

Can you explain this to me: https://github.com/hapijs/crumb/blob/master/lib/index.js#L203-L206

It makes no sense. You are comparing the incoming host header to the connection host. The way you are testing it is based on the old shot module behavior where it didn't set the host header properly. I upgraded to hapi 11 and half the tests broke.

from crumb.

hueniverse avatar hueniverse commented on August 13, 2024

In hapi v12 you should use request.info.cors.isOriginMatch exclusively without using any of the custom config stuff you have in crumb right now. IOW, we need a new major version of crumb for hapi v12.

from crumb.

stongo avatar stongo commented on August 13, 2024

Ok will do. Thanks for exposing that
On Jan 2, 2016 2:23 PM, "Eran Hammer" [email protected] wrote:

In hapi v12 you should use request.info.cors.isOriginMatch exclusively
without using any of the custom config stuff you have in crumb right now.
IOW, we need a new major version of crumb for hapi v12.


Reply to this email directly or view it on GitHub
#61 (comment).

from crumb.

stongo avatar stongo commented on August 13, 2024

Using request.info.cors.isOriginMatch alone won't allow a route to set the crumb for a CORS client and same-origin client (ie server rendered page)
That was what the extra logic had been for. Set crumb if it's a same-origin request OR an allowed CORS origin.
Maybe we don't support that, but it had been a request that came in an issue.

from crumb.

hueniverse avatar hueniverse commented on August 13, 2024

What does it mean "same origin request"? This line: https://github.com/hapijs/crumb/blob/master/lib/index.js#L203-L206 makes no sense as described above. Upgrade the tests to hapi v12 and see what happens.

from crumb.

stongo avatar stongo commented on August 13, 2024

I have already upgraded and tested locally (hapi12) branch.
Sorry for not explaining well. What I'm trying to describe is an edge case and probably not worth supporting.
Should be able to PR the update later today

from crumb.

stongo avatar stongo commented on August 13, 2024

6.0.0 release addresses this

from crumb.

lock avatar lock commented on August 13, 2024

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

from crumb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.