News for hackers. Stuff that matters.
Re:API Shouldn't Redirect HTTP to HTTPS by justin_oaks on Tuesday May 28, 2024 @04:18PM (#40505118)
I appreciate the author calling this out because creating an HTTP-redirect-to-HTTPS is something I'll do almost without thinking about it. "If it has HTTPS, I'll set up an HTTP redirect." Now I know that I need to think about it before setting that up.

It also made me realize that cURL's default to not redirect automatically is probably intentional and is a good default. Praise be to Daniel Stenberg for this choice when implementing cURL.

Re:API Shouldn't Redirect HTTP to HTTPS by tootie on Tuesday May 28, 2024 @04:57PM (#40505523)
Using Cloudfront, the redirect was the only built-in option for a long time. They only added pushbutton HSTS recently. But I'd say author is correct that if you're hosting an API there's no reason to support http at all. Just send a 400 on all requests and let the client developers use common sense.
Re:API Shouldn't Redirect HTTP to HTTPS by tracker1 on Wednesday May 29, 2024 @12:56PM (#40514123)
You can still return a response...

  400 - HTTP is unsupported, use HTTPS.
Re:API Shouldn't Redirect HTTP to HTTPS by koromak on Wednesday May 29, 2024 @09:18AM (#40511671)
Yeah I completely missed this as a security flaw. Time to go deploy a fix...
Re:API Shouldn't Redirect HTTP to HTTPS by tracker1 on Wednesday May 29, 2024 @12:54PM (#40514092)
I tend to use Caddy as a reverse proxy for personal projects... The default behavior is to redirect to https. May have to make a special rule for API instances.