5

我刚刚回答了一个问题,我说虽然字符串实习很好,但它可能是一个安全问题,因为稍后可以轻松访问字符串值。

虽然我很确定这是真的 :-) 我不确定这真的很容易。我试着用谷歌搜索这个话题,但没有得到相关的结果(google-fu 在这方面很弱),所以我在 SO 上试试你们。

您知道访问应用程序域中的 intered 字符串列表的任何“简单”方法吗?我必须使用内存转储之类的东西还是有像 AppDomain.GetInteredStringsList() 这样的方法?

与此相关:从 intered 字符串中获取任何有用的数据真的很容易。将敏感数据存储在字符串中真的是一个安全漏洞吗?

4

4 回答 4

6

这不是特别容易 - 但它是可行的。

基本上,如果您有任何可以进行内存转储的东西,您可以找到看起来像是字符串对象的内存位。(特别是,它们在开始时都会有相同的“类型信息指针”,所以如果你有一个示例字符串,你就离开了。)

顺便说一句,这与实习字符串无关。并非所有字符串都被实习 - 只有字符串常量和用户明确实习的字符串。

于 2008-12-23T13:07:49.073 回答
3

将敏感数据存储在字符串中真的是一个安全漏洞吗?

是的,绝对是的!

sensitive security data should be stored using the SecureString class.

Edit:

because even interned strings are stored in the managed heap, using a tool to dump the heap, will reveal all strings in the application.

于 2008-12-23T13:30:15.207 回答
1

在一个明智的应用程序中,密码存储在字符数组中,以便在不再需要时可以覆盖它们。

于 2008-12-23T13:12:24.353 回答
1

Not impossible to do... although not necessarily through managed code. Anything that has access to a process dump (windb / sos / etc) will have no difficulty looking for strings.

于 2008-12-23T13:48:46.853 回答