Skip to content

Throw only if the constructor key has a child named prototype #25

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

Merged
merged 3 commits into from
Mar 15, 2021

Conversation

delvedor
Copy link
Member

@delvedor delvedor commented Mar 8, 2021

Currently, we are throwing an error for a valid use case, eg:

{
  "constructor": {
    "foo": "bar
  }
}

While we should only throw if the constructor key has a direct prototype child.

{
  "constructor": {
    "prototype": {
      "foo": "bar
    }
  }
}

I'm still checking if there are some edge cases that need to be covered, or if this change will introduce any regression.

Checklist

@delvedor delvedor marked this pull request as ready for review March 9, 2021 07:05
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member Author

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fastify/core I'm wondering if we should remove the whole constructor object or only the constructor.prototype:

delete node.constructor

What do you think?

@mcollina
Copy link
Member

I would remove also constructor. We can safely assume that anyone doing those things is an attacker.

@delvedor delvedor merged commit 26f64b6 into master Mar 15, 2021
@delvedor delvedor deleted the improve-contractor-detection branch March 15, 2021 10:02
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

Successfully merging this pull request may close these issues.

5 participants