Skip to content

simple ignore arguments in exceptions implementation - #4282

Closed
krakjoe wants to merge 1 commit into
php:PHP-7.4from
krakjoe:zend-backtrace-ignore-args-setting
Closed

simple ignore arguments in exceptions implementation#4282
krakjoe wants to merge 1 commit into
php:PHP-7.4from
krakjoe:zend-backtrace-ignore-args-setting

Conversation

@krakjoe

Copy link
Copy Markdown
Member

As alternative to and for the author of #4281

@krakjoe
krakjoeforce-pushed the zend-backtrace-ignore-args-setting branch from 824e7f2 to 36678f9CompareJune 17, 2019 18:57
@eriklundin

Copy link
Copy Markdown
Contributor

Short and elegant. Should be enabled by default to protect blissfully unaware sysadmins though. It would probably require fixing a lot of tests which seems to be dependant on the data in stack traces?

@nikic

Copy link
Copy Markdown
Member

Would be good to test that this doesn't affect debug_backtrace/debug_print_backtrace (which already support this as an explicit call option).

@krakjoe
krakjoeforce-pushed the zend-backtrace-ignore-args-setting branch from 36678f9 to 5a76ec2CompareJune 17, 2019 19:53
@krakjoe

krakjoe commented Jun 17, 2019

Copy link
Copy Markdown
MemberAuthor

Would be good to test that this doesn't affect debug_backtrace/debug_print_backtrace (which already support this as an explicit call option).

Fixed that, we don't want to modify the behaviour of the API function, as I did at first , we just want new exceptions to take notice of the ini setting, and retain all other (internal/user) APIs as they are ...

@krakjoe
krakjoeforce-pushed the zend-backtrace-ignore-args-setting branch 2 times, most recently from 415aac5 to 882bed3CompareJune 17, 2019 20:07
@krakjoekrakjoe changed the title simple ignore arguments in backtrace implementationsimple ignore arguments in exceptions implementationJun 17, 2019
@krakjoe

Copy link
Copy Markdown
MemberAuthor

Note, no need to test debug_backtrace and debug_print_backtrace as modification is contained in new exception routine ...

Comment threadZend/zend.c Outdated
@krakjoe
krakjoeforce-pushed the zend-backtrace-ignore-args-setting branch from 882bed3 to a1df5f4CompareJune 17, 2019 20:39
@nikic

Copy link
Copy Markdown
Member

This needs entries in php.ini-development and php.ini-production for the new ini option.

@krakjoe
krakjoeforce-pushed the zend-backtrace-ignore-args-setting branch from a1df5f4 to 8ba1caeCompareJune 18, 2019 07:47
@krakjoe

Copy link
Copy Markdown
MemberAuthor

CI failures are unrelated ...

@nikicnikic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but let's wait a couple of days in case anyone has more feedback here.

@krakjoe

Copy link
Copy Markdown
MemberAuthor

ACK

@nikic

Copy link
Copy Markdown
Member

Short and elegant. Should be enabled by default to protect blissfully unaware sysadmins though. It would probably require fixing a lot of tests which seems to be dependant on the data in stack traces?

This PR enables zend.exception_ignore_args in php.ini-production. I think that's the right way to do this, as the general PHP defaults (without explicit ini file) are mostly geared towards development (we should probably fix the remaining discrepancies).

@dstogov

Copy link
Copy Markdown
Member

Personally, I think it's not a good idea to use INI directive to control argument collection.
declare() might be more natural.

@eriklundin

Copy link
Copy Markdown
Contributor

I have tested this now on a few development servers and Joe's fix seems to work great. I definitely think this should be declared on a server level (INI-file) and not disabled on a per script basis with declare().

@staabm

Copy link
Copy Markdown
Contributor

Personally, I think it's not a good idea to use INI directive to control argument collection.
declare() might be more natural.

maybe it makes sense to forbidd setting it via ini_set() at runtime but leave it in php.ini ?

@krakjoe

krakjoe commented Jun 19, 2019

Copy link
Copy Markdown
MemberAuthor

declare() might be more natural.

The decision to change this behaviour should be at application level, not really the author of some piece of code within an application. I can't think of any code that both throws exceptions and should need to be certain that stacktraces do not contain arguments. No such code can exist today.

maybe it makes sense to forbidd setting it via ini_set() at runtime but leave it in php.ini ?

The best justification for limiting a configuration setting to PHP_INI_SYSTEM is a technical justification/limitation, and since that doesn't exist here, it would seem like an arbitrary restriction to impose.

If we were to impose a system limit, that would remove the ability of an application to make the decision to hide arguments from traces, making shared hosting of applications that want to use this feature impossible.

@eriklundin

Copy link
Copy Markdown
Contributor

Opening up security holes from php scripts on various levels isn't especially hard to do for a developer. It’s the default behaviour and the ability to control the default behavior that's important.

If someone writes scripts that logs all postdata on all requests. I would blame the developer. If an unexpected fatal error automatically logs all parameters (including passwords etc). I would blame the sysadmin. And if the sysadmin cant control this i would blame the engine for not allowing control of this.

These errors now occurs on fatal errors which could occur because an extension was enabled or disabled, php upgrades etc. Outside circumstances would then introduce this logging. If a developer would enable argument logging with ini_set() or such i would argue that this should fall under the first category (developers fault).

@bwoebi

Copy link
Copy Markdown
Member

I have mixed feelings about the production default: In particular we already have display_errors=Off - stacktraces can and should probably land with full detail in the normal error logs (hidden from the consumer, visible for the developer/sysadmin)?

@nikicnikic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's land this.

@krakjoe

Copy link
Copy Markdown
MemberAuthor

Merged as 0819e6d

Thanks.

@krakjoekrakjoe closed this Jul 2, 2019
@carusogabrielcarusogabriel modified the milestone: PHP 8.0Jul 23, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@krakjoe@eriklundin@nikic@dstogov@staabm@bwoebi@carusogabriel