避免在一个web应用程序的源代码公开的主键? [英] Avoid exposing primary keys in the source of a web app?

查看:237
本文介绍了避免在一个web应用程序的源代码公开的主键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常会遇到像通过选择框的形式公开内部数据库主键的Web应用程序。偶尔我看到针对切换逻辑int或GUID魔法值的JavaScript匹配。

I often come across web applications that expose internal database primary keys through forms like select boxes. And occasionally I see javascript matching against an int or guid magic value that switches the logic.

时是为了避免泄漏行的所有内部标识在Web应用程序,以prevent外人理解你太多的系统,并可能用它来攻击你的系统的最佳做法。如果有什么是解决这个问题的最好方法是什么?

Is is a best practice to avoid leaking all internal identifiers of rows in your web application to prevent outsiders from understanding too much of your system and possibly using it to exploit your system. If so what is the best way to solve this problem?

如果您揭露一些其他的价值,Web应用程序可以被翻译回主键?

Should you expose some other value to the web app that can be translated back to the primary key?

感谢

修改

在一个完美的世界,你的应用是100%安全的,所以如果你模糊的东西它不会有问题。显然,这并非如此所以我们应该错误谨慎侧面和不公开这些信息?

In a perfect world your application would be 100% secure so it wouldn't matter if you obscured things. Obviously that's not the case so should we error on the side of caution and not expose this information?

有人指出,#2很可能暴露在URL中的一个关键这可能是罚款。不过考虑是为企业应用程序有什么不同?

Some have pointed out that Stackoverflow is probably exposing a key in the Url which is probably fine. However are considerations different for Enterprise Applications?

推荐答案

我不同意的立场,揭露主键是一个问题。它可以是一个问题,如果你让他们来,因为他们给予他们的系统,这通常是你想躲避什么意思之外用户可见。

I disagree with the stance that exposing primary keys is a problem. It can be a problem if you make them visible to users because them they are given meaning outside the system, which is usually what you're trying to avoid.

不过使用的ID作为组合框列表项的价值?去了我说。是什么在做翻译和一些中间值的点?您可能没有使用一个唯一的密钥。这样的翻译介绍了错误更有潜力。

However to use IDs as the value for combo box list items? Go for it I say. What's the point in doing a translation to and from some intermediate value? You may not have a unique key to use. Such a translation introduces more potential for bugs.

只是不要忽视安全性。

如果说你present有6个项目(编号1至6)用户,永远不要假设你只得到这些值从用户回来。有人可能会尝试通过发送回ID 7破坏安全性,所以你还是要确认你回来什么是允许的。

If say you present the user with 6 items (ID 1 to 6), never assume you'll only get those values back from the user. Someone could try and breach security by sending back ID 7 so you still have to verify that what you get back is allowed.

但避免完全?没门。不用了。

But avoiding that entirely? No way. No need.

作为另一个答案评论说,看这个网址。这包括什么毫无疑问是在SO数据库中的问题的主键。这是完全罚款揭露的技术使用密钥。

As a comment on another answer says, look at the URL here. That includes what no doubt is the primary key for the question in the SO database. It's entirely fine to expose keys for technical uses.

另外,如果你使用一些替代值,而不是,这并不一定更安全。

Also, if you do use some surrogate value instead, that's not necessarily more secure.

这篇关于避免在一个web应用程序的源代码公开的主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆