Giter VIP home page Giter VIP logo

Comments (3)

weavejester avatar weavejester commented on June 14, 2024 1

My inclination in this case is not to allow customization. Rather, I think there's a benefit to focusing on having a single correct way of producing a secure cookie. This removes the possibility of creating a security vulnerability through misconfiguration.

However, as the SessionStore protocol is available, people are free to create third-party session stores using whatever encryption algorithm they wish.

from ring.

weavejester avatar weavejester commented on June 14, 2024

The encrypted cookie is protected by an associated SHA256 HMAC. My understanding is that this prevents a padded oracle attack, or any form of plaintext oracle attack, as an attacker cannot change the encrypted data without invalidating the associated HMAC.

from ring.

kamituel avatar kamituel commented on June 14, 2024

This makes sense. I'm not experienced enough in cryptography to be 100% sure, but as far as I understand this particular attack vector, yes, HMAC over the whole cookie should eliminate the risk.

I still think that it'd be nice if the middleware would allow for more flexibility in terms of cryptography used. I might be 99.99% sure that AES-CBC with HMAC is sufficient, but if given a choice, I'd happily use AES-GCM.

Other possible advantages:

  • It would also allow for keys longer than 128 bits
  • It would allow larger apps to use the same crypto algorithms and key infrastructure everywhere.

Would you be open to a PR that would allow for more flexibility?

Maybe a protocol like this?

(defprotocol CookieStoreEncryption
  (encrypt [key data])
  (decrypt [key data])

For backward compatibility, the current implementation would then implement this protocol. E.g. encrypt would do AES-CBC with HMAC. But it could be overwritten like:

(ring.middleware.session.cookie/cookie-store
  {:key ...some bytes...
   :encryption-impl my-own-encryption})

I'd be happy to provide a PR like this, if the approach is sound in your opinion.

from ring.

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.