Skip to content

Commit e0905cd

Browse files
bug #52469 Check whether secrets are empty and mark them all as sensitive (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- Check whether secrets are empty and mark them all as sensitive | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Some security-hardening. I made this throw a deprecation (as was already the case in some places) but I'd be fine making them throw an exception right away since an empty secret is a bold mistake. WDYT? (Webhook was experimental in 6.3 so it's fine throwing there I think.) Commits ------- 52ca699707 Check whether secrets are empty and mark them all as sensitive
2 parents f0179cf + c5b1134 commit e0905cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

UriSigner.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\HttpFoundation;
1313

1414
/**
15-
* Signs URIs.
16-
*
1715
* @author Fabien Potencier <[email protected]>
1816
*/
1917
class UriSigner
@@ -22,11 +20,14 @@ class UriSigner
2220
private string $parameter;
2321

2422
/**
25-
* @param string $secret A secret
2623
* @param string $parameter Query string parameter to use
2724
*/
2825
public function __construct(#[\SensitiveParameter] string $secret, string $parameter = '_hash')
2926
{
27+
if (!$secret) {
28+
throw new \InvalidArgumentException('A non-empty secret is required.');
29+
}
30+
3031
$this->secret = $secret;
3132
$this->parameter = $parameter;
3233
}

0 commit comments

Comments
 (0)