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

Fix invalid DNS SAN entries #795

Merged
merged 2 commits into from
Feb 4, 2019
Merged

Fix invalid DNS SAN entries #795

merged 2 commits into from
Feb 4, 2019

Conversation

mrohera
Copy link
Member

@mrohera mrohera commented Feb 3, 2019

Changes here fix a situation where a edge device's host name that begins with number(s) [0-9] gets sanitized. For example host name "2019edgehost" is consumed as "edgehost". This has caused problems was observed when using VMs that begin with numbers since it appears to be permitted configuration contrary to RFC 1035.

The changes involve passing the configured host name as is into the SAN entry without any modifications. The module id DNS entry continues to be sanitized.

@myagley
Copy link
Contributor

myagley commented Feb 4, 2019

Do we need to sanitize this? Should we be returning an error instead? It seems like if we strip out characters we are effectively making the certificate unusable. A client can then never connect to the server because the cert SAN and hostname in the request will always be different. This seems like we are effectively silently failing.

@avranju
Copy link
Contributor

avranju commented Feb 4, 2019

@myagley Are you asking if we should do this sort of sanitization for module ID SAN entries as well? In the Kubernetes case this turned out to be necessary for Edge Hub since the module ID is $edgeHub which isn't a valid DNS name. So this gets transformed into edgehub -- i.e., the $ gets removed and the H is made lowercase. Since its Edge Agent that sets up the GatewayHostName it applies the same rules at that time for modules.

I suppose we could special-case Edge Hub and error out in the general case if the module ID isn't a valid DNS name.

For the subject name case, this PR removes sanitization (still makes it lower case though) and basically allows any arbitrary string. This fixes a regression.

@mrohera
Copy link
Member Author

mrohera commented Feb 4, 2019

@myagley suggested using the sanitization rules per: http://man7.org/linux/man-pages/man7/hostname.7.html. @avranju does this work for the aforementioned scenario?

@mrohera
Copy link
Member Author

mrohera commented Feb 4, 2019

Also I don't think this is a regression as the current changes merely bypass sanitization only for the hostname. Module IDs continue to be sanitized.

@avranju
Copy link
Contributor

avranju commented Feb 4, 2019

@mrohera Sorry, I meant that what's in master is a regression. This PR fixes the regression.

@avranju
Copy link
Contributor

avranju commented Feb 4, 2019

@myagley suggested using the sanitization rules per: http://man7.org/linux/man-pages/man7/hostname.7.html. @avranju does this work for the aforementioned scenario?

With the Kubernetes integration, module identifiers are used as the service name and here's the check that Kubernetes makes for service names:

A DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is [a-z]([-a-z0-9]*[a-z0-9])?

Maybe we can leave the module ID SAN entry as-is and use the rules suggested above only for the common name?

@mrohera mrohera merged commit 98a3dbd into master Feb 4, 2019
@mrohera mrohera deleted the mrohera/hostname_fix branch February 4, 2019 19:12
myagley pushed a commit to myagley/iotedge that referenced this pull request Feb 4, 2019
Changes here fix a situation where a edge device's host name that begins with number(s) [0-9] gets sanitized. For example host name "2019edgehost" is consumed as "edgehost". This has caused problems was observed when using VMs that begin with numbers since it appears to be permitted configuration contrary to RFC 1035.

The changes involve passing the configured host name as is into the SAN entry without any modifications. The module id DNS entry continues to be sanitized.
myagley added a commit to myagley/iotedge that referenced this pull request Feb 4, 2019
myagley pushed a commit to myagley/iotedge that referenced this pull request Feb 4, 2019
Changes here fix a situation where a edge device's host name that begins with number(s) [0-9] gets sanitized. For example host name "2019edgehost" is consumed as "edgehost". This has caused problems was observed when using VMs that begin with numbers since it appears to be permitted configuration contrary to RFC 1035.

The changes involve passing the configured host name as is into the SAN entry without any modifications. The module id DNS entry continues to be sanitized.
myagley added a commit that referenced this pull request Feb 4, 2019
* Fix invalid DNS SAN entries (#795)

Changes here fix a situation where a edge device's host name that begins with number(s) [0-9] gets sanitized. For example host name "2019edgehost" is consumed as "edgehost". This has caused problems was observed when using VMs that begin with numbers since it appears to be permitted configuration contrary to RFC 1035.

The changes involve passing the configured host name as is into the SAN entry without any modifications. The module id DNS entry continues to be sanitized.

* Revert "Fix invalid DNS SAN entries (#795)"

This reverts commit a8148cc.

* prepare_dns_san_entries was allowing characters that are not A-Za-z0-9 (#736)

* Fix invalid DNS SAN entries (#795)

Changes here fix a situation where a edge device's host name that begins with number(s) [0-9] gets sanitized. For example host name "2019edgehost" is consumed as "edgehost". This has caused problems was observed when using VMs that begin with numbers since it appears to be permitted configuration contrary to RFC 1035.

The changes involve passing the configured host name as is into the SAN entry without any modifications. The module id DNS entry continues to be sanitized.
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.

3 participants