TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How secure is my PHP script?

6 点作者 hennerw将近 10 年前

3 条评论

Udo将近 10 年前
I didn&#x27;t go through the whole thing in detail, so please correct me if I got anything wrong, but I think I understand enough of the structure.<p>There are some acute problems that could be solved in code, for example the use of str_replace() in download.php should be replaced by urldecode(), and you should be aware that the following couple of lines after that do exactly nothing to prevent access to arbitrary files on your server. I don&#x27;t mean this in a rude way, but it looks like you still have a ton of reading to do on how webservers work until you can tackle any of these problems with confidence. So no, it&#x27;s not remotely secure, and maybe something that focuses on security is not the best project to get started in the first place.<p>Besides the security aspects, the problem I see is that the script doesn&#x27;t fulfill its own core promise: to regulate file access. You can just circumvent it by taking the filename sent as an argument to download.php and use that to access the thing in the files&#x2F; folder directly if indeed .htaccess isn&#x27;t used (which would automatically apply to, say, any NginX server and which is indeed a scenario you explicitly advertise). If you want to prevent that, you have to either store the files in a place that isn&#x27;t browser-addressable, or at least store them in a way so their names can&#x27;t be guessed.<p>The problem with PHP is that it&#x27;s deceptively easy to make something that looks like it works, but in reality doesn&#x27;t. It&#x27;s an environment that makes it very effortless to shoot yourself in the foot. Personally, I love working with it (as opposed to many other programmers), but it <i>requires</i> that you <i>really</i> know what you&#x27;re doing. I don&#x27;t want to discourage you from using it, but it&#x27;s something you have to be aware of - and if you plan on doing only casual web development, I would highly recommend going with a framework instead.
评论 #9713434 未加载
评论 #9714315 未加载
hennerw将近 10 年前
I created this small script to easily create password protected areas on a server without databases or .htaccess files. The problem is, i am not that involved in PHP and backend programming in general. So i guess there are a few flaws. Can you help me find them?
评论 #9713457 未加载
ufo将近 10 年前
I&#x27;m not sure you will get lots of help if you just dump the code on people like that. Maybe you should update your readme and explain up front how your arquitecture is supposed to work. When it comes to security its often the case that vulnerabilities come from a bad arquitecture and notjust from sloppy coding and bugs.
评论 #9714439 未加载
评论 #9714286 未加载