Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find if a web site uses HSTS

Tags:

curl

https

header

I'm totally new to curl and am trying to ascertain if websites use Strict-Transport-Security.

I'm running off advice. I've been told to check against Chrome's preloaded list and to run

curl -D - https://www.example.com | head -n 20

to check for Strict-Transport-Security headers.

But the 'head' command generated an error and was unknown.

Any ideas?

ATM I'm running Win XP, will have a linux distro in a few days.

Thanks.

like image 275
Dental Floss Avatar asked Jul 30 '12 08:07

Dental Floss


People also ask

How do I know if a site is using Hsts?

There are a couple easy ways to check if the HSTS is working on your WordPress site. You can launch Google Chrome Devtools, click into the “Network” tab and look at the headers tab. As you can see below on our Kinsta website the HSTS value: “strict-transport-security: max-age=31536000” is being applied.

How do I check my browser Hsts list?

If you own a site that you would like to see included in the preloaded HSTS list you can submit it at https://hstspreload.org. You can see the current HSTS Rules -- both dynamic (set by a response header) and static (preloaded) using a tool on the about://net-internals#hsts page. Check the source for the full list.

How do I know if my Strict-Transport-Security header?

To check this Strict-Transport-Security in action go to Inspect Element -> Network check the response header for Strict-Transport-Security like below, Strict-Transport-Security is highlighted you can see.


1 Answers

That method is fine.

$ curl -s -D- https://paypal.com/ | grep Strict
Strict-Transport-Security: max-age=14400

As you've noticed, some webservers just refuse to honour HEAD requests. curl will print the headers for a GET request with -v:

$ curl -s -vv https://paypal.com/ 2>&1 | grep Strict
< Strict-Transport-Security: max-age=14400

The < means the header is one returned by the server to you.

Actual example.com, as in your example, won't work as it doesn't listen on https:// at all:

$ curl -D- https://www.example.com
curl: (7) couldn't connect to host

As the Strict-Transport-Security header is only honoured if it is delivered over https://, it's very safe to assume that any site that doesn't respond to on https:// isn't using STS, especially as it would have no reason to do so.

like image 59
FauxFaux Avatar answered Sep 18 '22 03:09

FauxFaux