CTFd doesn't handle URL protocol properly (mixing HTTP with HTTPS)
See original GitHub issueEnvironment:
- CTFd Version/Commit: b7a19f7
- Operating System: Alpine 3.9.3
- Running CTFd with tghosth/CTFd-docker-deploy behind a TLS-terminating Nginx.
- Reverse proxy properly returns the host, original IP, and the requested protocol via
X-Forwarded-Proto
. - Web Browser and Version: Chrome 73
What happened?
While running under HTTPS, several areas in CTFd return and redirect to http://
when they should be https://
. I encountered this behaviour in the following areas:
- All redirects caused by accessing an area that requires authentication without being authenticated. (e.g.
https://ctfdomain.example/user
->http://ctfdomain.example/login
) - All redirects resulting from actions processed by the server. (e.g. the redirect that happens after importing a backup)
- All redirects performed in a custom plugin I’m writing using Flask Dance (it’s for Okta authentication). I realise this will be difficult to reproduce, so I’m listing here it at last. Hopefully this shares the same root cause as the other two as it’s my biggest pain point.
What did you expect to happen? Everything should be HTTPS.
How to reproduce your issue
A. Backup import:
- Import a backup.
- Wait until a redirect to HTTP happens.
I reproduced it on CTFd’s own demo.ctfd.io
B. Auth redirect:
curl -I https://ctfdomain.example/user
- Notice the returned
Location:
header pointing tohttp://
.
demo.ctfd.io
is authed all the time, so I can’t repro there, but this screenshot is from a publicly available CTF found in the first page of Googling for “Powered by CTFd”.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to Find and Fix Mixed Content Warnings on HTTPS Sites
According to Google, mixed content occurs when HTML on a website loads over a secure HTTPS connection (thanks to a recently installed SSL ......
Read more >How to Find & Fix Mixed Content Issues with SSL / HTTPS
1. There is a great tool called Database Search and Replace, built by Interconnected/IT. As the name implies, it allows you to do...
Read more >W3C XML Schema Definition Language (XSD) 1.1 Part 1
This specification defines several attributes for direct use in any XML documents, as described in Schema-Related Markup in Documents Being ...
Read more >External Guidance on the implementation of Policy 0070
Send a question via our website www.ema.europa.eu/contact ... Information that EMA does not consider CCI .
Read more >Critical Issues Addressed in PAN-OS Releases
Bugs Affected Platform(if any). /Affected Version Description (release note)
PAN‑92564 8.0.0‑8.0‑8, 8.1.0
PAN‑86882 8.0.0‑8.0.7. and all older Mainlines
PAN‑81990 PA‑5220,PA‑5250. /. 8.0.4 Multiple DP restarts by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
While trying to isolate the issue to make more portable reproduction steps, I have noticed that I had
wsgi.url_scheme=http
set because a month ago I was having the opposite problem during testing. I have now set it tohttps
and everything is working as expected. Thanks for the help, Kevin 😃Running the following for the debug server:
The curl command shows an https response meaning the header was respected.
The same with a docker-compose modified for
REVERSE_PROXY=true
:I recognize that this is a pretty low effort test but it’s late in my timezone 😄
I’ll re-open this issue for a bit. If you can isolate out what the issue is it’d be useful to know.