Skip to content

Commit 8368db0

Browse files
committed
Mark parameter in ext/standard as sensitive
No changes to the stubs required, password_hash and password_verify were added to the initial version of the stub support.
1 parent 880803a commit 8368db0

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,8 @@ function unpack(string $format, string $string, int $offset = 0): array|false {}
16361636
function password_get_info(string $hash): array {}
16371637

16381638
/**
1639-
* @refcount 1
16401639
* @sensitive-param $password
1640+
* @refcount 1
16411641
*/
16421642
function password_hash(string $password, string|int|null $algo, array $options = []): string {}
16431643

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test that the password parameter is marked sensitive.
3+
--FILE--
4+
<?php
5+
try {
6+
var_dump(password_hash("foo"));
7+
} catch (\Throwable $e) {
8+
echo $e, PHP_EOL;
9+
}
10+
try {
11+
var_dump(password_hash("foo", "Invalid"));
12+
} catch (\Throwable $e) {
13+
echo $e, PHP_EOL;
14+
}
15+
?>
16+
--EXPECTF--
17+
ArgumentCountError: password_hash() expects at least 2 arguments, 1 given in %spassword_hash_sensitive_parameter.php:3
18+
Stack trace:
19+
#0 %spassword_hash_sensitive_parameter.php(3): password_hash(Object(SensitiveParameterValue))
20+
#1 {main}
21+
ValueError: password_hash(): Argument #2 ($algo) must be a valid password hashing algorithm in%spassword_hash_sensitive_parameter.php:8
22+
Stack trace:
23+
#0 %spassword_hash_sensitive_parameter.php(8): password_hash(Object(SensitiveParameterValue), 'Invalid')
24+
#1 {main}

0 commit comments

Comments
 (0)