Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does https encrypt the whole URL?

I googled a lot and many answers are Yes. For example: Is GET data also encrypted in HTTPS? But the senior security engineer in our company told me the URL would not be encrypted.

Image that, if the URL was encrypted, how does the DNS server find the host and connect?

I think is this is very strong point although it's against most of the answers. So I'm really confused and my questions are:

  1. Does https encrypt the everything in the request? (including the URL, host, path, parameters, headers)
  2. If yes, how the DNS server decrypt the request and send it to the host server?

I tried to access https://www.amazon.com/gp/css/homepage.html/ref=ya_surl_youracct and my IE sent two requests to the server:

First:

CONNECT www.amazon.com:443 HTTP/1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: www.amazon.com
Content-Length: 0
DNT: 1
Connection: Keep-Alive
Pragma: no-cache

Second:

GET /gp/css/homepage.html/ref=ya_surl_youracct HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US,zh-CN;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: www.amazon.com
DNT: 1
Connection: Keep-Alive

It seems my browser has requested twice: the first time is to establish the connection with host (without encryption) and the second time send an encrypted request over https? Am I right? If I am understanding this correctly, when a client call the RESTFUL API using https, it sends the requests (connection and get/post) twice every time?

like image 397
53iScott Avatar asked Apr 17 '15 09:04

53iScott


2 Answers

The URL IS encrypted from the time it leaves the browser until it hits the destination server.

What happens is that the browser extracts the domain name and the port from the URL and uses that to resolve DNS itself. Then it starts an encrypted channel to the destination server IP:port. Then it sends a HTTP request through that encrypted channel.

The important part is anyone but you and the destination server can only see that you're connecting to a specific IP address and port. They can't tell anything else (like specific URLs, GET parameters, etc).

Attackers can't even see the domain in most cases (though they can infer it if there is actually a DNS lookup - if it wasn't cached).

The big thing to understand is that DNS (Domain Name Service) is a completely different service with a different protocol from HTTP. The browser makes DNS lookup requests to convert a domain name into an IP address. Then it uses that IP address to issue a HTTP request.

But at no time does the DNS server receive a HTTP request, and at no time does it actually do anything other than provide a domain-name - IP mapping for users.

like image 163
ircmaxell Avatar answered Nov 16 '22 03:11

ircmaxell


While the other responses are correct so far as they go, there are many other considerations than just the encryption between the browser and the server. Here are some things to think about...

  • The IP address of the server is resolved.
  • The browser makes a TCP socket connection to the server's IP address using TLS. This is the CONNECT you see in your example.
  • The request is sent to the server over the encrypted session.

If this was all there is to it, you are done. No problem.

But wait, there's more!

Having the fields in a GET instead of a POST reveals sensitive data when...

  • Someone looks in the server logs. This might be a snoopy employee, but it can also be the NSA or other three-letter government agency, or the logs might become public record if subpoenaed in a trial.
  • An attacker causes the web site encryption to fall back to cleartext or a broken cipher. Have a look at the SSL checker from Qualsys labs to see if a site is vulnerable to this.
  • Any link on the page to an external site will show the URI of the page as the referrer. User ID and passwords are unintentionally yet commonly given away in this fashion to advertising networks. I sometimes spot these in my own blog.
  • The URL is available in the browser history and therefore accessible to scripts. If the computer is public (someone checks your web site from the guest PC in the hotel or airport lounge) the GET request leaks data to anyone else using that device.

As I mentioned, I sometimes find IDs, passwords and other sensitive info in the referrer logs of my blogs. In my case, I contact the owner of the referring site and tell them they are exposing their users to hacking. A less scrupulous person would add comments or updates to the site with links to their own web site, with the intention of harvesting the sensitive data in their referrer logs.

So your company's senior security engineer is correct that the URL is not encrypted in many places where it is extremely important to do so. You and the other respondents are also correct that it is encrypted in the very narrow use case of the browser talking to the server in context of a TLS session. Perhaps the confusion you mention has to do with the difference in the scope of these two use cases.

Please see also:

  • Testing for Exposed Session Variables (OTG-SESS-004)
  • Session Management - How to protect yourself (Note that "always use POST" is repeated over and over on this page.)
  • Client account hijacking through abusing session fixation on the provider
like image 42
T.Rob Avatar answered Nov 16 '22 03:11

T.Rob