diff options
| author | jvoisin | 2022-03-20 18:20:45 +0100 |
|---|---|---|
| committer | jvoisin | 2022-03-20 18:20:45 +0100 |
| commit | 81dd7f2ef07af306fe83d7755cbac4529aa9fc8d (patch) | |
| tree | 32cc44c6231b30db5ac7b15699297863460784aa /src/tests/session_encryption | |
| parent | 83b01942dfc80474cc05e09aeef4b44307a7120b (diff) | |
| parent | c38df1077a6c1dfbca1baca049214d053e2e7684 (diff) | |
Merge remote-tracking branch 'sektioneins/master'
Diffstat (limited to 'src/tests/session_encryption')
11 files changed, 52 insertions, 19 deletions
diff --git a/src/tests/session_encryption/config/config_crypt_session.ini b/src/tests/session_encryption/config/config_crypt_session.ini index 14b0c2c..054f0f8 100644 --- a/src/tests/session_encryption/config/config_crypt_session.ini +++ b/src/tests/session_encryption/config/config_crypt_session.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.session.encrypt(); \ No newline at end of file | 2 | sp.session.encrypt(); \ No newline at end of file |
diff --git a/src/tests/session_encryption/config/config_crypt_session_simul.ini b/src/tests/session_encryption/config/config_crypt_session_simul.ini index fbd43eb..5e3433b 100644 --- a/src/tests/session_encryption/config/config_crypt_session_simul.ini +++ b/src/tests/session_encryption/config/config_crypt_session_simul.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.session.encrypt(); | 2 | sp.session.encrypt(); |
| 3 | sp.session.simulation(); \ No newline at end of file | 3 | sp.session.simulation(); \ No newline at end of file |
diff --git a/src/tests/session_encryption/crypt_session_corrupted_session.phpt b/src/tests/session_encryption/crypt_session_corrupted_session.phpt index a97dbca..eca43b4 100644 --- a/src/tests/session_encryption/crypt_session_corrupted_session.phpt +++ b/src/tests/session_encryption/crypt_session_corrupted_session.phpt | |||
| @@ -2,11 +2,12 @@ | |||
| 2 | Set a custom session handler | 2 | Set a custom session handler |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (!extension_loaded("session")) print "skip"; ?> |
| 6 | <?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> | 6 | --EXTENSIONS-- |
| 7 | session | ||
| 7 | --INI-- | 8 | --INI-- |
| 8 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 9 | session.save_path = "/tmp" | 10 | session.save_path="/tmp" |
| 10 | --ENV-- | 11 | --ENV-- |
| 11 | return <<<EOF | 12 | return <<<EOF |
| 12 | REMOTE_ADDR=127.0.0.1 | 13 | REMOTE_ADDR=127.0.0.1 |
| @@ -29,4 +30,4 @@ session_start(); | |||
| 29 | var_dump($_SESSION); | 30 | var_dump($_SESSION); |
| 30 | ?> | 31 | ?> |
| 31 | --EXPECTF-- | 32 | --EXPECTF-- |
| 32 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow tentative detected in cookie encryption handling in %s/crypt_session_corrupted_session.php on line %s | 33 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow (tentative) detected in cookie encryption handling in %s/crypt_session_corrupted_session.php on line %s |
diff --git a/src/tests/session_encryption/crypt_session_invalid.phpt b/src/tests/session_encryption/crypt_session_invalid.phpt index 967d9d1..a71a601 100644 --- a/src/tests/session_encryption/crypt_session_invalid.phpt +++ b/src/tests/session_encryption/crypt_session_invalid.phpt | |||
| @@ -2,8 +2,9 @@ | |||
| 2 | SESSION crypt and bad decrypt | 2 | SESSION crypt and bad decrypt |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (!extension_loaded("session")) print "skip"; ?> |
| 6 | <?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> | 6 | --EXTENSIONS-- |
| 7 | session | ||
| 7 | --INI-- | 8 | --INI-- |
| 8 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 9 | --ENV-- | 10 | --ENV-- |
diff --git a/src/tests/session_encryption/crypt_session_invalid_simul.phpt b/src/tests/session_encryption/crypt_session_invalid_simul.phpt index cbb80dc..3eb619c 100644 --- a/src/tests/session_encryption/crypt_session_invalid_simul.phpt +++ b/src/tests/session_encryption/crypt_session_invalid_simul.phpt | |||
| @@ -2,8 +2,14 @@ | |||
| 2 | SESSION crypt and bad decrypt | 2 | SESSION crypt and bad decrypt |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini |
| 10 | display_errors=0 | ||
| 11 | log_errors=1 | ||
| 12 | error_log="{PWD}"/crypt_session_invalid_simul.tmp | ||
| 7 | --ENV-- | 13 | --ENV-- |
| 8 | return <<<EOF | 14 | return <<<EOF |
| 9 | REMOTE_ADDR=127.0.0.1 | 15 | REMOTE_ADDR=127.0.0.1 |
| @@ -19,9 +25,12 @@ putenv("REMOTE_ADDR=127.0.0.2"); | |||
| 19 | session_id($id); // Recover the session with the previous session_id | 25 | session_id($id); // Recover the session with the previous session_id |
| 20 | session_start(); // Re start the session, It will read and decrypt the non empty session | 26 | session_start(); // Re start the session, It will read and decrypt the non empty session |
| 21 | var_dump($_SESSION); // Dump the session | 27 | var_dump($_SESSION); // Dump the session |
| 28 | |||
| 29 | echo file_get_contents(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp"); | ||
| 30 | unlink(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp"); | ||
| 31 | |||
| 22 | ?> | 32 | ?> |
| 23 | --EXPECTF-- | 33 | --EXPECTF-- |
| 24 | array(1) { | 34 | array(0) { |
| 25 | ["toto"]=> | ||
| 26 | string(4) "tata" | ||
| 27 | } | 35 | } |
| 36 | %sPHP Warning: [snuffleupagus][127.0.0.2][cookie_encryption][simulation] Something went wrong with the decryption of the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_invalid_simul.php on line 9%A \ No newline at end of file | ||
diff --git a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt index 5e81b52..5966f8e 100644 --- a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt +++ b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt | |||
| @@ -2,27 +2,33 @@ | |||
| 2 | SESSION crypt/decrypt valid | 2 | SESSION crypt/decrypt valid |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini |
| 10 | session.save_path="{PWD}" | ||
| 11 | display_errors=0 | ||
| 12 | log_errors=1 | ||
| 13 | error_log="{PWD}"/crypt_session_read_uncrypt.tmp | ||
| 7 | --ENV-- | 14 | --ENV-- |
| 8 | return <<<EOF | 15 | return <<<EOF |
| 9 | REMOTE_ADDR=127.0.0.1 | 16 | REMOTE_ADDR=127.0.0.1 |
| 10 | EOF; | 17 | EOF; |
| 11 | --FILE-- | 18 | --FILE-- |
| 12 | <?php | 19 | <?php |
| 13 | $current_path = dirname(getcwd()) . "/src/tests/" ; | ||
| 14 | ini_set("session.save_path", $current_path); | ||
| 15 | |||
| 16 | session_start(); | 20 | session_start(); |
| 17 | $id = session_id(); // Get the session_id to use it later | 21 | $id = session_id(); // Get the session_id to use it later |
| 18 | $filename_sess = $current_path . "sess_" . $id; | 22 | $filename_sess = dirname(__FILE__) . "/sess_" . $id; |
| 19 | file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write a unencrypted session | 23 | file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write unencrypted session |
| 20 | session_write_close(); // Close the session | 24 | session_write_close(); // Close the session |
| 21 | 25 | ||
| 22 | session_id($id); | 26 | session_id($id); |
| 23 | session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session | 27 | session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session |
| 24 | var_dump($_SESSION); | 28 | var_dump($_SESSION); |
| 25 | echo "OK"; | 29 | echo "OK\n"; |
| 30 | echo file_get_contents(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp"); | ||
| 31 | unlink(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp"); | ||
| 26 | unlink($filename_sess); | 32 | unlink($filename_sess); |
| 27 | ?> | 33 | ?> |
| 28 | --EXPECTF-- | 34 | --EXPECTF-- |
| @@ -31,3 +37,4 @@ array(1) { | |||
| 31 | string(4) "tata" | 37 | string(4) "tata" |
| 32 | } | 38 | } |
| 33 | OK | 39 | OK |
| 40 | %aPHP Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Buffer underflow tentative detected in cookie encryption handling for the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_read_uncrypt.php on line 9 | ||
diff --git a/src/tests/session_encryption/crypt_session_valid.phpt b/src/tests/session_encryption/crypt_session_valid.phpt index c272486..a28685b 100644 --- a/src/tests/session_encryption/crypt_session_valid.phpt +++ b/src/tests/session_encryption/crypt_session_valid.phpt | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | SESSION crypt/decrypt valid | 2 | SESSION crypt/decrypt valid |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | --ENV-- | 10 | --ENV-- |
diff --git a/src/tests/session_encryption/crypt_session_valid_simul.phpt b/src/tests/session_encryption/crypt_session_valid_simul.phpt index d63277d..6af015e 100644 --- a/src/tests/session_encryption/crypt_session_valid_simul.phpt +++ b/src/tests/session_encryption/crypt_session_valid_simul.phpt | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | SESSION crypt/decrypt valid | 2 | SESSION crypt/decrypt valid |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini |
| 7 | --ENV-- | 10 | --ENV-- |
diff --git a/src/tests/session_encryption/set_custom_session_handler.phpt b/src/tests/session_encryption/set_custom_session_handler.phpt index 725ee43..04edcd0 100644 --- a/src/tests/session_encryption/set_custom_session_handler.phpt +++ b/src/tests/session_encryption/set_custom_session_handler.phpt | |||
| @@ -2,9 +2,12 @@ | |||
| 2 | Set a custom session handler | 2 | Set a custom session handler |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | session.save_path = "/tmp" | 10 | session.save_path="/tmp" |
| 8 | --ENV-- | 11 | --ENV-- |
| 9 | return <<<EOF | 12 | return <<<EOF |
| 10 | REMOTE_ADDR=127.0.0.1 | 13 | REMOTE_ADDR=127.0.0.1 |
diff --git a/src/tests/session_encryption/set_custom_session_handler2.phpt b/src/tests/session_encryption/set_custom_session_handler2.phpt index 8cc6786..0ebf7b6 100644 --- a/src/tests/session_encryption/set_custom_session_handler2.phpt +++ b/src/tests/session_encryption/set_custom_session_handler2.phpt | |||
| @@ -2,9 +2,12 @@ | |||
| 2 | Set a custom session handler, twice | 2 | Set a custom session handler, twice |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | session.save_path = "/tmp" | 10 | session.save_path="/tmp" |
| 8 | --ENV-- | 11 | --ENV-- |
| 9 | return <<<EOF | 12 | return <<<EOF |
| 10 | REMOTE_ADDR=127.0.0.1 | 13 | REMOTE_ADDR=127.0.0.1 |
diff --git a/src/tests/session_encryption/set_custom_session_handler_ini.phpt b/src/tests/session_encryption/set_custom_session_handler_ini.phpt index f9fbfb2..a454fc6 100644 --- a/src/tests/session_encryption/set_custom_session_handler_ini.phpt +++ b/src/tests/session_encryption/set_custom_session_handler_ini.phpt | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | Set a custom session handler | 2 | Set a custom session handler |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | session.save_handler = | 10 | session.save_handler = |
