Plugin Directory

Changeset 3841457


Ignore:
Timestamp:
12/03/2026 02:21:50 AM (less than one hour ago)
Author:
lunixi
Message:

Lunixi 1.2.3: fix credentials stored on the first settings save of a new installation

Location:
lunixi
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • lunixi/tags/1.2.3/CHANGELOG.md

    r3841374 r3841457  
    11# Changelog
     2
     3## 1.2.3 — 2026-12-03
     4
     5- Settings secrets (private key, webhook secret, automation secret) were encrypted twice on the first save of a new installation: WordPress runs the option's sanitize callback twice when `update_option()` falls through to `add_option()`, and the second pass encrypted the first pass's ciphertext. The stored secret then decrypted to ciphertext, so request signing and webhook verification failed until the merchant saved the secrets again. `SecretBox::seal()` keeps a value that is already our ciphertext, and `SecretBox::decrypt()` unwraps a value encrypted twice by earlier releases, so affected sites recover without re-entering their credentials. Reproduced and verified in WordPress Playground.
    26
    37## 1.2.2 — 2026-12-02
  • lunixi/tags/1.2.3/lunixi.php

    r3841374 r3841457  
    55 * Plugin URI:        https://lunixi.com/integrations/wordpress
    66 * Description:       Lunixi payments for WooCommerce: card checkout with 3D Secure, pre-authorization, refunds and signed webhooks, plus fraud, subscription, KYC and sanction screening.
    7  * Version:           1.2.2
     7 * Version:           1.2.3
    88 * Requires at least: 6.4
    99 * Requires PHP:      7.4
    … …  
    2828    // already loaded
    2929}
    30 \define('LUNIXI_VERSION', '1.2.2');
     30\define('LUNIXI_VERSION', '1.2.3');
    3131\define('LUNIXI_FILE', __FILE__);
    3232\define('LUNIXI_PATH', \plugin_dir_path(__FILE__));
  • lunixi/tags/1.2.3/readme.txt

    r3841374 r3841457  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.2
     7Stable tag: 1.2.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    117117== Changelog ==
    118118
     119= 1.2.3 =
     120* Fixed: on a new installation, the private key, webhook secret and automation secret were stored incorrectly the first time the settings were saved, so payments and webhooks did not work until the settings were saved again. Sites affected by this are repaired automatically after the update.
     121
    119122= 1.2.2 =
    120123* Fixed a fatal error when the Automation module was enabled and a Contact Form 7 form was submitted.
    … …  
    189192== Upgrade Notice ==
    190193
     194= 1.2.3 =
     195Fixes credentials saved on a new installation; affected sites are repaired automatically.
     196
    191197= 1.2.0 =
    192198Payments now require the buyer's details, including a TR identity number or passport number, which the checkout asks for. Orders missing a detail do not start a payment.
  • lunixi/tags/1.2.3/src/Core/SecretBox.php

    r3841374 r3841457  
    1414{
    1515    private const PREFIX = 'v1:';
     16    /**
     17     * Encrypts a value coming from the settings form, but keeps a value that is
     18     * already one of our ciphertexts. WordPress runs an option's sanitize
     19     * callback twice when the option is first created (update_option() falls
     20     * through to add_option(), which sanitizes again), so the second pass sees
     21     * the first pass's ciphertext. Encrypting it again would store a secret
     22     * that decrypts to ciphertext instead of the merchant's key.
     23     */
     24    public static function seal(string $value): string
     25    {
     26        if ($value === '' || self::open($value) !== null) {
     27            return $value;
     28        }
     29        return self::encrypt($value);
     30    }
    1631    public static function encrypt(string $plain): string
    1732    {
    … …  
    3348            // tolerate a value saved before encryption was enabled
    3449        }
     50        $plain = self::open($stored);
     51        if ($plain === null) {
     52            return '';
     53        }
     54        // Settings saved by 1.2.2 and earlier on a fresh install were encrypted
     55        // twice (see seal()); unwrap the extra layer so those sites keep working.
     56        $inner = self::open($plain);
     57        return $inner ?? $plain;
     58    }
     59    /** Opens one of our ciphertexts; null when the value is not one (or the key changed). */
     60    private static function open(string $stored): ?string
     61    {
     62        if (strncmp($stored, self::PREFIX, strlen(self::PREFIX)) !== 0) {
     63            return null;
     64        }
    3565        // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- storage encoding of the libsodium ciphertext, not code.
    3666        $raw = base64_decode(substr($stored, strlen(self::PREFIX)), \true);
    3767        if ($raw === \false || strlen($raw) <= \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES) {
    38             return '';
     68            return null;
    3969        }
    4070        $nonce = substr($raw, 0, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
    4171        $cipher = substr($raw, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
    4272        $plain = sodium_crypto_secretbox_open($cipher, $nonce, self::key());
    43         return $plain === \false ? '' : $plain;
     73        return $plain === \false ? null : $plain;
    4474    }
    4575    private static function key(): string
  • lunixi/tags/1.2.3/src/Core/Settings.php

    r3841374 r3841457  
    247247        $out = ['environment' => isset($input['environment']) && strtoupper((string) $input['environment']) === 'TEST' ? 'TEST' : 'LIVE', 'key_id' => sanitize_text_field((string) ($input['key_id'] ?? '')), 'base_url' => esc_url_raw((string) ($input['base_url'] ?? ''))];
    248248        $privateKey = trim(sanitize_textarea_field((string) ($input['private_key'] ?? '')));
    249         $out['private_key'] = $privateKey !== '' ? \Lunixi\WP\Core\SecretBox::encrypt($privateKey) : (string) ($existing['private_key'] ?? '');
     249        $out['private_key'] = $privateKey !== '' ? \Lunixi\WP\Core\SecretBox::seal($privateKey) : (string) ($existing['private_key'] ?? '');
    250250        $webhookSecret = self::secret($input['webhook_secret'] ?? '');
    251         $out['webhook_secret'] = $webhookSecret !== '' ? \Lunixi\WP\Core\SecretBox::encrypt($webhookSecret) : (string) ($existing['webhook_secret'] ?? '');
     251        $out['webhook_secret'] = $webhookSecret !== '' ? \Lunixi\WP\Core\SecretBox::seal($webhookSecret) : (string) ($existing['webhook_secret'] ?? '');
    252252        $out['debug'] = !empty($input['debug']) ? '1' : '';
    253253        $portalMode = (string) ($input['portal_mode'] ?? 'embed');
    … …  
    266266        $out['automation_integration_id'] = sanitize_text_field((string) ($input['automation_integration_id'] ?? ''));
    267267        $automationSecret = self::secret($input['automation_secret'] ?? '');
    268         $out['automation_secret'] = $automationSecret !== '' ? \Lunixi\WP\Core\SecretBox::encrypt($automationSecret) : (string) ($existing['automation_secret'] ?? '');
     268        $out['automation_secret'] = $automationSecret !== '' ? \Lunixi\WP\Core\SecretBox::seal($automationSecret) : (string) ($existing['automation_secret'] ?? '');
    269269        $out['identity_enabled'] = !empty($input['identity_enabled']) ? '1' : '';
    270270        $out['identity_publishable_key'] = sanitize_text_field((string) ($input['identity_publishable_key'] ?? ''));
  • lunixi/tags/1.2.3/vendor/scoped-package.json

    r3841374 r3841457  
    11{
    2     "pluginVersion": "1.2.2",
     2    "pluginVersion": "1.2.3",
    33    "sdk": {
    44        "name": "lunixi/php-sdk",
  • lunixi/trunk/CHANGELOG.md

    r3841374 r3841457  
    11# Changelog
     2
     3## 1.2.3 — 2026-12-03
     4
     5- Settings secrets (private key, webhook secret, automation secret) were encrypted twice on the first save of a new installation: WordPress runs the option's sanitize callback twice when `update_option()` falls through to `add_option()`, and the second pass encrypted the first pass's ciphertext. The stored secret then decrypted to ciphertext, so request signing and webhook verification failed until the merchant saved the secrets again. `SecretBox::seal()` keeps a value that is already our ciphertext, and `SecretBox::decrypt()` unwraps a value encrypted twice by earlier releases, so affected sites recover without re-entering their credentials. Reproduced and verified in WordPress Playground.
    26
    37## 1.2.2 — 2026-12-02
  • lunixi/trunk/lunixi.php

    r3841374 r3841457  
    55 * Plugin URI:        https://lunixi.com/integrations/wordpress
    66 * Description:       Lunixi payments for WooCommerce: card checkout with 3D Secure, pre-authorization, refunds and signed webhooks, plus fraud, subscription, KYC and sanction screening.
    7  * Version:           1.2.2
     7 * Version:           1.2.3
    88 * Requires at least: 6.4
    99 * Requires PHP:      7.4
    … …  
    2828    // already loaded
    2929}
    30 \define('LUNIXI_VERSION', '1.2.2');
     30\define('LUNIXI_VERSION', '1.2.3');
    3131\define('LUNIXI_FILE', __FILE__);
    3232\define('LUNIXI_PATH', \plugin_dir_path(__FILE__));
  • lunixi/trunk/readme.txt

    r3841374 r3841457  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.2
     7Stable tag: 1.2.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    117117== Changelog ==
    118118
     119= 1.2.3 =
     120* Fixed: on a new installation, the private key, webhook secret and automation secret were stored incorrectly the first time the settings were saved, so payments and webhooks did not work until the settings were saved again. Sites affected by this are repaired automatically after the update.
     121
    119122= 1.2.2 =
    120123* Fixed a fatal error when the Automation module was enabled and a Contact Form 7 form was submitted.
    … …  
    189192== Upgrade Notice ==
    190193
     194= 1.2.3 =
     195Fixes credentials saved on a new installation; affected sites are repaired automatically.
     196
    191197= 1.2.0 =
    192198Payments now require the buyer's details, including a TR identity number or passport number, which the checkout asks for. Orders missing a detail do not start a payment.
  • lunixi/trunk/src/Core/SecretBox.php

    r3841374 r3841457  
    1414{
    1515    private const PREFIX = 'v1:';
     16    /**
     17     * Encrypts a value coming from the settings form, but keeps a value that is
     18     * already one of our ciphertexts. WordPress runs an option's sanitize
     19     * callback twice when the option is first created (update_option() falls
     20     * through to add_option(), which sanitizes again), so the second pass sees
     21     * the first pass's ciphertext. Encrypting it again would store a secret
     22     * that decrypts to ciphertext instead of the merchant's key.
     23     */
     24    public static function seal(string $value): string
     25    {
     26        if ($value === '' || self::open($value) !== null) {
     27            return $value;
     28        }
     29        return self::encrypt($value);
     30    }
    1631    public static function encrypt(string $plain): string
    1732    {
    … …  
    3348            // tolerate a value saved before encryption was enabled
    3449        }
     50        $plain = self::open($stored);
     51        if ($plain === null) {
     52            return '';
     53        }
     54        // Settings saved by 1.2.2 and earlier on a fresh install were encrypted
     55        // twice (see seal()); unwrap the extra layer so those sites keep working.
     56        $inner = self::open($plain);
     57        return $inner ?? $plain;
     58    }
     59    /** Opens one of our ciphertexts; null when the value is not one (or the key changed). */
     60    private static function open(string $stored): ?string
     61    {
     62        if (strncmp($stored, self::PREFIX, strlen(self::PREFIX)) !== 0) {
     63            return null;
     64        }
    3565        // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- storage encoding of the libsodium ciphertext, not code.
    3666        $raw = base64_decode(substr($stored, strlen(self::PREFIX)), \true);
    3767        if ($raw === \false || strlen($raw) <= \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES) {
    38             return '';
     68            return null;
    3969        }
    4070        $nonce = substr($raw, 0, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
    4171        $cipher = substr($raw, \SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
    4272        $plain = sodium_crypto_secretbox_open($cipher, $nonce, self::key());
    43         return $plain === \false ? '' : $plain;
     73        return $plain === \false ? null : $plain;
    4474    }
    4575    private static function key(): string
  • lunixi/trunk/src/Core/Settings.php

    r3841374 r3841457  
    247247        $out = ['environment' => isset($input['environment']) && strtoupper((string) $input['environment']) === 'TEST' ? 'TEST' : 'LIVE', 'key_id' => sanitize_text_field((string) ($input['key_id'] ?? '')), 'base_url' => esc_url_raw((string) ($input['base_url'] ?? ''))];
    248248        $privateKey = trim(sanitize_textarea_field((string) ($input['private_key'] ?? '')));
    249         $out['private_key'] = $privateKey !== '' ? \Lunixi\WP\Core\SecretBox::encrypt($privateKey) : (string) ($existing['private_key'] ?? '');
     249        $out['private_key'] = $privateKey !== '' ? \Lunixi\WP\Core\SecretBox::seal($privateKey) : (string) ($existing['private_key'] ?? '');
    250250        $webhookSecret = self::secret($input['webhook_secret'] ?? '');
    251         $out['webhook_secret'] = $webhookSecret !== '' ? \Lunixi\WP\Core\SecretBox::encrypt($webhookSecret) : (string) ($existing['webhook_secret'] ?? '');
     251        $out['webhook_secret'] = $webhookSecret !== '' ? \Lunixi\WP\Core\SecretBox::seal($webhookSecret) : (string) ($existing['webhook_secret'] ?? '');
    252252        $out['debug'] = !empty($input['debug']) ? '1' : '';
    253253        $portalMode = (string) ($input['portal_mode'] ?? 'embed');
    … …  
    266266        $out['automation_integration_id'] = sanitize_text_field((string) ($input['automation_integration_id'] ?? ''));
    267267        $automationSecret = self::secret($input['automation_secret'] ?? '');
    268         $out['automation_secret'] = $automationSecret !== '' ? \Lunixi\WP\Core\SecretBox::encrypt($automationSecret) : (string) ($existing['automation_secret'] ?? '');
     268        $out['automation_secret'] = $automationSecret !== '' ? \Lunixi\WP\Core\SecretBox::seal($automationSecret) : (string) ($existing['automation_secret'] ?? '');
    269269        $out['identity_enabled'] = !empty($input['identity_enabled']) ? '1' : '';
    270270        $out['identity_publishable_key'] = sanitize_text_field((string) ($input['identity_publishable_key'] ?? ''));
  • lunixi/trunk/vendor/scoped-package.json

    r3841374 r3841457  
    11{
    2     "pluginVersion": "1.2.2",
     2    "pluginVersion": "1.2.3",
    33    "sdk": {
    44        "name": "lunixi/php-sdk",
Note: See TracChangeset for help on using the changeset viewer.