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

Incorrect number of sealed components #380

Closed
dalalRohit opened this issue Jul 25, 2021 · 1 comment
Closed

Incorrect number of sealed components #380

dalalRohit opened this issue Jul 25, 2021 · 1 comment

Comments

@dalalRohit
Copy link

dalalRohit commented Jul 25, 2021

The error I'm facing is definitely a very rare-case scenario but worth handling as a developer I guess.

When someone tampers/alters the encrypted cookie from the Cookies panel in DevTools, the app breaks completely with Incorrect number of sealed components as the error.

Screenshot 2021-07-25 at 11 43 05 PM

Is there any way I can catch this error?

Firstly, I thought it is coming from the point where the cookie is getting requested, i.e from where req.session.get(cookie_name) is called. So tried wrapping that in try/ catch but the error seems to be from either iron-store or @hapi/iron I guess.

Any help?

Rohit,

@vieiralucas
Copy link

vieiralucas commented Aug 11, 2021

My guess is that we need to add a check here:
https://github.com/vvo/next-iron-session/blob/d7e0c6aea42c27173e6d674e92f871e34632e580/lib/index.js#L132-L136

Like this:

    if (
      err.message === "Expired seal" ||
      err.message === "Bad hmac value" ||
      err.message === "Cannot find password: " ||
      err.message === "Incorrect number of sealed components"
    ) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants