PHP - 将数据从一个站点安全地传递到另一个站点
我有一个可以接受来自多个站点的请求的站点。有点像升级检查。 这些网站将发送用户名、密码、应用程序版本等信息,然后我的网站将根据这些信息发送响应。
基本上这是一个 $_GET
请求,类似于:
http://www.mysite.com/?user=boo&password=foo&version=4
我想知道这样做是否会出现任何安全问题。这些数据会被以某种方式“拦截”吗?
I have a site that can take requests from multiple sites. Sort of like a upgrade check.
These sites will send info like user names, passwords, app version etc, then my site will send a response based on this info.
Basically this is a $_GET
request, something like:
http://www.mysite.com/?user=boo&password=foo&version=4
I was wondering if there would be any security issues doing stuff like this. Could this data be "intercepted" somehow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我强烈建议在任何情况下(即使在 SSL 下)不要通过纯文本发送用户名/密码。相反,我建议使用摘要形式的身份验证。
相反,我建议生成一个大的身份验证令牌(一个大尺寸的随机字符串,128 个字符就可以了)。然后,用户将在他们的应用程序中安装这个“令牌”。
现在,当应用程序检查更新时,它首先向您的服务器发出请求,要求提供摘要令牌。这是一种随机的一次性令牌,仅用于一次请求。您的应用程序应该生成一个令牌,将其与时间戳一起以持久格式(文件、内存、数据库等)存储,然后将其发回。
现在,您的应用程序收到此摘要令牌(此处称为
$dt
)。然后,使用已经给出的预配置身份验证令牌对其进行 hmac。然后,将
$authField
发送到服务器。然后,服务器将拆分各个部分:现在,您首先在数据库中查找用户的身份验证令牌并将其存储在
$authToken
中。然后,您查找$digestToken
以确保它存在并且是在不到 60 秒前创建的(如果它太短,您可以调整它,但不要使其显着变长)。无论哪种方式,此时都应将其从数据库中删除(以防止其被重复使用)。现在,如果
$digestToken
存在并且有效,并且您可以找到$authToken
,那么只需执行以下检查:它的好处是每次更改发送的令牌以及单个http请求(任何读取请求流的人都无法从请求中获取任何敏感信息,除了用户名,如果您愿意,您可以进一步屏蔽该用户名)...
Well, I would highly suggest not sending the username / password across plain text under any circumstance (even when under SSL). Instead, I'd suggest using a Digest form of authentication.
Instead, I would suggest generating a large authentication token (a random string of large size, 128 characters would work). Then, the users would install this "token" in their app.
Now, when the app checks for updates, it first fires a request to your server asking for a digest token. This is a random, one time use token that's only used for exactly one request. Your application should generate a token, store it in a durable format (file, memory, database, etc) along with the timestamp, and then send it back.
Now, your application receives this digest token (called
$dt
here). Then, you hmac it with the pre-configured authentication token that was already given.Then, you send the
$authField
to the server. The server will then split the parts:Now, you first lookup the user's authentication token in the database and store it in
$authToken
. Then, you lookup the$digestToken
to make sure that it exists and that it was created less than 60 seconds ago (you can adjust this if it's too short, but don't make it significantly longer). Either way, delete it from the db at this point (to prevent it from being reused).Now, if the
$digestToken
exists and is valid, and you can find a$authToken
, then just do the following check:It has the benefit of changing the sent token each and ever single http request (anyone reading the request stream won't be able to get any sensitive information from the request, other than the username which you could mask further if you'd like)...
安全槽模糊不起作用,使用 POST 代替 GET 只会使信息稍微难以获取如果您确实在监视用户,请抓住。
这里真正的问题是防止人们拦截服务器之间传输的流量。解决这个问题的唯一方法是加密,例如 SSL。当您传输密码等敏感信息时,最好始终尝试使用 SSL。这可能有点难以实现,但就安全性而言绝对是值得的。
然而,防止敏感数据被窃取的最佳方法是从一开始就不要传输它。考虑是否可以选择让您的应用程序在不传输密码的情况下检查更新。如果有可用更新,您可以使用 HTTPS 将用户发送到网页来下载更新,这样就省去了您自己实施 SSL 的麻烦。
Security trough obscurity does not work, and using POST in stead of GET only makes the information slightly harder to snatch up if you're actually looking the user over the shoulder.
The real issue here is preventing people from intercepting the traffic in transit between the servers. The only way to deal with that is encryption, such as SSL. It's a good idea to always try to use SSL when you're transmitting sensitive information like passwords. This can be slightly harder to implement, but it's definitely worth it in terms of security.
However, the best way to keep sensitive data from being snatched up is to not transmit it in the first place. Consider whether it's an option to have your application check for updates without transmitting a password. If an update is available you can send the user to a webpage using HTTPS to download the update, which saves you the trouble of implementing SSL yourself.
使用 .htaccess 修改和隐藏您网站的 URL。
例如:
看起来像:
当您成功创建 .htaccess 文件时,两个 url 将表现相同。
Use .htaccess to modify and cloak the url of your website.
eg:
will be looking like:
when u successfully create the .htaccess file, both the urls will act the same.