如何在不泄露任何安全信息或堆栈跟踪的情况下记录错误?

发布于 2025-01-04 06:03:57 字数 184 浏览 2 评论 0原文

当我在我的项目上运行 Fortify Scan 时,我确实看到我正在记录异常

LOGGER.error(e.getMessage(),e);

,它说这不是正确的方法,因为攻击者可能会访问此信息并从中获取系统信息并计划攻击。

做到这一点的最佳方法是什么?(不影响安全性)?

When I run Fortify Scan on my project i do see that i'm logging the exceptions using

LOGGER.error(e.getMessage(),e);

and it says this is not the right way because attckers may get access to this info and get system info from this and plan an attack.

What is the best way to do this?(without compramising on the security)?

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

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

发布评论

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

评论(2

我三岁 2025-01-11 06:03:57

在大多数情况下,这种推理坦率地说是荒谬的。您的 LOGGER 对象应该写入本地文件系统,如果远程攻击者可以访问您的文件系统,您就会遇到更大的问题。

适当限制对日志文件的访问,然后随心所欲地记录。

That reasoning is frankly ridiculous in most cases. Your LOGGER object should be writing to the local filesystem, and if a remote attacker can access your filesystem you've got way bigger problems.

Restrict access to your log files as appropriate, and then log to your heart's content.

手心的温暖 2025-01-11 06:03:57

您可以在生产中关闭注销,但是当最终用户报告错误并且您不知道发生了什么时,这会给您带来很大的不利。

您应该将日志视为关键数据,并在操作系统级别保护对日志的访问,例如对数据库文件的访问。如果攻击者访问数据库,他无论如何都会危害系统。最好只有系统管理员有权访问日志文件,并且仅在需要时才将它们提供给开发人员(生产中的严重错误等)。

You could switch logging off in production, but this would make you great disadvantage when the final user would report error and you would have no idea what had happened.

You should treat your logs as critical data and protect access to them on operating system level, such as access to database files. If attacker would access the database, he would compromise the system anyway. At best only the system admin should have access to log files, and should give them to developers only when needed (critical error on production etc.).

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