Skip to content

Commit 7808ad0

Browse files
authored
Fixed bug that RequiredIf can be exploited to generate gadget chains for deserialization vulnerabiltiies. (#3724)
1 parent 85fa8c1 commit 7808ad0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Rules/RequiredIf.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
namespace Hyperf\Validation\Rules;
1313

14+
use InvalidArgumentException;
15+
1416
class RequiredIf
1517
{
1618
/**
@@ -27,7 +29,11 @@ class RequiredIf
2729
*/
2830
public function __construct($condition)
2931
{
30-
$this->condition = $condition;
32+
if (! is_string($condition)) {
33+
$this->condition = $condition;
34+
} else {
35+
throw new InvalidArgumentException('The provided condition must be a callable or boolean.');
36+
}
3137
}
3238

3339
/**

0 commit comments

Comments
 (0)