Compare commits

..

2 Commits
main ... master

Author SHA1 Message Date
erinn f3c7f1cc0b Update 'README.md' 2021-08-20 19:13:44 +00:00
erinn c168f7c88e fix potential timing attack in password validation reported by @sweis 2021-08-20 12:11:10 -07:00
15 changed files with 20 additions and 50 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
lockbox/php/env.php
.DS_Store

View File

@ -1,13 +0,0 @@
FROM php:7.4-apache
# Set working directy at web server root
WORKDIR /var/www/html
# Manually installs Lockbox
COPY ./lockbox/ .
COPY ./config/env.example.php ./php/env.php
COPY ./config/key.public .
# Create directory to save submissions and adjust permissions
RUN mkdir /var/www/data
RUN chown -R www-data:www-data /var/www/data

View File

@ -1,13 +1,8 @@
![](lockbox/img/logo.png)
![](./img/logo.png)
This is the PHP/webserver component for Lockbox. For instructions visit [the Lockbox app`s main repository](https://git.openprivacy.ca/openprivacy/lockbox).
This is the PHP/webserver component for Lockbox. For instructions visit [the Lockbox app's main repository](https://git.openprivacy.ca/openprivacy/lockbox).
## Docker Install Instructions
Right now, there is a very basic process to building and deploying a Docker image of Lockbox in a container that contains php and an instance of apache webserver. The image has been tested on linux base OS and will need to be run of a host that already has the OS installed. Future development will aim to have a more robust install.
### Acknowledgements
Note: This version of the Docker deployment is using an `env.php` file instead of environment variables due to some of the nuances with how php handles environment variables.
The `.docker` directory contains a Dockerfile to build an image for your deployment. Do the following before building the image:
* Modify `config/env.example.php` based on any customizations
* Generate a keypair (you can use the script in the `cmd` folder (`genkeys.php.txt`, which needs to be renamed to `genkeys.php` prior to use, or use a key pair you have already generated) and place the public key in the `config` folder as `key.public`
* thanks to Steve Weis (@sweis) for reporting a potential timing attack against admin password validation

View File

@ -2,6 +2,10 @@
require_once 'php/config.inc.php';
// To generate a password hash, use the following command on a secure local machine:
// php -r 'echo password_hash("adminpasswordhere", PASSWORD_DEFAULT);'
$password = '$2y$10$ORfmg3iGr25X2Y.MYxTp5OxYC02dUF8swQ/dbeYreMR0ea0LIUk0u';
define('FORMCONTENTS', '<form method="post">
<p>Password: <input type="password" name="password"> <input type="submit" class="button-primary" value="Download encrypted submissions"></p>
</form>');
@ -28,7 +32,7 @@ if (count($ADMIN_IPS) > 0 && array_search($ip, $ADMIN_IPS) === false) {
include footer;
} else {
if (isset($_POST) && isset($_POST['password'])) {
if ($_POST['password'] === DL_PASS) {
if (password_verify($_POST['password'], $password)) {
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"submissions.dat\"");

View File

@ -1,5 +1,7 @@
<?php
require_once 'config.inc.php';
// Load private key
$privKey = base64_decode(file_get_contents("key.private"));
$pubKey = base64_decode(file_get_contents("key.public"));
@ -16,7 +18,7 @@ foreach ($encrypted_submissions as $encrypted) {
$decryptedData = sodium_crypto_box_seal_open(base64_decode($parts[1]), $keypair);
// Parse exported variable
$vars = json_decode($decryptedData, true);
eval('$vars = '.$decryptedData.';');
// Print :)
foreach ($vars as $k => $v){

View File

@ -1,16 +0,0 @@
<?php
$conf_vars = [
'LB_DL_PASS' => '',
'LB_FILE' => '/var/www/data/lockbox.dat', // This is the submissions file -- it should not be in your web directory!!!
'LB_PUBKEY_FILE' => '/var/www/html/key.public' // Absolute parth of public key file
];
// restrict the (optional) admin form to these IPs
$ips = array(
/* "127.0.0.1",
"192.168.0.0",
"172.16.0.0" */
);
?>

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -15,7 +15,7 @@ if (isset($_POST) && count($_POST)>0) {
$data = json_encode($_POST);
// pubkey is a base64-encoded key generated by sodium_crypto_box_keypair
$pubKey = base64_decode(file_get_contents(PK_FILE));
$pubKey = base64_decode(file_get_contents("key.public"));
// for now, data is stored by encrypting each submission individually, base64 encoding it,
// and appending it as a separate line onto the end of the data file (prepending with a

View File

@ -1,9 +1,7 @@
<?php
require_once 'env.php';
// This is the submissions file -- it should not be in your web directory!!!
define('FILE', $conf_vars['LB_FILE']);
define('FILE', '/var/www/data/lockbox.dat');
// Page/form title
define('MSG_TITLE', 'Lockbox by Open Privacy');
@ -24,16 +22,18 @@ define('MSG_FAIL', '
define('MSG_FOOTER', '&copy;2020 <a href="https://openprivacy.ca/" target="_blank">Our Awesome Org</a> - All rights reserved. Form powered by <a href="https://git.openprivacy.ca/openprivacy/lockbox" target="_blank">Lockbox</a> by <a href="https://openprivacy.ca" target="_blank">Open Privacy</a>');
// restrict the (optional) admin form to these IPs
$ADMIN_IPS = $ips;
$ADMIN_IPS = array(
/* "1.2.3.501", // erinn
"9.5.1.06", // sarah
"92.102.94.l" // dan*/
);
// if you would like you disable the IP check (not recommended!) you can use this line instead:
// $ADMIN_IPS = array();
// password for downloading submissions from the admin form
define('DL_PASS', $conf_vars['LB_DL_PASS']);
define('DL_PASS', "");
// This is the path to the public key file
define('PK_FILE', $conf_vars['LB_PUBKEY_FILE']);
// ============ include file locations -- you shouldn't need to change below this line