Debian 13 support, PHP 8.4/8.5, security hardening, install script
- Debian 13 (Trixie) compatibility: - Build uw-imap c-client from source (removed from trixie) - Fix OpenSSL 3 include paths for c-client - Split libnginx-mod-http-brotli package name - Add -lgomp and -std=c++17 to PHP CXXFLAGS - Fix Dovecot 2.4 config syntax in setup - Use 127.0.0.1 for DB (works in FPM chroot) - PHP version updates: - Add PHP 8.5.4 and 8.4.19 - Remove PHP 8.1 (EOL) - Update igbinary to master, imagick to 3.8.1, brotli to 0.18.3 - Remove php-rar (unmaintained, incompatible with 8.4+) - setup.php uses DEFAULT_PHP_VERSION for FPM sockets - Users can switch PHP version from dashboard - Security hardening: - CSRF tokens use bin2hex(random_bytes(32)) - Admin password uses password_hash/password_verify - Session regeneration on login - All output escaped with htmlspecialchars - Nginx rewrite rules validated (flag whitelist, reject injection) - Path traversal protection in FileManager - SQL injection fix in password change - Security headers (CSP script-src:none, X-Frame-Options, etc) - Onion private keys encrypted at rest (libsodium) - SFTP password encrypted in session with expiry - Admin brute-force rate limiting - CSRF token on login form - Zero JavaScript - all pages work without JS - mt_rand replaced with random_int - Cookie secure flag precedence fix - PDO ERRMODE_EXCEPTION - Generic login error messages (no username enumeration) - FileManager rename validation - Self-bootstrapping install.sh: - Auto-clones repo if run standalone (curl | bash support) - Interactive prompts or --non-interactive flag - Optional vanity .onion generation via mkp224o - Password generation or custom input - Credentials saved to /root/hosting-credentials.txt
This commit is contained in:
1 parent
71dd2804fb
commit
229ce3a0dc
10 files changed
+873
-96
No files matched your search
+14
-11
@@ -2,6 +2,9 @@
|
||||
require('../common.php');
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
session_start();
|
||||
if(empty($_SESSION['login_csrf'])){
|
||||
$_SESSION['login_csrf']=bin2hex(random_bytes(32));
|
||||
}
|
||||
if(!empty($_SESSION['hosting_username']) && empty($_SESSION['2fa_code'])){
|
||||
header('Location: home.php');
|
||||
exit;
|
||||
@@ -29,7 +32,10 @@ if($_SERVER['REQUEST_METHOD']==='POST'){
|
||||
} else {
|
||||
$db = get_db_instance();
|
||||
$ok=true;
|
||||
if($error=check_captcha_error()){
|
||||
if(!isset($_POST['login_csrf']) || !hash_equals($_SESSION['login_csrf'], $_POST['login_csrf'])){
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: Invalid request token.').'</p>';
|
||||
$ok=false;
|
||||
}elseif($error=check_captcha_error()){
|
||||
$msg.='<p role="alert" style="color:red">'.$error.'</p>';
|
||||
$ok=false;
|
||||
}elseif(!isset($_POST['username']) || $_POST['username']===''){
|
||||
@@ -52,24 +58,21 @@ if($_SERVER['REQUEST_METHOD']==='POST'){
|
||||
$stmt=$db->prepare('SELECT new_account.approved FROM new_account INNER JOIN users ON (users.id=new_account.user_id) WHERE users.id=?;');
|
||||
$stmt->execute([$tmp['id']]);
|
||||
if($tmp=$stmt->fetch(PDO::FETCH_NUM)){
|
||||
if(REQUIRE_APPROVAL && !$tmp[0]){
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: Your account is pending admin approval. Please try again later.').'</p>';
|
||||
}else{
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: Your account is pending creation. Please try again in a minute.').'</p>';
|
||||
}
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: Invalid username or password.').'</p>';
|
||||
$ok=false;
|
||||
}elseif(!isset($_POST['pass']) || !password_verify($_POST['pass'], $password)){
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: wrong password.').'</p>';
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: Invalid username or password.').'</p>';
|
||||
$ok=false;
|
||||
}
|
||||
}else{
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: username was not found. If you forgot it, you can enter youraccount.onion instead.').'</p>';
|
||||
$msg.='<p role="alert" style="color:red">'._('Error: Invalid username or password.').'</p>';
|
||||
$ok=false;
|
||||
}
|
||||
}
|
||||
if($ok){
|
||||
session_regenerate_id(true);
|
||||
$_SESSION['hosting_username']=$username;
|
||||
$_SESSION['csrf_token']=sha1(uniqid());
|
||||
$_SESSION['csrf_token']=bin2hex(random_bytes(32));
|
||||
if($tfa){
|
||||
$code = bin2hex(random_bytes(3));
|
||||
$_SESSION['2fa_code'] = $code;
|
||||
@@ -101,7 +104,7 @@ if($tfa){
|
||||
$encrypted = gnupg_encrypt($gpg, _('To login, please enter the following code to confirm ownership of your key:')."\n\n".$_SESSION['2fa_code']."\n");
|
||||
echo $msg;
|
||||
echo '<p>'._('To login, please decrypt the following PGP encrypted message and confirm the code:').'</p>';
|
||||
echo "<textarea readonly=\"readonly\" onclick=\"this.select()\" rows=\"10\" cols=\"70\">$encrypted</textarea>";
|
||||
echo '<textarea readonly="readonly" rows="10" cols="70">'.htmlspecialchars($encrypted, ENT_QUOTES, 'UTF-8').'</textarea>';
|
||||
?>
|
||||
<form action="login.php" method="post"><input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>">
|
||||
<table border="1">
|
||||
@@ -119,7 +122,7 @@ if($tfa){
|
||||
main_menu('login.php');
|
||||
echo $msg;
|
||||
?>
|
||||
<form method="POST" action="login.php"><table>
|
||||
<form method="POST" action="login.php"><input type="hidden" name="login_csrf" value="<?php echo $_SESSION['login_csrf']; ?>"><table>
|
||||
<tr><td><?php echo _('Username'); ?></td><td><input type="text" name="username" value="<?php
|
||||
if(isset($_POST['username'])){
|
||||
echo htmlspecialchars($_POST['username']);
|
||||
|
||||
Reference in new issue
Block a user