Skip to content

bug: cookie is not set if the host address is localhost:4320 #632

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion vulnerabilities/weak_id/source/high.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
}
$_SESSION['last_session_id_high']++;
$cookie_value = md5($_SESSION['last_session_id_high']);
setcookie("dvwaSession", $cookie_value, time()+3600, "/vulnerabilities/weak_id/", $_SERVER['HTTP_HOST'], false, false);
$domain = ($_SERVER['SERVER_NAME'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
setcookie("dvwaSession", $cookie_value, time()+3600, "/vulnerabilities/weak_id/", $domain, false, false);
}

?>
3 changes: 2 additions & 1 deletion vulnerabilities/weak_id/source/impossible.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

if ($_SERVER['REQUEST_METHOD'] == "POST") {
$cookie_value = sha1(mt_rand() . time() . "Impossible");
setcookie("dvwaSession", $cookie_value, time()+3600, "/vulnerabilities/weak_id/", $_SERVER['HTTP_HOST'], true, true);
$domain = ($_SERVER['SERVER_NAME'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't you setting it if it is localhost?

The default according to the manual should be an empty string, not false.

Would it make sense to do an equals check and reverse the two value fields? That would read better to me.

setcookie("dvwaSession", $cookie_value, time()+3600, "/vulnerabilities/weak_id/", $domain, true, true);
}
?>
Loading