Header Misconfiguration - PHP API
The PHP API's authentication check only sends a redirect header when the session is missing, but does not stop script execution, so the protected page content still renders. An attacker could bypass the login and view the index page, potentially exposing full path information.
- Triaged in 10 days
- Fixed in 12 days
- Disclosed after 12 days
Hey,
Your index api page auth can easily be bypassed because it doesn't use proper auth practices in its PHP core. Here is the master code from Shopify:
https://github.com/Shopify/shopify_php_api/blob/master/index.php
it says:
if (!isset($_SESSION['shop']) || !isset($_SESSION['token'])) header("Location: login.php");
This easily can be bypassed because the browser can decide to receive 301/302 redirects. and since if not logged in, the code tries to decide to redirect back to the login page, and the browser can ignore it. this can create an authentication bypass and also full path disclosure.
I have written a similar example in my blog, http://www.paulosyibelo.com/2014/08/header-based-login-bypass.html
P.S: The issue exists not only on the index.php page, but in almost every page. (ex: https://github.com/Shopify/shopify_php_api/blob/master/login.php)
The best practice I would recommend would be creating another function instead of the header one, like:
function redirect($url){ header("Location: $url"); exit(); }
The easiest approch is to exit(); the code after the redirection. or else, the rest of the page still renders no matter what. I hope I don't need to provide a POC as its a crystal clear bug (also with the link).
Thanks,
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The authentication check uses a header redirect without calling exit(), so the rest of the script continues to execute and render protected content.
Impact
An attacker could bypass authentication on the index and other pages, potentially leading to full path disclosure.
What the attacker needed
None
The fix
The code should call exit() after sending the redirect header, or use a redirect function that exits, so the rest of the page does not render.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a website wants to send you to a login page, it can send a 'redirect' message to your browser. This code sends that message but keeps building the page anyway, so the page content is still sent to anyone who asks. A person can simply ignore the redirect and see the page.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.