-
Notifications
You must be signed in to change notification settings - Fork 82
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
Bugfix for domain_enforces_https() logic #192
Conversation
It's unclear to me why that function call is there, but it is not needed. When this code was last modified, the existing logic was: return is_domain_supports_https(domain) and ( is_strictly_forces_https(domain) and ( is_defaults_to_https(domain) or is_redirect(domain) ) or ( (not is_strictly_forces_https(domain)) and is_defaults_to_https(domain) ) ) With this bugfix, the logic is now: return is_domain_supports_https(domain) and ( is_defaults_to_https(domain) or ( is_strictly_forces_https(domain) and is_redirect_domain(domain) ) ) A quick logic test using the eight possible values of is_strictly_forces_https(domain), is_defaults_to_https(domain), and is_redirect(domain) shows that the old and new expressions are now in agreement. This was noticed thanks to a comment by @climber-girl.
@echudow, if there is a reason for including the call to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me, but let's hear from @echudow in case we are missing out on some particular case that he had in mind.
I don't remember all the specifics at the moment, but I think there was a case something along the lines of the site's http endpoint redirected to HTTPS on a different site but also had a live https endpoint on its own site without redirecting, so the domain was was failing the enforce HTTPS check because is_redirect_domain() was False. So I added is_http_redirect_domain() instead. Logically, as long as that's ok, the is_redirect_domain() could be removed and just replaced with is_http_redirect_domain() and the refactor that @jsf9k did should work fine with just replacing is_redirect_domain() with is_http_redirect_domain(). I don't have time now, but I'll try to dig up the specific details over the weekend or next week. |
Thanks for the input, @echudow! We probably need @h-m-f-t to weigh in as to whether we should count such a case as "enforcing HTTPS". In the case that caused me to investigate this, the site in question redirected all four endpoints to HTTPS except for the It sounds like in your case the host did not default to HTTPS, in which case I don't think we want to count it as "enforcing HTTPS." |
One of the sites that caused me to add the http_redirect was cloudservices.disa.mil. The http endpoint immediately redirects to https://www.milcloud.mil/, but the https endpoint is live and doesn't redirect, and both www endpoints are down, so it isn't a "redirect_domain". It seems to me like it enforces HTTPS though since both live endpoints are either https or redirect to https, but fails the old check because the http endpoint is live so it doesn't default_to_https and it isn't a redirect_domain. @jsf9k, for the case that you were looking into, shouldn't the site still fail to enforce_https because it doesn't strictly_forces_https since the www endpoint redirects to an HTTP site? strictly_forces_https is in an "and" with the (http_)redirect_domain, so it should still fail the overall domain_enforces_https check. @jsf9k, sorry for losing your refactor since I was working on an earlier version of the code and then neglected to merge in all the upstream updates. The refactor looks good to me, but I think could be okay with is_http_redirect_domain rather than is_redirect_domain. |
@echudow - I'm trying to compare our two cases, but the site that caused me to investigate this ( I'm told things will be back up tomorrow. |
I think you are correct, @echudow. The presence of The domain Why is the canonical domain an https domain in this case? Well, because it satisfies these rules. The issue I have is that Right now, for BOD 18-01 compliance we require "supports_https", "domain_enforces_https", "domain_uses_strong_hsts", and "no crappy crypto". Should we change "domain_enforces_https" to "strictly_forces_https" when calculating BOD 18-01 compliance? @h-m-f-t, can you weigh in here? |
I think the thing to do is to (1) keep my refactor, but (2) revert back to using return is_domain_supports_https(domain) and (
is_defaults_to_https(domain) or (
is_strictly_forces_https(domain) and is_http_redirect_domain(domain)
)
) This will have the simplification from the refactor but will give the same results as what is currently in develop. The issue I raised in my previous comment can then be taken up in a separate pull request. |
@jsf9k, @h-m-f-t, I think that would be great. That's what I suggested above and I already made that change in my fork a few days ago. For the return is_domain_supports_https(domain) and is_strictly_forces_https(domain) and (
is_defaults_to_https(domain) or is_http_redirect_domain(domain)
) |
Hmm, yeah, malware.us-cert.gov should not be True for IIRC, the difference between
|
So, should we change Are we good with the change from |
@echudow, I think changing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'd recommend a test run to check for surprises.
@h-m-f-t, what do you think about changing |
@echudow, I will kick that test off on Monday. I should have results Tuesday. |
Looking at the results of the full test run, I still think changing |
Time, how does it work 🕦 Layer 8 comment: frustration could be expressed by those whose scores this negatively changes. "I haven't changed anything; why don't I pass now?" Prior communication (sent generally) about the change can help lessen frustration and give notice that action needs to be taken. |
Another example that can be used to check logic changes during tests is studentsabroad.state.gov, which should be failing Supports HTTPS because it’s https-www endpoint should be flagging for BadHostname (cert is issued to *.state.gov, which wouldn't cover www.studentsabroad.state.gov). $ curl --head https://www.studentsabroad.state.gov |
Why do you have to hate on State as your example?? :(
…________________________________
From: Genevieve Marquardt <[email protected]>
Sent: Wednesday, May 22, 2019 4:48:00 PM
To: cisagov/pshtt
Cc: Subscribed
Subject: Re: [cisagov/pshtt] Bugfix for domain_enforces_https() logic (#192)
Another example that can be used to check logic changes during tests is studentsabroad.state.gov, which should be failing Supports HTTPS because it’s https-www endpoint should be flagging for BadHostname (cert is issued to *.state.gov, which wouldn't cover www.studentsabroad.state.gov<http://www.studentsabroad.state.gov>).
However, a manual pshtt scan through docker that I just ran shows it as meeting Supports HTTPS because the plain domain endpoints are good to go.
$ curl --head https://www.studentsabroad.state.gov
curl: (51) SSL: no alternative certificate subject name matches target host name 'www.studentsabroad.state.gov'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#192?email_source=notifications&email_token=AKUO3SOSTWPIDGUZDH6TAHDPWWWQBA5CNFSM4HKVAFA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWAJO4Q#issuecomment-494966642>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKUO3SPLC2IKC2PKSIAYL5LPWWWQBANCNFSM4HKVAFAQ>.
|
The latest version of pshtt tightens up the is_domain_supports_https() logic. See cisagov/pshtt#192 for details.
The latest version of pshtt tightens up the logic in the is_domain_supports_https() method. See cisagov/pshtt#192 for details.
Update `pre-commit` hook versions
Remove an extraneous call to
is_http_redirect_domain(domain)
. It's unclear to me why that function call is there, but it is not needed. When this logic was originally simplified by me in #180, the existing logic was:For some reason the extra call to
is_http_redirect_domain(domain)
was added in commit a65544b. With this bugfix, the logic is now reverted back to:A quick-but-tedious logic test using the eight possible values of
A = is_strictly_forces_https(domain)
,B = is_defaults_to_https(domain)
, andC = is_redirect(domain)
shows that the old and new expressions are now in agreement.Another way to look at this is to notice that the old logic can be written as (remembering that
and
has higher precedence thanor
):Note that if
B
isTrue
then the statement becomes(A and True) or (not A and True)
, which reduces toTrue
regardless of the value ofA
. IfB
is false then(not A and B)
evaluates toFalse
, and the larger statement can only be true ifA and (False or C)
evaluates toTrue
, which would mean thatA and C
isTrue
. Therefore the original statement must be equivalent toThis was noticed thanks to a comment by @climber-girl.