Is an HTTPS query string secure?

前端 未结 9 1367
耶瑟儿~
耶瑟儿~ 2020-11-22 03:52

I am creating a secure web based API that uses HTTPS; however, if I allow the users to configure it (include sending password) using a query string will this also be secure

相关标签:
9条回答
  • 2020-11-22 04:32

    Yes. The entire text of an HTTPS session is secured by SSL. That includes the query and the headers. In that respect, a POST and a GET would be exactly the same.

    As to the security of your method, there's no real way to say without proper inspection.

    0 讨论(0)
  • 2020-11-22 04:33

    I don't agree with the statement about [...] HTTP referrer leakage (an external image in the target page might leak the password) in Slough's response.

    The HTTP 1.1 RFC explicitly states:

    Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

    Anyway, server logs and browser history are more than sufficient reasons not to put sensitive data in the query string.

    0 讨论(0)
  • 2020-11-22 04:39

    Yes, it is. But using GET for sensitive data is a bad idea for several reasons:

    • Mostly HTTP referrer leakage (an external image in the target page might leak the password[1])
    • Password will be stored in server logs (which is obviously bad)
    • History caches in browsers

    Therefore, even though Querystring is secured it's not recommended to transfer sensitive data over querystring.

    [1] Although I need to note that RFC states that browser should not send referrers from HTTPS to HTTP. But that doesn't mean a bad 3rd party browser toolbar or an external image/flash from an HTTPS site won't leak it.

    0 讨论(0)
  • 2020-11-22 04:43

    From a "sniff the network packet" point of view a GET request is safe, as the browser will first establish the secure connection and then send the request containing the GET parameters. But GET url's will be stored in the users browser history / autocomplete, which is not a good place to store e.g. password data in. Of course this only applies if you take the broader "Webservice" definition that might access the service from a browser, if you access it only from your custom application this should not be a problem.

    So using post at least for password dialogs should be preferred. Also as pointed out in the link littlegeek posted a GET URL is more likely to be written to your server logs.

    0 讨论(0)
  • 2020-11-22 04:44

    Yes, your query strings will be encrypted.

    The reason behind is that query strings are part of the HTTP protocol which is an application layer protocol, while the security (SSL/TLS) part comes from the transport layer. The SSL connection is established first and then the query parameters (which belong to the HTTP protocol) are sent to the server.

    When establishing an SSL connection, your client will perform the following steps in order. Suppose you're trying to log in to a site named example.com and want to send your credentials using query parameters. Your complete URL may look like the following:

    https://example.com/login?username=alice&password=12345)
    
    1. Your client (e.g., browser/mobile app) will first resolve your domain name example.com to an IP address (124.21.12.31) using a DNS request. When querying that information, only domain specific information is used, i.e., only example.com will be used.
    2. Now, your client will try to connect to the server with the IP address 124.21.12.31 and will attempt to connect to port 443 (SSL service port not the default HTTP port 80).
    3. Now, the server at example.com will send its certificates to your client.
    4. Your client will verify the certificates and start exchanging a shared secret key for your session.
    5. After successfully establishing a secure connection, only then will your query parameters be sent via the secure connection.

    Therefore, you won't expose sensitive data. However, sending your credentials over an HTTPS session using this method is not the best way. You should go for a different approach.

    0 讨论(0)
  • 2020-11-22 04:44

    Yes, as long as no one is looking over your shoulder at the monitor.

    0 讨论(0)
提交回复
热议问题