为什么 OpenSSL 可能会将接收/写入的数据保留在内存中?

发布于 2024-11-02 14:11:34 字数 530 浏览 0 评论 0原文

我试图确保敏感数据(密码等)不会以明文形式保存在进程内存中,并且我发现发送到 OpenSSL 或从 OpenSSL 接收的所有数据都保存在内存中...

这是一个问题因为从 SSL 连接发送或接收的数据可能包含我们不希望保留在进程内存中的敏感信息。

注意:

  • 仅当使用 SSLv3 或 TLSv1 时才会出现这种情况。使用 SSLv2 时,数据不会保存在内存中。
  • 我使用的是 Ubuntu Lucid 的 0.9.8k-7ubuntu8.6 版本。如果这与安全修复有关,我认为它是最新的。

复制很简单:

  • 使用“openssl client -tls1 -connect hostname:443”连接到 SSL 服务器
  • 在 TLS 连接中发送数据
  • 强制生成核心文件(kill -SEGV例如)
  • 检查核心文件,接收和发送的数据将存在

OpenSSL 可能需要保留该数据的原因是什么?是否可以选择改变其行为?

I'm trying to ensure that sensitive data (passwords, ...) are not kept in clear-text in process memory and I have found that all data sent to or received from OpenSSL is kept in memory...

This is a problem as data sent or received from an SSL connection may contain sensitive information that we don't want to keep in process memory.

Notes:

  • This is only the case when using SSLv3 or TLSv1. When using SSLv2, data is not kept in memory.
  • I am using version 0.9.8k-7ubuntu8.6 from Ubuntu Lucid. If this is related to a security fix, I think it is up to date.

Reproduction is easy:

  • Use 'openssl client -tls1 -connect hostname:443' to connect to an SSL server
  • Send data in TLS connection
  • Force generation of core file (kill -SEGV for example)
  • Inspect core file, received and sent data will be present

Is there a reason for which OpenSSL may need to keep that data? Is there an option to alter its behavior?

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

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

发布评论

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

评论(3

苍白女子 2024-11-09 14:11:34

它仍然在内存中,因为您从未专门覆盖内存内容。它没有充分的理由自动这样做(其他人都会抱怨它使用了不必要的循环)。

您必须自己删除内存内容。该功能不通过命令行程序公开。

It's still in memory because you never specifically overwrote the memory contents. There isn't a good reason for it to do so automatically (everyone else would complain that it uses unnecessary cycles).

You would have to erase the memory contents yourself. That functionality is not exposed via the command-line program.

岁吢 2024-11-09 14:11:34

命令行“客户端”工具仅用于测试。它并不旨在提供实际的安全性或适合实际使用。它有许多功能使其非常不适合任何其他用途,例如,您不能发送“R”,因为这会触发重新协商。

The command-line 'client' tool is just for testing. It's not intended to provide actual security or to be suitable for real use. It has a number of features that make it very unsuitable for any kind of other use, for example, you cannot send a 'R' since that triggers renegotiation.

飘过的浮云 2024-11-09 14:11:34

注意:在找到我正在寻找的解释后,我正在回答我自己的问题。

如果在连接上启用了压缩,则数据将保存在 zlib 缓冲区中。这就是为什么某些配置/服务器没有观察到它的原因。 zlib 肯定需要正确压缩流。

如果您不需要压缩并且不希望未加密的数据在进程内存中长时间保留,则可以禁用 OpenSSL 压缩。

STACK_OF(SSL_COMP)* cm = SSL_COMP_get_compression_methods();
sk_SSL_COMP_zero(cm);

Note: I'm replying to my own question after having found the explanation I was looking for.

The data is kept in zlib buffers if compression is enabled on the connection. That's why it is not observed with some configuration/server. It is surely required by zlib to correctly compress the flow.

If you don't need compression and you don't want unencrypted data to stay for a long time in process memory, you can disable OpenSSL compression.

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