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

fixes Origin validation for IP address. gives meaning to public and allowedHosts #1622

Closed
wants to merge 3 commits into from

Conversation

carlosgeos
Copy link

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Yes, I have adapted and improved the tests.

Motivation / Use-Case

#1618

Breaking Changes

None.

BUT it is breaking if people are using webpack-dev-server in a way it is not intended to be used. For example, without specifying public or allowedHosts to serve publicly.

Additional Info

This fixes #1618 which are two things basically:

  1. More security regarding the websocket server (it was accepting all connections with an IP address as Origin). https://www.npmjs.com/advisories/725
  2. Not letting everyone in the network connect to the development server unless specified if public, allowedHosts, etc

Carlos Requena López added 2 commits January 8, 2019 21:06
@carlosgeos carlosgeos changed the title Fix 1618 fixes Origin validation for IP address. gives meaning to public and allowedHosts Jan 8, 2019
@carlosgeos
Copy link
Author

I also like #1619. If that one gets merged, I'll update this PR (to have no conflicts)

// so we have the pure IPv6-address in hostname.
if (ip.isV4Format(hostname) || ip.isV6Format(hostname)) {
return true;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why we remove this check, it can be breaking change for some developers?

Copy link
Author

Choose a reason for hiding this comment

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

This check basically means no security (for both static server and sockjs server) (#1618). It is not breaking if people are following the docs 👍

Copy link
Member

Choose a reason for hiding this comment

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

@carlosgeos developers are not following the docs 😄 Better avoid this removing, we can do this in next major release

Copy link
Author

Choose a reason for hiding this comment

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

hahahah ok, then I'll close this PR

// always allow localhost host, for convience
if (hostname === 'localhost') {
if (hostname === 'localhost' || hostname === '127.0.0.1') {
Copy link
Member

Choose a reason for hiding this comment

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

We need better check here, because some developers can use 192.168.0.1 or other local IPs

Copy link
Author

Choose a reason for hiding this comment

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

If they use a local IP, developers should specify public: '192.168.0.x'. It will be covered by the public option further down in the code:

if (hostname === publicHostname) {
return true;
}

allowedHosts can also be used.

@alexander-akait
Copy link
Member

Also need rebase

@carlosgeos carlosgeos closed this Jan 9, 2019
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.

Missing Origin Validation, for IP addresses
2 participants