-
Notifications
You must be signed in to change notification settings - Fork 7.9k
main: Change the register_argc_argv
INI default to Off
#19473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@cmb69 Any idea for the Windows-specific failure? |
The tests/basic/011.phpt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/basic/011.phpt b/tests/basic/011.phpt
index 03fccaa9b70..fd359fe4032 100644
--- a/tests/basic/011.phpt
+++ b/tests/basic/011.phpt
@@ -3,7 +3,7 @@
--INI--
register_argc_argv=1
--GET--
-ab+cd+ef+123+test
+foo=ab+cd+ef+123+test
--FILE--
<?php
$argc = $_SERVER['argc'];
@@ -15,7 +15,7 @@
?>
--EXPECT--
-0: ab
+0: foo=ab
1: cd
2: ef
3: 123 |
@cmb69 Thanks. What a terrible behavioral difference. So I just realized /cc @nicolas-grekas |
CGI is what |
Sorry for dropping the ball on this. I've thought about this a little more now and I think the solution proposed in the RFC is not quite ideal. To spell it out once more: Now my understanding is that the security concerns are with regard to So it would make sense to me to:
This would make the implementation much simpler and more predictable, since we would not need to define what a CLI SAPI is. Changing the built-in default to make PHP safer when running without an INI (i.e. what this PR does) definitely makes sense. But I would perhaps defer emitting a deprecation notice to PHP 8.6 and then do another vote based on these new findings? |
Not sure what made you think so but |
Quoting from the RFC text:
Okay. Can you explain the Symfony fix for me? Why is it checking for |
Because hardcoding the list of SAPI keeps the issue open for unlisted SAPIs. The world is more vast than just the current public SAPIs. About the patch: the issue happens with specially crafted query strings. When |
Well, that's an ellipsis in the RFC, I should have mentioned any variant of those variables (aka what is in _SERVER also). |
So, basically what the RFC actually intended to propose (XY problem) is the following:
In that case, the proper fix is not deprecating the INI setting, but rather emitting a deprecation notice when this code path is taken: Lines 678 to 679 in e844e68
diff --git i/main/php_variables.c w/main/php_variables.c
index 91eb0a7f5ce..72ec60e814f 100644
--- i/main/php_variables.c
+++ w/main/php_variables.c
@@ -676,6 +676,7 @@ PHPAPI void php_build_argv(const char *s, zval *track_vars_array)
}
}
} else if (s && *s) {
+ zend_error(E_DEPRECATED, "Deriving the argc from query_string is deprecated");
while (1) {
const char *space = strchr(s, '+');
/* auto-type */ results in:
and when running with the integrated web server:
is printed. The latter output also makes me realize that |
No, because it would be an allow-list: Bail out when the SAPI is not CLI, i.e. as the very first line of the application you would use:
Yes, I understand. But I'm trying to fully understand the situation before proposing a change that does not actually do the right thing. |
Or to clarify: The deprecation notice would mention the INI setting as a fix to suppress the deprecation message, but the issue is not with the INI setting itself, which to me is an important distinction in the mental model. |
Not sure there's any difference in practical terms. |
If it had done that, I would have voted against it. But it didn't, so we can't change the behaviour to remove these from |
It may make sense to discuss this issue on internals. |
I'm not sure where the quoted sentence says that. |
This partly implements the deprecation of the `register_argc_argv` INI setting by updating the default value to ensure safe behavior when no INI file is loaded. The actual deprecation warning will follow separately. RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive
2d7056b
to
93974c6
Compare
@cmb69 After the discussion with Nicolas I've properly understood both the current behavior and the problem. A draft for the actual deprecation notice that matches the RFC intent is in #19606. This PR should be good to go, since it just changes the built-in default to match the recommended default of the example INIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable and matches the RFC proposal AFAIU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RM approval
This partly implements the deprecation of the
register_argc_argv
INI setting by updating the default value to ensure safe behavior when no INI file is loaded. The actual deprecation warning will follow separately.RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive