Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not leak HTTPS cookies to HTTP or JS #35

Merged
merged 1 commit into from
Sep 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions -/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ function bcurls_find_banned_glyph($slug) {
{
if (md5($_POST['username'].$_POST['password'].COOKIE_SALT) == COOKIE_VALUE)
{
setcookie(COOKIE_NAME, COOKIE_VALUE, NOW + YEAR, '/', COOKIE_DOMAIN);
setcookie(COOKIE_NAME,
COOKIE_VALUE,
NOW + YEAR,
'/',
COOKIE_DOMAIN,
$_SERVER['HTTPS'], // If we are on HTTPS, do not leak cookie to HTTP
true // HTTPONLY (don't let JS examine the cookie)
);
$_COOKIE[COOKIE_NAME] = COOKIE_VALUE;
}
}
Expand Down Expand Up @@ -135,7 +142,14 @@ function bcurls_find_banned_glyph($slug) {
// prolong login for another year, unless this is an API request
else if (!isset($_GET['api']))
{
setcookie(COOKIE_NAME, COOKIE_VALUE, NOW + YEAR, '/', COOKIE_DOMAIN);
setcookie(COOKIE_NAME,
COOKIE_VALUE,
NOW + YEAR,
'/',
COOKIE_DOMAIN,
$_SERVER['HTTPS'], // If we are on HTTPS, do not leak cookie to HTTP
true // HTTPONLY (don't let JS examine the cookie)
);
}

// Successfully logged in, so
Expand Down