Skip to content

Commit 576f19d

Browse files
arraypressclaude
andcommitted
Placeholder salts get a warning, not a refusal to store
Treating the sample salts as no salts at all made encryption unavailable wherever they were still in place -- which is every WordPress test suite, and more live sites than anyone would like -- and a field marked encrypted then refused to store anything. A Stripe key saved as nothing, with no message on screen. The key is derived as before, and a site on the placeholders is told so where warnings are shown. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Kwx2STJ4EaVaJofEJJ9Zo
1 parent 9ed0675 commit 576f19d

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

‎src/Context/EncryptedContext.php‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,37 @@ public static function available(): bool {
282282
private static function key(): string {
283283
$salt = '';
284284

285+
$weak = false;
286+
285287
foreach ( [ 'LOGGED_IN_KEY', 'LOGGED_IN_SALT', 'AUTH_KEY', 'SECURE_AUTH_KEY' ] as $constant ) {
286288
$part = defined( $constant ) ? (string) constant( $constant ) : '';
287289

288-
// The phrase wp-config-sample.php ships with is public, and a key
289-
// derived from it is no key at all.
290-
if ( '' === $part || 'put your unique phrase here' === $part ) {
290+
if ( '' === $part ) {
291291
continue;
292292
}
293293

294+
// The phrase wp-config-sample.php ships with is public, and a key
295+
// derived from it is no key at all. It is still used: refusing
296+
// to store anything left a Stripe key blank on every site and
297+
// every test suite that never set its salts, with nothing on
298+
// screen to say why. The site is warned instead, where warnings
299+
// are shown, and its cookies are forgeable with those salts in
300+
// any case.
301+
if ( 'put your unique phrase here' === $part ) {
302+
$weak = true;
303+
}
304+
294305
$salt .= $part;
295306
}
296307

308+
if ( $weak && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
309+
_doing_it_wrong(
310+
__METHOD__,
311+
esc_html__( 'The salts in wp-config.php are the placeholders from wp-config-sample.php, so the key that encrypts these fields is public. Set unique salts.', 'arraypress' ),
312+
'1.0.0'
313+
);
314+
}
315+
297316
return '' === $salt ? '' : hash( 'sha256', $salt, true );
298317
}
299318

0 commit comments

Comments
 (0)