PHP 的安全性如何?

发布于 2024-08-06 19:21:05 字数 146 浏览 3 评论 0原文

我对 PHP 编码有点陌生,我知道如果您没有清理 PHP 代码,恶意用户可能会攻击网站。我想知道他们是否需要数据输入框(例如文件提交或用户名/密码输入字段)?

像“include (header.php)”这样的命令是否也需要某种安全性,或者它们本质上是安全的?

I am somewhat new to PHP coding and I am aware that malicious users can hack a website if you have not sanitized your PHP code. What I am wondering is whether they need a data entry box (like for file submissions, or user-name/password entry fields)?.

Do commands like "include (header.php)" also need some sort of security or are they innately safe?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

沩ん囻菔务 2024-08-13 19:21:05

就像任何其他语言一样,PHP 代码与程序员编写的代码一样安全。

与任何其他语言一样,单个(甚至常见)安全风险数量过多且详细,无法包含在 StackOverflow 答案中。

查找一本涵盖安全 PHP 编码的书。

Just like any other language, PHP code is as secure as the programmer writes it.

Also like any other language, individual (and even common) security risks are too numerous and detailed to include in a StackOverflow answer.

Find a book which covers Secure PHP coding.

奢华的一滴泪 2024-08-13 19:21:05

不要相信用户。

include "a/literal/file.php";

非常安全

include $someFile;

意味着您需要考虑如何设置 $someFile 。如果您使用用户提供给您的任何数据来设置 $someFile 的值,您最好对其进行清理。

Don't trust the user.

include "a/literal/file.php";

is quite safe

include $someFile;

means you want to think about how $someFile gets set. If you use any data that was given to you by a user to set $someFile's value, you'd better sanitize it.

带刺的爱情 2024-08-13 19:21:05

引用 RSnake 在 2006 年 sla.ckers.org 上的帖子:

我认为有趣的是 Stefan Esser 从 PHP 事件响应团队退休。并不是要在董事会上掀起一场宗教战争,但有趣的是,PHP 安全响应团队的创始人厌倦了 PHP 缺乏安全性并因此退出。他的网站目前已关闭(流量泛滥?):[blog.php-security.org] 所以这里是缓存的剪切和粘贴:

<块引用>

2006 年 12 月 9 日,星期六

昨晚我终于从 PHP 安全响应团队退休了,这最初是我几年前的想法。

造成这种情况的原因有很多,但最重要的一个是我已经意识到,任何从内部提高PHP安全性的尝试都是徒劳的。当你试图将 PHP 的安全问题归咎于用户时,PHP 小组就会加入你的行列,但当你批评 PHP 本身的安全性时,你就变成了不受欢迎的人。我不再计算因披露 PHP 安全漏洞或开发 Suhosin 而被称为不道德叛徒的次数。

对于普通 PHP 用户来说,这意味着我将不再在我的建议中隐藏对安全漏洞的缓慢响应时间。这也意味着我的一些建议将没有可用的补丁,因为 PHP 安全响应团队几个月来拒绝修复它们。这也意味着将会有更多关于 PHP 安全漏洞的建议。

由 Stefan Esser 在 PHP 安全性方面于 10:58 发布

嗯,虽然这听起来很可怕,但我真的很兴奋终于得到了有关 PHP 安全性的“真正的优惠”。我一直对此有点警惕,看看斯特凡会说什么会很有趣。

来源:http://sla.ckers.org/forum/read.php?2 ,3976

其中很好地介绍了 Hardened PHP 项目 Suhosin http://www.hardened-php .net/suhosin/ 和 Esser 的 PHP Bug 月项目 http://www.php-security。组织/

To quote RSnake from a sla.ckers.org post back in 2006:

I thought what was interesting is that Stefan Esser retired from the PHP incident response team. Not to start a religious war on the boards, but it's interesting that the founder of PHP's security response team is fed up with the lack of security in PHP and quit as a result. His site is down at the moment (traffic flood?): [blog.php-security.org] So here is a cut and paste of the cache:

Saturday, December 9. 2006

Last night I finally retired from the PHP Security Response Team, that was initially my idea a few years ago.

The reasons for this are many, but the most important one is that I have realised that any attempt to improve the security of PHP from the inside is futile. The PHP Group will jump into your boat as soon you try to blame PHP's security problems on the user but the moment you criticize the security of PHP itself you become persona non grata. I stopped counting the times I was called immoral traitor for disclosing security holes in PHP or for developing Suhosin.

For the ordinary PHP user this means that I will no longer hide the slow response time to security holes in my advisories. It will also mean that some of my advisories will come without patches available, because the PHP Security Response Team refused to fix them for months. It will also mean that there will be a lot more advisories about security holes in PHP.

Posted by Stefan Esser in PHP, Security at 10:58

Well, scary as that sounds, I am really excited to finally get the "real deal" on PHP security. I've always been a little wary of it and it will be interesting to see what Stefan has to say.

source: http://sla.ckers.org/forum/read.php?2,3976

Which introduces nicely the Hardened PHP project, Suhosin http://www.hardened-php.net/suhosin/ and Esser's Month of PHP Bugs project http://www.php-security.org/

唯憾梦倾城 2024-08-13 19:21:05

PHP 与任何事物一样安全。但不是默认的,它依赖于程序员的技能。与 .NET 不同,.NET 默认情况下有助于提高安全性。

包含是安全的,只是如果路径是动态生成的,请小心。

下面的内容是无害的(取决于 myfile.php 中的代码)

include("mypath/myfile.php");

PHP is as secure as anything. But not by default, it relies on the skills of the programmer. Unlike .NET which tends to help out with security by default.

Includes are safe just be careful if the paths are being dyanmically generated.

The below is harmless (depending on the code in myfile.php)

include("mypath/myfile.php");
夏花。依旧 2024-08-13 19:21:05

关于数据输入框,应该关注 SQL 注入攻击、溢出、错误字符等。查看诸如 filter_var()mysql_real_escape_string()等函数pg_escape_string() 对于初学者来说。

Regarding data entry boxes, one should be concerned about SQL injection attacks, overflow, bad chars, etc. Check out functions like filter_var(), mysql_real_escape_string(), pg_escape_string() for starters.

情愿 2024-08-13 19:21:05

同意这里每个人的观点 - PHP 本身并不比任何其他语言更安全或更不安全。

不过,您应该深入研究您的 php.ini 文件。您可能应该了解所有指令。这是很多人很早就犯错误的地方。

Agree with everyone here - PHP is not really more or less secure in and of itself than any other language.

You should look deeply into your php.ini file though. You should probably learn about all of the directives. This is where a lot of people make mistakes early on.

一指流沙 2024-08-13 19:21:05

您的问题相当广泛和笼统,但要解决您提出的具体观点:

include (header.php);

相对安全,但

include ($header);

可能是一个危险的安全漏洞,具体取决于 $header 的分配方式以及是否已清理。

Your question is rather broad and general but to address a specific point you made:

include (header.php);

is relatively safe but

include ($header);

is potentially a dangerous security hole depending on how $header was assigned and if it's been sanitized.

々眼睛长脚气 2024-08-13 19:21:05

具体回答这个问题,PHP 作为一种语言是非常安全的。对于语言本身,建议您使用最新的稳定版本以保持基于语言的安全性。 php 维护者是创建和修复错误的人;)

To answer the question specifically, PHP as a language is very secure. For the language itself, it is recommended that you use the latest stable build to keep on top of language-based security. The php maintainers are the ones that create and fix bugs ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文