|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-11-16 08:49 UTC] peter dot mlich at volny dot cz
Description: ------------ --- From manual page: http://www.php.net/function.var-dump --- var_dump ignore class permitions 'private'. Php 5.5.12. Cannot be upgraded, wamp server problem. But, its only for programing and testing. On server have top version, but not run test code there. Test script: --------------- class classDb { private $table; public $structure; function __construct($structure) { $this->table = array(1,2,3); } } $users_db = new classDb('classUser'); var_dump($users_db); // 2 var_dump($users_db->table); // 1 // 1 - Fatal error: Cannot access private property classDb::$table in C:\wamp\www\ // 2 - Show all + all in private $users_db->table :) easy for hackers PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 08:00:02 2025 UTC |
Just curious. If you want to steal "private" property info, why don't you use debug_zval_dump()? $ php -r 'class foo { private $p = "abc"; } $o = new foo; debug_zval_dump($o);' object(foo)#1 (1) refcount(2){ ["p":"foo":private]=> string(3) "abc" refcount(2) } I guess you would like to hide sensitive information in script/object variable from malicious "modules"/"extensions", but it's impossible for many languages/platforms. Java does not allow to dump objects like PHP. Not sure how well other scripting languages hide private property (and app installation path). Are there scripting languages hide private property well and/or hide file path information? (I'm curious about path, too. You can get file path by __FILE__ constant to know app installation path) Mitigation: var_dump()/debug_zval_dump()/get_included_files()/etc are debugging functions. Disable them by disable_functions INI. Or applications can tokenize module/extension PHP code and check unwanted functions. This is very fragile security measure because of nature of blacklist security, though. disable_functions is INI_SYSTEM main/main.c:562: PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL) I guess most secure apps are using environment variables for security sensitive information, so getenv() should be restricted in this case. However, getenv() may be used for good reasons. We may consider change it to INI_PERDIR, perhaps? It may not be feasible. I don't check the code. "Securing PHP application module/extension" is interesting topic, but we don't provide it now. Suggestions are welcome. e.g. Framework that is relatively secure PHP script module/extension, hides application's sensitive information.