On this page
An HTTPS page can contain a download link whose destination uses HTTP. The page itself is protected in transit, but that protection does not automatically extend to a separate request for a file. This guide shows how to inspect an HTTP download link on an HTTPS page, reproduce the behavior in a controlled environment, and check that a proposed fix covers redirects.
Key Takeaways
- HTTPS protects the page’s connection; it does not change an
http://link into a secure destination. - A link that initiates a top-level navigation is different from a page loading an insecure image or script. Browser handling can differ, especially when a link triggers a download.
- Inspect the final request and redirect chain, not just the URL written in the page’s HTML.
- Serve the file and its redirects over HTTPS. HTTPS protects the transfer, but it does not prove that the file itself is safe.
Why an HTTPS page can link to HTTP
A page can use an absolute link such as:
<a href="http://downloads.example.test/report.pdf">Download report</a>
The browser first retrieves the page over HTTPS. When a visitor activates this link, the destination is a separate HTTP request unless the browser or server changes how it is handled. An attacker able to interfere with an unprotected HTTP transfer could potentially alter or replace the file in transit.
This differs from an HTTPS page embedding an HTTP subresource, such as <script src="http://example.test/app.js"></script>. In that case, the insecure request is part of loading the page. A link, by contrast, generally initiates a navigation; a server response or browser decision can turn that navigation into a download.
Browsers may warn, block, or otherwise handle insecure downloads differently from ordinary navigations or subresources. Exact behavior depends on the browser, its version and settings, and the request. Current Chrome, Firefox, and MDN documentation was not available for verification in this article, so do not rely on a particular warning or blocking outcome. Test the browsers and configurations your visitors use.
Advertisement
Inspect an HTTP download link on an HTTPS page
Use a test file and an account you are authorized to access. Avoid exposing signed URLs, tokens, or private filenames in screenshots and logs.
- Open the HTTPS page and inspect the link with your browser’s developer tools. Check its
hrefand any surrounding script that handles clicks. - In the Elements panel, select the link. In browsers that support the
$0developer-tools shortcut, evaluate$0.hrefin the console to see its resolved URL. A relativehrefcan resolve differently from an absolute one. - Open the Network panel and enable its option to preserve requests across navigation, if available. Click the link and inspect the request URL, response status, and any
Locationheaders. - Check the browser’s download interface and security messages as well. A download or a blocked request may not appear in the Network panel as an ordinary page request.
- If the request redirects, inspect every hop. An HTTPS starting URL can redirect to HTTP, and an HTTP starting URL can expose the initial request even if it subsequently redirects to HTTPS.
JavaScript can change the destination or initiate a request instead of following the displayed href. If the network record and the HTML disagree, investigate the click handler and any redirecting endpoint.
For a controlled test URL, you can also inspect the redirect chain from a terminal:
curl -v -L --max-redirs 5 --max-time 20 -o /dev/null 'https://downloads.example.test/report.pdf'
Replace the URL with your own test endpoint. This makes a real request and may download the file, so use a small test file. The verbose output can include sensitive URL or header information; redact it before sharing. curl can help reveal requests and redirects, but its behavior does not establish what a browser will warn about or block.
Reproduce it on a controlled test page
This example requires a private lab network, an HTTPS web server with a certificate trusted by the test browser, and Python installed on a lab machine. The code was not executed for this article.
Configure your lab’s name resolution so that page.lab.test points to the HTTPS server and downloads.lab.test points to the lab machine serving the file. Use a private address reachable by the test browser; do not expose the test server to the public internet. Loopback addresses can receive special browser treatment, so they are a poor basis for generalizing the result.
On the file-serving lab machine, create a small test file and start a temporary HTTP server. When prompted, enter that machine’s private lab IP address:
mkdir -p lab-download
printf 'Controlled download test\n' > lab-download/sample.bin
read -r -p 'Lab server private IP: ' LAB_IP
python3 -m http.server 8000 --bind "$LAB_IP" --directory lab-download
Publish the following page at https://page.lab.test/ using your HTTPS server:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Download transport test</title>
</head>
<body>
<h1>Download transport test</h1>
<p><a href="http://downloads.lab.test:8000/sample.bin">Open test file</a></p>
</body>
</html>
Open the page in the test browser, confirm that its HTTPS connection is trusted, and activate the link while observing developer tools and the browser’s download interface. Depending on browser behavior and server headers, the file might download, open, or be blocked or otherwise handled. Record the browser version and settings alongside your observation; do not treat one result as a guarantee for other visitors.
Stop the temporary Python server with Ctrl+C when finished. It is intended here only as a lab server, not as a production download service.
Advertisement
Fix the destination and its redirects
- Serve the file over HTTPS. Configure a valid certificate for the download hostname, make the file available through the HTTPS endpoint, and change the page’s link to that endpoint.
- Check every redirect. Follow the link through any download service, storage endpoint, or CDN. Ensure each request in the chain uses HTTPS, including the final file request. Update stale redirect configurations and stored URLs where necessary.
- Test the actual user flow. Check the rendered link, click handlers, response headers, and browser download behavior. Test relevant browsers and repeat after deployment.
- Check transport independently of file trust. HTTPS helps protect a connection against interception and modification in transit; it does not establish that the publisher or file is trustworthy. Where appropriate, verify a publisher’s digital signature using a trusted verification key, or compare a checksum obtained through a trusted, independent channel.
If an HTTP endpoint remains for compatibility, redirecting it to HTTPS is useful, but visitors who start at the HTTP URL still make an unprotected initial request. Update the links that send visitors there rather than relying solely on the redirect.
Common Mistakes
- Checking only the padlock on the page. It describes the page connection, not every destination the page can link to.
- Stopping at the first HTTPS URL. A later redirect can still point to HTTP.
- Assuming a browser warning is universal. Download behavior can vary; absence of a warning is not proof of a secure transfer.
- Treating the
downloadattribute as a security control. It does not make an HTTP transfer secure, and browser handling can differ for cross-origin links. - Assuming an HTTPS file is harmless. A secure transport can deliver a malicious or unwanted file just as it can deliver a legitimate one.
Best Practices
Maintain an inventory of download links and redirect endpoints, including links generated by application code. Review changes to storage and CDN configurations that could alter destinations. Use small, non-sensitive files for troubleshooting, and avoid sharing logs that contain credentials or signed query parameters.
Conclusion
An HTTPS page and its download destination are separate requests. Inspect the rendered link and the complete redirect chain, move the file delivery path to HTTPS, and verify file trust separately from transport security.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.