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

WIP: Changed is_hsts() function to check both https endpoints. #204

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pshtt/pshtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,16 +1199,20 @@ def is_missing_intermediate_cert(domain):

def is_hsts(domain):
"""
Domain has HSTS if its canonical HTTPS endpoint has HSTS.
Domain has HSTS if both https and httpswww endpoints have HSTS when live.
Copy link
Member

Choose a reason for hiding this comment

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

The canonical endpoint was (I think) introduced by @h-m-f-t in an effort to make the HTTPS report results more digestible by the less technical. I'd have to know his thoughts on this change before approving.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think @climber-girl 's point was that if both endpoints are live then both should have HSTS. I think this section of RFC6797 touches on what I mean although it is in the context of a web application and the includeSubDomains directive.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't completely understand all of the reasons for only focusing on the canonical endpoint. It seems like we assume that that is where most users will end up, but plenty of others may use the other endpoint (if it is live), and attackers could take advantage of the other endpoint (via spear-phishing URLs and the like) if it is not sufficiently protected.

strictly_forces_https already looks at both http endpoints, not just the canonical one, but downgrades_https currently only looks at the canonical https endpoint. If we switch this HSTS check to check both endpoints, then we should probably change some other checks to look at both endpoints (such as downgrades_https and maybe even follow-on sslyze checks). Should most of these checks for both endpoints be in new "Strictly_Enforces" checks or should these be changed in the existing checks?

"""
canonical, https, httpswww = domain.canonical, domain.https, domain.httpswww
https, httpswww = domain.https, domain.httpswww

if canonical.host == "www":
canonical_https = httpswww
else:
canonical_https = https
if not https.live and not httpswww.live:
return None

hsts = True
if https.live:
hsts &= https.hsts
if httpswww.live:
hsts &= httpswww.hsts

return canonical_https.hsts
return hsts


def hsts_header(domain):
Expand Down